File tree 1 file changed +14
-1
lines changed
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ public function addLocaleStrings($language, $strings = [])
237
237
}
238
238
$ dictionary = "" ;
239
239
foreach ($ strings as $ key => $ value ) {
240
- $ dictionary .= '" ' . $ key .'" = " ' . $ value .'"; ' . PHP_EOL ;
240
+ $ dictionary .= '" ' . $ this -> escapeLocaleString ( $ key) .'" = " ' . $ this -> escapeLocaleString ( $ value) .'"; ' . PHP_EOL ;
241
241
}
242
242
$ this ->locales [$ language ] = $ dictionary ;
243
243
@@ -665,4 +665,17 @@ protected function clean()
665
665
666
666
return true ;
667
667
}
668
+
669
+ protected static $ escapeChars = [
670
+ "\n" => "\\n " ,
671
+ "\r" => "\\r " ,
672
+ "\"" => "\\\"" ,
673
+ "\\" => "\\\\"
674
+ ];
675
+ /**
676
+ * Escapes strings for use in locale files
677
+ */
678
+ protected function escapeLocaleString ($ string ) {
679
+ return strtr ($ string , self ::$ escapeChars );
680
+ }
668
681
}
You can’t perform that action at this time.
0 commit comments