if ( $label == '' ) {
$label = $title->getPrefixedText();
}
- $encLabel = htmlspecialchars( $label );
$currentExists = $time
&& MediaWikiServices::getInstance()->getRepoGroup()->findFile( $title ) !== false;
if ( ( $wgUploadMissingFileUrl || $wgUploadNavigationUrl || $wgEnableUploads )
&& !$currentExists
) {
- $redir = RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title );
-
- if ( $redir ) {
- // We already know it's a redirect, so mark it
- // accordingly
+ if ( RepoGroup::singleton()->getLocalRepo()->checkRedirect( $title ) ) {
+ // We already know it's a redirect, so mark it accordingly
return self::link(
$title,
- $encLabel,
+ htmlspecialchars( $label ),
[ 'class' => 'mw-redirect' ],
wfCgiToArray( $query ),
[ 'known', 'noclasses' ]
);
}
- $href = self::getUploadUrl( $title, $query );
-
- return '<a href="' . htmlspecialchars( $href ) . '" class="new" title="' .
- htmlspecialchars( $title->getPrefixedText(), ENT_QUOTES ) . '">' .
- $encLabel . '</a>';
+ return Html::element( 'a', [
+ 'href' => self::getUploadUrl( $title, $query ),
+ 'class' => 'new',
+ 'title' => $title->getPrefixedText()
+ ], $label );
}
- return self::link( $title, $encLabel, [], wfCgiToArray( $query ), [ 'known', 'noclasses' ] );
+ return self::link(
+ $title,
+ htmlspecialchars( $label ),
+ [],
+ wfCgiToArray( $query ),
+ [ 'known', 'noclasses' ]
+ );
}
/**
!! wikitext
[[File:Cool "Gator".png]]
!! html/php+tidy
-<p><a href="/index.php?title=Special:Upload&wpDestFile=Cool_%22Gator%22.png" class="new" title="File:Cool "Gator".png">File:Cool "Gator".png</a>
+<p><a href="/index.php?title=Special:Upload&wpDestFile=Cool_%22Gator%22.png" class="new" title="File:Cool "Gator".png">File:Cool "Gator".png</a>
</p>
!! html/parsoid
<p><figure-inline class="mw-default-size" typeof="mw:Error mw:Image" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}'><a href="./Special:FilePath/Cool_%22Gator%22.png"><span resource='./File:Cool_"Gator".png' data-parsoid='{"a":{"resource":"./File:Cool_\"Gator\".png"},"sa":{"resource":"File:Cool \"Gator\".png"}}'>File:Cool "Gator".png</span></a></figure-inline></p>
[[File:Nonexistent|<]]
[[File:Nonexistent|a<i>b</i>c]]
!! html/php
-<p><a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent"><script></script></a>
-<a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent"><script></script></a>
+<p><a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent"><script></script></a>
+<a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent"><script></script></a>
<a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent"><</a>
<a href="/index.php?title=Special:Upload&wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
</p>