From c05b4c9bc4a644e1cb9b99b3a62be01573811301 Mon Sep 17 00:00:00 2001 From: Jackmcbarn Date: Fri, 6 Jun 2014 15:56:19 -0400 Subject: [PATCH] Re-emit unknown tags from #tag When #tag is given a tag that it doesn't recognize, re-emit it as a regular tag instead of giving an error. This allows for it to be used with transparent tags and HTML tags. Change-Id: I0ceee8a4fdaf2d3142054a108f445ff06597c31a --- includes/parser/CoreParserFunctions.php | 20 +++++++++++++------- languages/i18n/en.json | 1 - languages/i18n/qqq.json | 1 - 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index e820fe2bd2..a95bbfee85 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -953,13 +953,6 @@ class CoreParserFunctions { $inner = null; } - $stripList = $parser->getStripList(); - if ( !in_array( $tagName, $stripList ) ) { - return '' . - wfMessage( 'unknown_extension_tag', $tagName )->inContentLanguage()->text() . - ''; - } - $attributes = array(); foreach ( $args as $arg ) { $bits = $arg->splitArg(); @@ -973,6 +966,19 @@ class CoreParserFunctions { } } + $stripList = $parser->getStripList(); + if ( !in_array( $tagName, $stripList ) ) { + // we can't handle this tag (at least not now), so just re-emit it as an ordinary tag + $attrText = ''; + foreach ( $attributes as $name => $value ) { + $attrText .= ' ' . htmlspecialchars( $name ) . '="' . htmlspecialchars( $value ) . '"'; + } + if ( $inner === null ) { + return "<$tagName$attrText/>"; + } + return "<$tagName$attrText>$inner"; + } + $params = array( 'name' => $tagName, 'inner' => $inner, diff --git a/languages/i18n/en.json b/languages/i18n/en.json index da49fe90a9..8fc9cf2e17 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -3244,7 +3244,6 @@ "signature": "[[{{ns:user}}:$1|$2]] ([[{{ns:user_talk}}:$1|talk]])", "signature-anon": "[[{{#special:Contributions}}/$1|$2]]", "timezone-utc": "UTC", - "unknown_extension_tag": "Unknown extension tag \"$1\"", "duplicate-defaultsort": "Warning: Default sort key \"$2\" overrides earlier default sort key \"$1\".", "duplicate-displaytitle": "Warning: Display title \"$2\" overrides earlier display title \"$1\".", "invalid-indicator-name": "Error: Page status indicators' name attribute must not be empty.", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 42ae44c97b..2c01b0241c 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -3408,7 +3408,6 @@ "signature": "This will be substituted in the signature (~~~ or ~~~~ excluding timestamp).\n\nParameters:\n* $1 - the username that is currently login\n* $2 - the customized signature which is specified in [[Special:Preferences|user's preferences]] as non-raw\nUse your language default parentheses ({{msg-mw|parentheses}}), but not use the message direct.\n\nSee also:\n* {{msg-mw|Signature-anon}} - signature for anonymous user", "signature-anon": "{{notranslate}}\nUsed as signature for anonymous user. Parameters:\n* $1 - username (IP address?)\n* $2 - nickname (IP address?)\nSee also:\n* {{msg-mw|Signature}} - signature for registered user", "timezone-utc": "{{optional}}", - "unknown_extension_tag": "This is an error shown when you use an unknown extension tag name.\n\nThis feature allows tags like
 to be called with a parser like {{#tag:pre}}.\n\nParameters:\n* $1 - the unknown extension tag name",
 	"duplicate-defaultsort": "See definition of [[w:Sorting|sort key]] on Wikipedia. Parameters:\n* $1 - old default sort key\n* $2 - new default sort key",
 	"duplicate-displaytitle": "Warning shown when a page has its display title set multiple times. Parameters:\n* $1 - old display title\n* $2 - new display title",
 	"invalid-indicator-name": "Warning shown when the [https://www.mediawiki.org/wiki/Help:Page_status_indicators <indicator name=\"''unique-identifier''\">''content''</indicator>] parser tag is used incorrectly.",
-- 
2.20.1