Deprecate Language::markNoConversion, which confuses readers
Language::markNoConversion is used only within Parser.php and differs
from LanguageConverter::markNoConversion in that, contrary to its name
and its namesake, it only protects *things which look like URLs* from
language conversion.
This wasted several days of my time before I realized what was going on.
It's needless; just hoist the "looks like a URL" special casing inline
to the single place where that functionality is used. (And I wonder
if the "looks like a URL" case is actually needed at all any more,
since most of those cases are probably free external links, which
go through a different code path, not bracketed external links.)
This is a clean-up to the clean-up that liangent performed in 2012
with e01adbfc0b.
Change-Id: I80479600f34170651732b032e8881855aa1204d8
This commit is contained in:
parent
70c79f3fc2
commit
7de2c566dd
3 changed files with 15 additions and 3 deletions
|
|
@ -207,6 +207,10 @@ because of Phabricator reports.
|
|||
generate cryptographically secure random byte sequences.
|
||||
* Parser::getConverterLanguage() is deprecated. Use ::getTargetLanguage()
|
||||
instead.
|
||||
* Language::markNoConversion() is deprecated. It confused readers because
|
||||
it had unexpected behavior (only marking text if it looked like a URL)
|
||||
and was only used in a single place in the code. Use
|
||||
LanguageConverter::markNoConversion() instead.
|
||||
|
||||
=== Other changes in 1.32 ===
|
||||
* …
|
||||
|
|
|
|||
|
|
@ -1606,7 +1606,7 @@ class Parser {
|
|||
if ( $text === false ) {
|
||||
# Not an image, make a link
|
||||
$text = Linker::makeExternalLink( $url,
|
||||
$this->getTargetLanguage()->markNoConversion( $url, true ),
|
||||
$this->getTargetLanguage()->getConverter()->markNoConversion( $url ),
|
||||
true, 'free',
|
||||
$this->getExternalLinkAttribs( $url ), $this->mTitle );
|
||||
# Register it in the output object...
|
||||
|
|
@ -1895,7 +1895,10 @@ class Parser {
|
|||
list( $dtrail, $trail ) = Linker::splitTrail( $trail );
|
||||
}
|
||||
|
||||
$text = $this->getTargetLanguage()->markNoConversion( $text );
|
||||
// Excluding protocol-relative URLs may avoid many false positives.
|
||||
if ( preg_match( '/^(?:' . wfUrlProtocolsWithoutProtRel() . ')/', $text ) ) {
|
||||
$text = $this->getTargetLanguage()->getConverter()->markNoConversion( $text );
|
||||
}
|
||||
|
||||
$url = Sanitizer::cleanUrl( $url );
|
||||
|
||||
|
|
|
|||
|
|
@ -4321,13 +4321,18 @@ class Language {
|
|||
* the "raw" tag (-{R| }-) to prevent conversion.
|
||||
*
|
||||
* This function is called "markNoConversion" for historical
|
||||
* reasons.
|
||||
* reasons *BUT DIFFERS SIGNIFICANTLY* from
|
||||
* LanguageConverter::markNoConversion(), with which it is easily
|
||||
* confused.
|
||||
*
|
||||
* @param string $text Text to be used for external link
|
||||
* @param bool $noParse Wrap it without confirming it's a real URL first
|
||||
* @return string The tagged text
|
||||
* @deprecated since 1.32, use LanguageConverter::markNoConversion()
|
||||
* instead.
|
||||
*/
|
||||
public function markNoConversion( $text, $noParse = false ) {
|
||||
wfDeprecated( __METHOD__, '1.32' );
|
||||
// Excluding protocal-relative URLs may avoid many false positives.
|
||||
if ( $noParse || preg_match( '/^(?:' . wfUrlProtocolsWithoutProtRel() . ')/', $text ) ) {
|
||||
return $this->mConverter->markNoConversion( $text );
|
||||
|
|
|
|||
Loading…
Reference in a new issue