@@ -19,8 +19,7 @@ class HJSONStringifier
1919 // needsQuotes tests if the string can be written as a quoteless string (includes needsEscape but without \\ and \")
2020 private $ needsQuotes = '/^ \\s|^"|^ \'|^ \'\'\'|^#|^ \\/ \\*|^ \\/ \\/|^ \\{|^ \\}|^ \\[|^ \\]|^:|^,| \\s$|[\x00-\x1f\x7f-\x9f\x{00ad}\x{0600}-\x{0604}\x{070f}\x{17b4}\x{17b5}\x{200c}-\x{200f}\x{2028}-\x{202f}\x{2060}-\x{206f}\x{feff}\x{fff0}-\x{ffff}\x]/u ' ;
2121 // needsEscapeML tests if the string can be written as a multiline string (includes needsEscape but without \n, \r, \\ and \")
22- private $ needsEscapeML = '/ \'\'\'|[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f\x{00ad}\x{0600}-\x{0604}\x{070f}\x{17b4}\x{17b5}\x{200c}-\x{200f}\x{2028}-\x{202f}\x{2060}-\x{206f}\x{feff}\x{fff0}-\x{ffff}\x]/u ' ;
23- private $ onlyWhitespace = '/^ \\s+$/ ' ;
22+ private $ needsEscapeML = '/^ \\s+$| \'\'\'|[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f\x{00ad}\x{0600}-\x{0604}\x{070f}\x{17b4}\x{17b5}\x{200c}-\x{200f}\x{2028}-\x{202f}\x{2060}-\x{206f}\x{feff}\x{fff0}-\x{ffff}\x]/u ' ;
2423 private $ startsWithKeyword = '/^(true|false|null)\s*((,|\]|\}|#|\/\/|\/\*).*)?$/ ' ;
2524 private $ needsEscapeName = '/[,\{\[\}\]\s:#" \']|\/\/|\/\*| \'\'\'/ ' ;
2625 private $ gap = '' ;
@@ -142,11 +141,7 @@ private function quote($string = null, $gap = null, $hasComment = null, $isRootO
142141
143142 if (!preg_match ($ this ->needsEscape , $ string )) {
144143 return '" ' . $ string . '" ' ;
145- } elseif (
146- !preg_match ($ this ->needsEscapeML , $ string ) &&
147- !preg_match ($ this ->onlyWhitespace , $ string ) &&
148- !$ isRootObject
149- ) {
144+ } elseif (!preg_match ($ this ->needsEscapeML , $ string ) && !$ isRootObject ) {
150145 return $ this ->mlString ($ string , $ gap );
151146 } else {
152147 return '" ' . $ this ->quoteReplace ($ string ) . '" ' ;
0 commit comments