@@ -49,24 +49,34 @@ public static function toString(Translations $translations)
4949 $ lines [] = 'msgctxt ' .self ::quote ($ translation ->getContext ());
5050 }
5151
52- self ::addLines ($ lines , 'msgid ' , $ translation ->getOriginal ());
53-
52+ self ::addLines ($ lines , 'msgid ' , self ::removeEOT ($ translation ->getOriginal ()));
5453 if ($ translation ->hasPlural ()) {
55- self ::addLines ($ lines , 'msgid_plural ' , $ translation ->getPlural ());
56- self ::addLines ($ lines , 'msgstr[0] ' , $ translation ->getTranslation ());
57-
54+ self ::addLines ($ lines , 'msgid_plural ' , self :: removeEOT ( $ translation ->getPlural () ));
55+ self ::addLines ($ lines , 'msgstr[0] ' , self :: removeEOT ( $ translation ->getTranslation () ));
56+
5857 foreach ($ translation ->getPluralTranslation () as $ k => $ v ) {
5958 self ::addLines ($ lines , 'msgstr[ ' .($ k + 1 ).'] ' , $ v );
6059 }
6160 } else {
62- self ::addLines ($ lines , 'msgstr ' , $ translation ->getTranslation ());
61+ self ::addLines ($ lines , 'msgstr ' , self :: removeEOT ( $ translation ->getTranslation () ));
6362 }
6463
6564 $ lines [] = '' ;
6665 }
6766
6867 return implode ("\n" , $ lines );
6968 }
69+
70+ /**
71+ * Escape Control Characters like EOT from strings
72+ *
73+ * @param string $text
74+ *
75+ * @return string
76+ */
77+ private static function removeEOT ($ text ){
78+ return preg_replace ('/[\x00-\x09\x0B\x0C\x0E-\x1F\x7F]/ ' , '' , $ text );
79+ }
7080
7181 /**
7282 * Escapes and adds double quotes to a string
0 commit comments