From fe385ecc371f9d7fe7e98c3ffdfec7e6a7cf900e Mon Sep 17 00:00:00 2001 From: Thiemo Kreuz Date: Tue, 5 Nov 2019 16:02:12 +0100 Subject: [PATCH] =?UTF-8?q?Block=20all=20combinations=20of=20refines=3D"?= =?UTF-8?q?=E2=80=A6"=20and=20follows=3D"=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note it doesn't make a difference if this is behind the feature flag or not. It should always be forbidden, and in fact is: Either the follows attribute is unknown, or the combination is forbidden. Bug: T236256 Change-Id: Iebbb2d1d5bab183ab0590b8a7a7f6e79d319b72c --- includes/Cite.php | 4 +++- tests/parser/bookReferencing.txt | 8 ++++++-- tests/phpunit/CiteTest.php | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/includes/Cite.php b/includes/Cite.php index 1692a8c34..e22053c4e 100644 --- a/includes/Cite.php +++ b/includes/Cite.php @@ -415,7 +415,9 @@ class Cite { return [ null, null, false, $dir, null ]; } - if ( isset( $argv['name'] ) && isset( $argv['follow'] ) ) { + if ( isset( $argv['follow'] ) && + ( isset( $argv['name'] ) || isset( $argv[self::REFINES_ATTRIBUTE] ) ) + ) { return [ false, false, false, false, false ]; } diff --git a/tests/parser/bookReferencing.txt b/tests/parser/bookReferencing.txt index c113fb117..5ff85c711 100644 --- a/tests/parser/bookReferencing.txt +++ b/tests/parser/bookReferencing.txt @@ -416,9 +416,11 @@ wgCiteBookReferencing=true !! html/php

[1] +Cite error: Invalid <ref> tag; +invalid names, e.g. too many

    -
  1. book 1 huh? +
  2. book 1
!! end @@ -437,9 +439,11 @@ wgCiteBookReferencing=true !! html/php

[1] [2] +Cite error: Invalid <ref> tag; +invalid names, e.g. too many

    -
  1. book 1 huh? +
  2. book 1
  3. book 2
  4. diff --git a/tests/phpunit/CiteTest.php b/tests/phpunit/CiteTest.php index bfea5b235..1510f28f6 100644 --- a/tests/phpunit/CiteTest.php +++ b/tests/phpunit/CiteTest.php @@ -43,7 +43,7 @@ class CiteTest extends MediaWikiTestCase { // Pairs [ [ 'follow' => 'f', 'name' => 'n' ], [ false, false, false, false, false ] ], [ [ 'follow' => null, 'name' => null ], [ false, false, false, false, false ] ], - [ [ 'follow' => 'f', 'refines' => 'r' ], [ null, null, 'f', null, 'r' ] ], + [ [ 'follow' => 'f', 'refines' => 'r' ], [ false, false, false, false, false ] ], [ [ 'group' => 'g', 'name' => 'n' ], [ 'n', 'g', null, null, null ] ], // Combinations of 3 or more attributes