Skip to content

Commit

Permalink
[FIX] xml: escape chars in regex
Browse files Browse the repository at this point in the history
There's an issue in odoo when extracing translatable source terms
from the bundled library file `o_spreadsheet.js`. Some terms are not
extracted.

Babel doesn't correctly tokenize the regex /"/
As a result, all following tokens are fucked up and source terms are no longer
exported after this point.

It seems to be known that babel js lexer isn't perfect.
python-babel/babel#467
python-babel/babel#616
python-babel/babel#640
python-babel/babel#791

X-original-commit: d711ad2
  • Loading branch information
LucasLefevre committed Jun 24, 2022
1 parent dbdd763 commit 33fab6d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/xlsx/helpers/xml_helpers.ts
Expand Up @@ -26,11 +26,11 @@ export function createXMLFile(

function xmlEscape(str: XMLAttributeValue): string {
return String(str)
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&apos;");
.replace(/\&/g, "&amp;")
.replace(/\</g, "&lt;")
.replace(/\>/g, "&gt;")
.replace(/\"/g, "&quot;")
.replace(/\'/g, "&apos;");
}

export function formatAttributes(attrs: XMLAttributes): XMLString {
Expand Down

0 comments on commit 33fab6d

Please sign in to comment.