-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Validate MusicXML in parseMusicXML() and update demo to better reject…
… invalid files
- Loading branch information
1 parent
81380da
commit bd3c0d0
Showing
7 changed files
with
152 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/*! | ||
* musicxml-player v0.14.0 | ||
* musicxml-player v0.15.0 | ||
* (c) Karim Ratib <[email protected]> (https://github.com/infojunkie) | ||
* Released under the GPL-3.0-only License. | ||
*/ | ||
|
@@ -5844,8 +5844,9 @@ function _parseCompressedMusicXML(mxml, queries) { | |
text: decoder.decode(containerBuf), | ||
}); | ||
const rootFile = SaxonJS2_rtExports.XPath.evaluate('//rootfile[1]/@full-path', doc); | ||
if (!rootFile) | ||
throw new Error('Invalid compressed MusicXML file does not contain rootfile/@full-path.'); | ||
if (!rootFile) { | ||
throw new Error('[parseMusicXML] Invalid compressed MusicXML file does not contain rootfile/@full-path.'); | ||
} | ||
// Parse root document as MusicXML. | ||
const rootBuf = yield entries[rootFile.value].arrayBuffer(); | ||
return _parseUncompressedMusicXML(decoder.decode(rootBuf), queries); | ||
|
@@ -5859,7 +5860,11 @@ function _parseUncompressedMusicXML(musicXml, queries) { | |
encoding: 'utf8', | ||
text: musicXml, | ||
}); | ||
const version = (_a = SaxonJS2_rtExports.XPath.evaluate('//score-partwise/@version', doc)) !== null && _a !== void 0 ? _a : { | ||
const valid = SaxonJS2_rtExports.XPath.evaluate('boolean(//score-partwise | //score-timewise)', doc); | ||
if (!valid) { | ||
throw new Error('[parseMusicXML] Invalid MusicXML file contains neither score-partwise nor score-timewise.'); | ||
} | ||
const version = (_a = SaxonJS2_rtExports.XPath.evaluate('//score-partwise/@version | //score-timewise/@version', doc)) !== null && _a !== void 0 ? _a : { | ||
value: '(unknown)', | ||
}; | ||
console.debug(`[parseMusicXML] MusicXML version ${version.value}`); | ||
|
@@ -13795,7 +13800,7 @@ class WebAudioFontOutput { | |
} | ||
|
||
var name = "musicxml-player"; | ||
var version = "0.14.0"; | ||
var version = "0.15.0"; | ||
var description = "A simple JavaScript component that loads and plays MusicXML files in the browser using Web Audio and Web MIDI."; | ||
var main = "dist/musicxml-player.esm.js"; | ||
var type = "module"; | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.