From b8efcb0e1ad96e79e9c9741850a2e4d6c7f3979f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerg=C5=91=20Tisza?= Date: Sat, 13 Oct 2018 22:43:17 -0700 Subject: [PATCH] Unstrip contents before comparing When used as {{#tag:ref|...}}, references can contain strip markers, and different strip markers can hide the same text, so unstrip before comparing to avoid false warnings. Bug: T205803 Change-Id: I059fd853d1eea07aa06cc85f80e463dd97fd171a --- includes/Cite.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/includes/Cite.php b/includes/Cite.php index 316bdb773..1f9ddd472 100644 --- a/includes/Cite.php +++ b/includes/Cite.php @@ -380,7 +380,7 @@ class Cite { # we'll figure that out later. Likewise it's definitely valid # if there's any content, regardless of key. - return $this->stack( $str, $key, $group, $follow, $argv, $dir ); + return $this->stack( $str, $key, $group, $follow, $argv, $dir, $parser ); } # Not clear how we could get here, but something is probably @@ -465,12 +465,13 @@ class Cite { * @param string $group * @param string|null $follow * @param string[] $call - * @param $dir ref direction + * @param string $dir ref direction + * @param Parser $parser * * @throws Exception * @return string */ - private function stack( $str, $key, $group, $follow, array $call, $dir ) { + private function stack( $str, $key, $group, $follow, array $call, $dir, Parser $parser ) { if ( !isset( $this->mRefs[$group] ) ) { $this->mRefs[$group] = []; } @@ -551,7 +552,11 @@ class Cite { $this->mRefCallStack[] = [ 'assign', $call, $str, $key, $group, $this->mRefs[$group][$key]['key'] ]; } else { - if ( $str != null && $str !== '' && $str !== $this->mRefs[$group][$key]['text'] ) { + if ( $str != null && $str !== '' + // T205803 different strip markers might hide the same text + && $parser->mStripState->unstripBoth( $str ) + !== $parser->mStripState->unstripBoth( $this->mRefs[$group][$key]['text'] ) + ) { // two refs with same key and different content // add error message to the original ref $this->mRefs[$group][$key]['text'] .= ' ' . $this->plainError(