Skip to content

Commit

Permalink
HTML escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster committed Nov 12, 2024
1 parent c485c8a commit 28ac5b5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions grunt/helpers/Translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,13 @@ class Translate {
${Object.entries(outputGroupedByFile).map(([fileName, entries]) => {
return ` <file id="${fileName}">
${entries.map(item => {
if (/[<>]+/.test(item.value)) return null;
const value = /[<>&"'/]/.test(item.value)
? `<![CDATA[${item.value}]]>`
: item.value;
return ` <unit id="${item.id}${item.path}">
<segment>
<source xml:space="preserve">${item.value}</source>
<target xml:space="preserve">${item.value}</target>
<source xml:space="preserve">${value}</source>
<target xml:space="preserve">${value}</target>
</segment>
</unit>
`;
Expand Down

0 comments on commit 28ac5b5

Please sign in to comment.