Merge "Fix inconsistent error reporting for invisible content"

This commit is contained in:
jenkins-bot 2019-12-18 09:27:03 +00:00 committed by Gerrit Code Review
commit 0d7e04e1ee
2 changed files with 33 additions and 5 deletions

View file

@ -241,10 +241,7 @@ class Cite {
return StatusValue::newFatal( 'cite_error_references_no_key' );
}
// This doesn't catch the null case because that's guaranteed to trigger other errors
// FIXME: We allow whitespace-only text, should this be invalid? It leaves a
// loophole around the trimmed-text test outside of <references>.
if ( $text === '' ) {
if ( $text === null || trim( $text ) === '' ) {
// <ref> called in <references> has no content.
return StatusValue::newFatal(
'cite_error_empty_references_define',

View file

@ -639,12 +639,43 @@ Attributes are trimmed by the parser, see Sanitizer::decodeTagAttributes()
<li id="cite_note-foo-1"><span class="mw-cite-backlink"><a href="#cite_ref-foo_1-0">↑</a></span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag;
no text was provided for refs named <code>foo</code></span></li>
</ol></div>
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "unused" defined in <code>&lt;references&gt;</code> is not used in prior text.</span><br />
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag defined in <code>&lt;references&gt;</code> with name "foo" has no content.</span><br />
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag with name "unused" defined in <code>&lt;references&gt;</code> is not used in prior text.</span><br />
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag in <code>&lt;references&gt;</code> has conflicting group attribute "1".</span><br />
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag defined in <code>&lt;references&gt;</code> has no name attribute.</span>
</p>
!! end
!! test
Error conditions on non-visible content
!! wikitext
<ref name="a">x</ref>
<ref name="b"> </ref>
<ref name="c" />
<references>
<ref name="a" />
<ref name="b" />
<ref name="c"> </ref>
</references>
!! html
<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>
<sup id="cite_ref-c_3-0" class="reference"><a href="#cite_note-c-3">&#91;3&#93;</a></sup>
</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">x</span>
</li>
<li id="cite_note-b-2"><span class="mw-cite-backlink"><a href="#cite_ref-b_2-0">↑</a></span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag;
no text was provided for refs named <code>b</code></span></li>
<li id="cite_note-c-3"><span class="mw-cite-backlink"><a href="#cite_ref-c_3-0">↑</a></span> <span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: Invalid <code>&lt;ref&gt;</code> tag;
no text was provided for refs named <code>c</code></span></li>
</ol></div>
<p><span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag defined in <code>&lt;references&gt;</code> with name "a" has no content.</span><br />
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag defined in <code>&lt;references&gt;</code> with name "b" has no content.</span><br />
<span class="error mw-ext-cite-error" lang="en" dir="ltr">Cite error: <code>&lt;ref&gt;</code> tag defined in <code>&lt;references&gt;</code> with name "c" has no content.</span>
</p>
!! end
!! article
MediaWiki:cite_link_label_group-klingon
!! text