X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FXml.php;h=8289b818c1446955bd5da50032366cee34013975;hb=f44275ec1f2d243563b60041b7a29052f60bda24;hp=4c6b0715b0a53edf1329eccdef2bc21592d8ef09;hpb=84851a43f3ea8ea146c4d82c55fd01b9fa302347;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Xml.php b/includes/Xml.php index 4c6b0715b0..8289b818c1 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -59,8 +59,8 @@ class Xml { * Given an array of ('attributename' => 'value'), it generates the code * to set the XML attributes : attributename="value". * The values are passed to Sanitizer::encodeAttribute. - * Return null if no attributes given. - * @param array $attribs Array of attributes for an XML element + * Returns null or empty string if no attributes given. + * @param array|null $attribs Array of attributes for an XML element * @throws MWException * @return null|string */ @@ -613,42 +613,6 @@ class Xml { $content, false ); } - /** - * Returns an escaped string suitable for inclusion in a string literal - * for JavaScript source code. - * Illegal control characters are assumed not to be present. - * - * @deprecated since 1.21; use Xml::encodeJsVar() or Xml::encodeJsCall() instead - * @param string $string String to escape - * @return string - */ - public static function escapeJsString( $string ) { - // See ECMA 262 section 7.8.4 for string literal format - $pairs = [ - "\\" => "\\\\", - "\"" => "\\\"", - '\'' => '\\\'', - "\n" => "\\n", - "\r" => "\\r", - - # To avoid closing the element or CDATA section - "<" => "\\x3c", - ">" => "\\x3e", - - # To avoid any complaints about bad entity refs - "&" => "\\x26", - - # Work around https://bugzilla.mozilla.org/show_bug.cgi?id=274152 - # Encode certain Unicode formatting chars so affected - # versions of Gecko don't misinterpret our strings; - # this is a common problem with Farsi text. - "\xe2\x80\x8c" => "\\u200c", // ZERO WIDTH NON-JOINER - "\xe2\x80\x8d" => "\\u200d", // ZERO WIDTH JOINER - ]; - - return strtr( $string, $pairs ); - } - /** * Encode a variable of arbitrary type to JavaScript. * If the value is an XmlJsCode object, pass through the object's value verbatim. @@ -863,27 +827,3 @@ class Xml { } } -/** - * A wrapper class which causes Xml::encodeJsVar() and Xml::encodeJsCall() to - * interpret a given string as being a JavaScript expression, instead of string - * data. - * - * Example: - * - * Xml::encodeJsVar( new XmlJsCode( 'a + b' ) ); - * - * Returns "a + b". - * - * @note As of 1.21, XmlJsCode objects cannot be nested inside objects or arrays. The sole - * exception is the $args argument to Xml::encodeJsCall() because Xml::encodeJsVar() is - * called for each individual element in that array. - * - * @since 1.17 - */ -class XmlJsCode { - public $value; - - function __construct( $value ) { - $this->value = $value; - } -}