Bug 1403665 - remove " and ? from filenames
This is an export of this commit: https://github.com/mozilla-services/screenshots/pull/3524/commits/42a561d6ad6e160628344d271f9244df5179e8e0
And fixes this Screenshots bug: https://github.com/mozilla-services/screenshots/issues/3517
MozReview-Commit-ID: GPkfNCFGflZ
--- a/browser/extensions/screenshots/webextension/build/shot.js
+++ b/browser/extensions/screenshots/webextension/build/shot.js
@@ -360,17 +360,17 @@ class AbstractShot {
assertOrigin(val);
}
this._origin = val || undefined;
}
get filename() {
let filenameTitle = this.title;
let date = new Date(this.createdDate);
- filenameTitle = filenameTitle.replace(/[:\\<>/!@&*.|\n\r\t]/g, " ");
+ filenameTitle = filenameTitle.replace(/[:\\<>/!@&?"*.|\n\r\t]/g, " ");
filenameTitle = filenameTitle.replace(/\s{1,4000}/g, " ");
let clipFilename = `Screenshot-${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${filenameTitle}`;
const clipFilenameBytesSize = clipFilename.length * 2; // JS STrings are UTF-16
if (clipFilenameBytesSize > 251) { // 255 bytes (Usual filesystems max) - 4 for the ".png" file extension string
const excedingchars = (clipFilenameBytesSize - 246) / 2; // 251 - 5 for ellipsis "[...]"
clipFilename = clipFilename.substring(0, clipFilename.length - excedingchars);
clipFilename = clipFilename + '[...]';
}