Block all combinations of refines="…" and follows="…"

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
This commit is contained in:
Thiemo Kreuz 2019-11-05 16:02:12 +01:00
parent d919615e28
commit fe385ecc37
3 changed files with 10 additions and 4 deletions

View file

@ -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 ];
}

View file

@ -416,9 +416,11 @@ wgCiteBookReferencing=true
<references />
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag;
invalid names, e.g. too many</span>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book 1 huh?</span>
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book 1</span>
</li>
</ol></div>
!! end
@ -437,9 +439,11 @@ wgCiteBookReferencing=true
!! html/php
<p><sup id="cite_ref-a_1-0" class="reference"><a href="#cite_note-a-1">&#91;1&#93;</a></sup>
<sup id="cite_ref-b_2-0" class="reference"><a href="#cite_note-b-2">&#91;2&#93;</a></sup>
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag;
invalid names, e.g. too many</span>
</p>
<div class="mw-references-wrap"><ol class="references">
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book 1 huh?</span>
<li id="cite_note-a-1"><span class="mw-cite-backlink"><a href="#cite_ref-a_1-0">↑</a></span> <span class="reference-text">book 1</span>
</li>
<li id="cite_note-b-2"><span class="mw-cite-backlink"><a href="#cite_ref-b_2-0">↑</a></span> <span class="reference-text">book 2</span>
</li>

View file

@ -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