mirror of
https://github.com/captbaritone/webamp.git
synced 2026-07-19 01:23:49 +00:00
Improve defence against corrupt skins
This commit is contained in:
parent
e1e4d986e4
commit
535991b4b4
2 changed files with 23 additions and 13 deletions
|
|
@ -35,9 +35,13 @@ class Shooter {
|
|||
|
||||
_validateZip(u) {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(u, (err, buffer) => {
|
||||
JSZip.loadAsync(buffer).then(resolve, reject);
|
||||
});
|
||||
try {
|
||||
fs.readFile(u, (err, buffer) => {
|
||||
JSZip.loadAsync(buffer).then(resolve, reject);
|
||||
});
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -82,16 +82,22 @@ export function loadFilesFromReferences(
|
|||
export function setSkinFromArrayBuffer(arrayBuffer) {
|
||||
return async dispatch => {
|
||||
dispatch({ type: LOADING });
|
||||
const skinData = await skinParser(arrayBuffer);
|
||||
dispatch({
|
||||
type: SET_SKIN_DATA,
|
||||
skinImages: skinData.images,
|
||||
skinColors: skinData.colors,
|
||||
skinPlaylistStyle: skinData.playlistStyle,
|
||||
skinCursors: skinData.cursors,
|
||||
skinRegion: skinData.region,
|
||||
skinGenLetterWidths: skinData.genLetterWidths
|
||||
});
|
||||
try {
|
||||
const skinData = await skinParser(arrayBuffer);
|
||||
dispatch({
|
||||
type: SET_SKIN_DATA,
|
||||
skinImages: skinData.images,
|
||||
skinColors: skinData.colors,
|
||||
skinPlaylistStyle: skinData.playlistStyle,
|
||||
skinCursors: skinData.cursors,
|
||||
skinRegion: skinData.region,
|
||||
skinGenLetterWidths: skinData.genLetterWidths
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
dispatch({ type: LOADED });
|
||||
alert(`Failed to parse skin`);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue