X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fjson%2FFormatJson.php;h=b99b0b826cecd71cb35a7ff2e8901783ebb5b884;hb=769953fe7b910a45a201d61d24d832063d6fc3cb;hp=0c77a7bcc2d90bae6958602e6ce254022bb5b333;hpb=350dcb4cd7990daa4ea8fe4c8335f9353f442605;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/json/FormatJson.php b/includes/json/FormatJson.php index 0c77a7bcc2..b99b0b826c 100644 --- a/includes/json/FormatJson.php +++ b/includes/json/FormatJson.php @@ -77,17 +77,6 @@ class FormatJson { */ const STRIP_COMMENTS = 0x400; - /** - * Regex that matches whitespace inside empty arrays and objects. - * - * This doesn't affect regular strings inside the JSON because those can't - * have a real line break (\n) in them, at this point they are already escaped - * as the string "\n" which this doesn't match. - * - * @private - */ - const WS_CLEANUP_REGEX = '/(?<=[\[{])\n\s*+(?=[\]}])/'; - /** * Characters problematic in JavaScript. * @@ -95,8 +84,8 @@ class FormatJson { * and U+000D (CR). However, PHP already escapes LF and CR according to RFC 4627. */ private static $badChars = [ - "\xe2\x80\xa8", // U+2028 LINE SEPARATOR - "\xe2\x80\xa9", // U+2029 PARAGRAPH SEPARATOR + "\u{2028}", // U+2028 LINE SEPARATOR + "\u{2029}", // U+2029 PARAGRAPH SEPARATOR ]; /** @@ -129,11 +118,6 @@ class FormatJson { $pretty = $pretty ? ' ' : false; } - static $bug66021; - if ( $pretty !== false && $bug66021 === null ) { - $bug66021 = json_encode( [], JSON_PRETTY_PRINT ) !== '[]'; - } - // PHP escapes '/' to prevent breaking out of inline script blocks using '', // which is hardly useful when '<' and '>' are escaped (and inadequate), and such // escaping negatively impacts the human readability of URLs and similar strings. @@ -147,10 +131,6 @@ class FormatJson { } if ( $pretty !== false ) { - // Workaround for - if ( $bug66021 ) { - $json = preg_replace( self::WS_CLEANUP_REGEX, '', $json ); - } if ( $pretty !== ' ' ) { // Change the four-space indent to a tab indent $json = str_replace( "\n ", "\n\t", $json );