diff --git a/src/Cite.php b/src/Cite.php index fe6ff4aba..ae012cb07 100644 --- a/src/Cite.php +++ b/src/Cite.php @@ -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 . - if ( $text === '' ) { + if ( $text === null || trim( $text ) === '' ) { // called in has no content. return StatusValue::newFatal( 'cite_error_empty_references_define', diff --git a/tests/parser/citeParserTests.txt b/tests/parser/citeParserTests.txt index 29e4a4156..dc7cb77e9 100644 --- a/tests/parser/citeParserTests.txt +++ b/tests/parser/citeParserTests.txt @@ -639,12 +639,43 @@ Attributes are trimmed by the parser, see Sanitizer::decodeTagAttributes()
  • Cite error: Invalid <ref> tag; no text was provided for refs named foo
  • -

    Cite error: <ref> tag with name "unused" defined in <references> is not used in prior text.
    +

    Cite error: <ref> tag defined in <references> with name "foo" has no content.
    +Cite error: <ref> tag with name "unused" defined in <references> is not used in prior text.
    Cite error: <ref> tag in <references> has conflicting group attribute "1".
    Cite error: <ref> tag defined in <references> has no name attribute.

    !! end +!! test +Error conditions on non-visible content +!! wikitext +x + + + + + + + +!! html +

    [1] +[2] +[3] +

    +
      +
    1. x +
    2. +
    3. Cite error: Invalid <ref> tag; +no text was provided for refs named b
    4. +
    5. Cite error: Invalid <ref> tag; +no text was provided for refs named c
    6. +
    +

    Cite error: <ref> tag defined in <references> with name "a" has no content.
    +Cite error: <ref> tag defined in <references> with name "b" has no content.
    +Cite error: <ref> tag defined in <references> with name "c" has no content. +

    +!! end + !! article MediaWiki:cite_link_label_group-klingon !! text