musicxml-io 0.5.5 → 0.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +8 -3
- package/dist/index.mjs +8 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -223,13 +223,16 @@ function decodeXmlEntities(s) {
|
|
|
223
223
|
(_, named, dec, hex) => named ? _entityMap[named] : dec ? String.fromCharCode(parseInt(dec, 10)) : String.fromCharCode(parseInt(hex, 16))
|
|
224
224
|
);
|
|
225
225
|
}
|
|
226
|
+
var INVALID_XML_CHARS_RE = /[\x00-\x08\x0B\x0C\x0E-\x1F\uFFFE\uFFFF]/g;
|
|
226
227
|
function decodeTree(nodes) {
|
|
227
228
|
for (let i = 0; i < nodes.length; i++) {
|
|
228
229
|
const node = nodes[i];
|
|
229
230
|
if (typeof node === "string") {
|
|
230
|
-
|
|
231
|
-
|
|
231
|
+
let s = node;
|
|
232
|
+
if (s.indexOf("&") !== -1) {
|
|
233
|
+
s = decodeXmlEntities(s);
|
|
232
234
|
}
|
|
235
|
+
nodes[i] = s.replace(INVALID_XML_CHARS_RE, "");
|
|
233
236
|
} else {
|
|
234
237
|
const attrs = node.attributes;
|
|
235
238
|
for (const key in attrs) {
|
|
@@ -257,7 +260,9 @@ function parse(input) {
|
|
|
257
260
|
if (typeof input !== "string") {
|
|
258
261
|
xmlString = decodeXmlBytes(input);
|
|
259
262
|
} else if (input.includes("\0")) {
|
|
260
|
-
|
|
263
|
+
throw new Error(
|
|
264
|
+
"parse() received a string containing NUL bytes, which indicates a UTF-16 encoded MusicXML file was read without proper encoding detection. Pass a Buffer or Uint8Array instead so the encoding is handled automatically:\n parse(fs.readFileSync(path)) // Node.js\n parse(new Uint8Array(arrayBuffer)) // Browser"
|
|
265
|
+
);
|
|
261
266
|
} else {
|
|
262
267
|
xmlString = input;
|
|
263
268
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -223,13 +223,16 @@ function decodeXmlEntities(s) {
|
|
|
223
223
|
(_, named, dec, hex) => named ? _entityMap[named] : dec ? String.fromCharCode(parseInt(dec, 10)) : String.fromCharCode(parseInt(hex, 16))
|
|
224
224
|
);
|
|
225
225
|
}
|
|
226
|
+
var INVALID_XML_CHARS_RE = /[\x00-\x08\x0B\x0C\x0E-\x1F\uFFFE\uFFFF]/g;
|
|
226
227
|
function decodeTree(nodes) {
|
|
227
228
|
for (let i = 0; i < nodes.length; i++) {
|
|
228
229
|
const node = nodes[i];
|
|
229
230
|
if (typeof node === "string") {
|
|
230
|
-
|
|
231
|
-
|
|
231
|
+
let s = node;
|
|
232
|
+
if (s.indexOf("&") !== -1) {
|
|
233
|
+
s = decodeXmlEntities(s);
|
|
232
234
|
}
|
|
235
|
+
nodes[i] = s.replace(INVALID_XML_CHARS_RE, "");
|
|
233
236
|
} else {
|
|
234
237
|
const attrs = node.attributes;
|
|
235
238
|
for (const key in attrs) {
|
|
@@ -257,7 +260,9 @@ function parse(input) {
|
|
|
257
260
|
if (typeof input !== "string") {
|
|
258
261
|
xmlString = decodeXmlBytes(input);
|
|
259
262
|
} else if (input.includes("\0")) {
|
|
260
|
-
|
|
263
|
+
throw new Error(
|
|
264
|
+
"parse() received a string containing NUL bytes, which indicates a UTF-16 encoded MusicXML file was read without proper encoding detection. Pass a Buffer or Uint8Array instead so the encoding is handled automatically:\n parse(fs.readFileSync(path)) // Node.js\n parse(new Uint8Array(arrayBuffer)) // Browser"
|
|
265
|
+
);
|
|
261
266
|
} else {
|
|
262
267
|
xmlString = input;
|
|
263
268
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "musicxml-io",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"description": "Parse and serialize MusicXML (.xml/.mxl) and ABC notation with high round-trip fidelity",
|
|
5
5
|
"author": "tan-z-tan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"abc-notation"
|
|
71
71
|
],
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@types/node": "^
|
|
73
|
+
"@types/node": "^25.6.0",
|
|
74
74
|
"@typescript-eslint/eslint-plugin": "^8.57.2",
|
|
75
75
|
"@typescript-eslint/parser": "^8.57.2",
|
|
76
76
|
"eslint": "^10.1.0",
|