mirror of
https://github.com/scratchfoundation/scratchjr.git
synced 2024-11-29 02:25:39 -05:00
Sanitize filename
Allow non-latin characters, but remove anything that could be problematic
This commit is contained in:
parent
9923c34e76
commit
e035b0f86e
1 changed files with 14 additions and 1 deletions
|
@ -436,8 +436,21 @@ export default class IO {
|
||||||
// This could pause if getmedia takes a long time, for example,
|
// This could pause if getmedia takes a long time, for example,
|
||||||
// if we have many large sprites or large sounds
|
// if we have many large sprites or large sounds
|
||||||
|
|
||||||
|
// strip spaces and sanitize filename, including windows reserved names even though
|
||||||
|
// kids are unlikely to name their project lpt1 etc.
|
||||||
|
var illegalRe = /[\/\?<>\\:\*\|":]/g;
|
||||||
|
var controlRe = /[\x00-\x1f\x80-\x9f]/g;
|
||||||
|
var reservedRe = /^\.+$/;
|
||||||
|
var windowsReservedRe = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i;
|
||||||
|
var windowsTrailingRe = /[\. ]+$/;
|
||||||
|
|
||||||
zipFileName = jsonData.name.replace(/\s*/g, '');
|
zipFileName = jsonData.name.replace(/\s*/g, '');
|
||||||
zipFileName = zipFileName.replace(/\W/g, '');
|
zipFileName = zipFileName
|
||||||
|
.replace(illegalRe, '_')
|
||||||
|
.replace(controlRe, '_')
|
||||||
|
.replace(reservedRe, '_')
|
||||||
|
.replace(windowsReservedRe, '_')
|
||||||
|
.replace(windowsTrailingRe, '_');
|
||||||
shareName = jsonData.name;
|
shareName = jsonData.name;
|
||||||
|
|
||||||
function checkStatus () {
|
function checkStatus () {
|
||||||
|
|
Loading…
Reference in a new issue