mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-27 16:30:12 +00:00
Merge "Don't break when reference names contain []"
This commit is contained in:
commit
53e260e90a
|
@ -411,13 +411,13 @@ class Cite {
|
|||
}
|
||||
if ( isset( $argv['name'] ) ) {
|
||||
// Key given.
|
||||
$key = Sanitizer::escapeIdForAttribute( $argv['name'] );
|
||||
$key = trim( $argv['name'] );
|
||||
unset( $argv['name'] );
|
||||
--$cnt;
|
||||
}
|
||||
if ( isset( $argv['follow'] ) ) {
|
||||
// Follow given.
|
||||
$follow = Sanitizer::escapeIdForAttribute( $argv['follow'] );
|
||||
$follow = trim( $argv['follow'] );
|
||||
unset( $argv['follow'] );
|
||||
--$cnt;
|
||||
}
|
||||
|
@ -814,10 +814,10 @@ class Cite {
|
|||
if ( !is_array( $val ) ) {
|
||||
return wfMessage(
|
||||
'cite_references_link_one',
|
||||
Sanitizer::safeEncodeAttribute(
|
||||
$this->normalizeKey(
|
||||
self::getReferencesKey( $key )
|
||||
),
|
||||
Sanitizer::safeEncodeAttribute(
|
||||
$this->normalizeKey(
|
||||
$this->refKey( $key )
|
||||
),
|
||||
$this->referenceText( $key, $val )
|
||||
|
@ -827,7 +827,7 @@ class Cite {
|
|||
if ( isset( $val['follow'] ) ) {
|
||||
return wfMessage(
|
||||
'cite_references_no_link',
|
||||
Sanitizer::safeEncodeAttribute(
|
||||
$this->normalizeKey(
|
||||
self::getReferencesKey( $val['follow'] )
|
||||
),
|
||||
$text
|
||||
|
@ -836,7 +836,7 @@ class Cite {
|
|||
if ( !isset( $val['count'] ) ) {
|
||||
// this handles the case of section preview for list-defined references
|
||||
return wfMessage( 'cite_references_link_many',
|
||||
Sanitizer::safeEncodeAttribute(
|
||||
$this->normalizeKey(
|
||||
self::getReferencesKey( $key . "-" . ( isset( $val['key'] ) ? $val['key'] : '' ) )
|
||||
),
|
||||
'',
|
||||
|
@ -846,10 +846,10 @@ class Cite {
|
|||
if ( $val['count'] < 0 ) {
|
||||
return wfMessage(
|
||||
'cite_references_link_one',
|
||||
Sanitizer::safeEncodeAttribute(
|
||||
$this->normalizeKey(
|
||||
self::getReferencesKey( $val['key'] )
|
||||
),
|
||||
Sanitizer::safeEncodeAttribute(
|
||||
$this->normalizeKey(
|
||||
# $this->refKey( $val['key'], $val['count'] )
|
||||
$this->refKey( $val['key'] )
|
||||
),
|
||||
|
@ -863,10 +863,10 @@ class Cite {
|
|||
if ( $val['count'] === 0 ) {
|
||||
return wfMessage(
|
||||
'cite_references_link_one',
|
||||
Sanitizer::safeEncodeAttribute(
|
||||
$this->normalizeKey(
|
||||
self::getReferencesKey( $key . "-" . $val['key'] )
|
||||
),
|
||||
Sanitizer::safeEncodeAttribute(
|
||||
$this->normalizeKey(
|
||||
# $this->refKey( $key, $val['count'] ),
|
||||
$this->refKey( $key, $val['key'] . "-" . $val['count'] )
|
||||
),
|
||||
|
@ -879,7 +879,7 @@ class Cite {
|
|||
for ( $i = 0; $i <= $val['count']; ++$i ) {
|
||||
$links[] = wfMessage(
|
||||
'cite_references_link_many_format',
|
||||
Sanitizer::safeEncodeAttribute(
|
||||
$this->normalizeKey(
|
||||
$this->refKey( $key, $val['key'] . "-$i" )
|
||||
),
|
||||
$this->referencesFormatEntryNumericBacklinkLabel( $val['number'], $i, $val['count'] ),
|
||||
|
@ -890,7 +890,7 @@ class Cite {
|
|||
$list = $this->listToText( $links );
|
||||
|
||||
return wfMessage( 'cite_references_link_many',
|
||||
Sanitizer::safeEncodeAttribute(
|
||||
$this->normalizeKey(
|
||||
self::getReferencesKey( $key . "-" . $val['key'] )
|
||||
),
|
||||
$list,
|
||||
|
@ -1049,10 +1049,10 @@ class Cite {
|
|||
$this->mParser->recursiveTagParse(
|
||||
wfMessage(
|
||||
'cite_reference_link',
|
||||
Sanitizer::safeEncodeAttribute(
|
||||
$this->normalizeKey(
|
||||
$this->refKey( $key, $count )
|
||||
),
|
||||
Sanitizer::safeEncodeAttribute(
|
||||
$this->normalizeKey(
|
||||
self::getReferencesKey( $key . $subkey )
|
||||
),
|
||||
Sanitizer::safeEncodeAttribute(
|
||||
|
@ -1063,6 +1063,19 @@ class Cite {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes and sanitizes a reference key
|
||||
*
|
||||
* @param string $key
|
||||
* @return string
|
||||
*/
|
||||
private function normalizeKey( $key ) {
|
||||
$key = Sanitizer::escapeIdForAttribute( $key );
|
||||
$key = Sanitizer::safeEncodeAttribute( $key );
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
/**
|
||||
* This does approximately the same thing as
|
||||
* Language::listToText() but due to this being used for a
|
||||
|
|
|
@ -608,6 +608,21 @@ Multiple definition (inside {{#tag:references}})
|
|||
|
||||
!! end
|
||||
|
||||
!! test
|
||||
T29694 - [] in reference names in HTML5 fragment mode
|
||||
!! config
|
||||
wgFragmentMode=[ 'html5' ]
|
||||
!! wikitext
|
||||
<ref name="[#foo] {bar} <baz>">[bar]</ref>
|
||||
!! html
|
||||
<sup id="cite_ref-[#foo]_{bar}_<baz_1-0" class="reference"><a href="#cite_note-[#foo]_{bar}_<baz-1">[1]</a></sup><div class="mw-references-wrap"><ol class="references">
|
||||
<li id="cite_note-[#foo]_{bar}_<baz-1"><span class="mw-cite-backlink"><a href="#cite_ref-[#foo]_{bar}_<baz_1-0">↑</a></span> <span class="reference-text">">[bar]</span>
|
||||
</li>
|
||||
</ol></div>
|
||||
|
||||
!! end
|
||||
|
||||
|
||||
#### ----------------------------------------------------------------
|
||||
#### Parsoid-only testing of Parsoid's impl of <ref> and <references>
|
||||
#### tags. Parsoid's output for these tags differs from that of the
|
||||
|
|
Loading…
Reference in a new issue