@@ -58,7 +58,7 @@ async function translate(language: string, filePath: string) {
58
58
59
59
parser . on ( "text" , text => {
60
60
if ( isRecording ) {
61
- currentSegment += ` ${ text } ` ;
61
+ currentSegment += strongEscapeXML ( text ) ;
62
62
} else {
63
63
segments . push ( [ false , text ] ) ;
64
64
}
@@ -140,7 +140,7 @@ async function translate(language: string, filePath: string) {
140
140
141
141
clean . on ( "text" , text => {
142
142
if ( currDepth >= 1 ) {
143
- translated += escapeXML ( text ) ;
143
+ translated += strongEscapeXML ( text ) ;
144
144
}
145
145
} ) ;
146
146
@@ -209,7 +209,7 @@ async function translate(language: string, filePath: string) {
209
209
const text = messageContent . text ;
210
210
// console.log(text.value);
211
211
212
- const safeText = escapeXML ( text . value ) ;
212
+ const safeText : String = escapeXML ( text . value ) ;
213
213
const textStream = Readable . from ( "<WRAPPER>" + safeText + "</WRAPPER>" ) ;
214
214
215
215
await new Promise < void > ( ( resolve , reject ) => {
@@ -238,3 +238,14 @@ function formatAttributes(attrs) {
238
238
function escapeXML ( str : string ) : string {
239
239
return str . replace ( / & (? ! (?: a m p ; | l t ; | g t ; | a p o s ; | q u o t ; ) ) / g, "&" ) ;
240
240
}
241
+
242
+
243
+
244
+ function strongEscapeXML ( str : string ) : string {
245
+ return str
246
+ . replace ( / & (? ! (?: a m p ; | l t ; | g t ; | a p o s ; | q u o t ; ) ) / g, "&" )
247
+ . replace ( / < / g, "<" )
248
+ . replace ( / > / g, ">" )
249
+ . replace ( / " / g, """ )
250
+ . replace ( / ' / g, "'" ) ;
251
+ }
0 commit comments