Remove "%" from list of unencoded entities

@aurimasv's patch from https://github.com/zotero/zotero/pull/304#issuecomment-16562271
This commit is contained in:
Simon Kornblith 2013-04-18 15:43:07 -04:00
parent dbd36a935f
commit 4486ba4495
2 changed files with 2 additions and 7 deletions

View file

@ -51,12 +51,7 @@ Zotero.Attachments = new function(){
Zotero.debug('Importing attachment from file');
// Try decoding URI entities, since we're going to strip '%'
var newName = file.leafName;
try {
newName = decodeURIComponent(file.leafName);
}
catch (e) {}
newName = Zotero.File.getValidFileName(newName);
var newName = Zotero.File.getValidFileName(file.leafName);
if (!file.isFile()) {
throw ("'" + file.leafName + "' must be a file in Zotero.Attachments.importFromFile()");

View file

@ -360,7 +360,7 @@ Zotero.File = new function(){
function getValidFileName(fileName, skipXML) {
// TODO: use space instead, and figure out what's doing extra
// URL encode when saving attachments that trigger this
fileName = fileName.replace(/[\/\\\?%\*:|"<>]/g, '');
fileName = fileName.replace(/[\/\\\?\*:|"<>]/g, '');
// Replace newlines and tabs (which shouldn't be in the string in the first place) with spaces
fileName = fileName.replace(/[\r\n\t]+/g, ' ');
// Replace various thin spaces