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
e01adbfc0bd9f39adffc1f955ccc711e73818194.
Change-Id: I80479600f34170651732b032e8881855aa1204d8
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 ===
* …
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...
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 );
* 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 );