From 0b33e7d1b7b71a1a2c878305415477f5d77a7a85 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 19 Jan 2012 22:36:14 -0500 Subject: [PATCH] Replace various space characters in filenames that break on Windows These are all valid Unicode characters, but PDF plugins can't files with filenames containing them on Windows. --- chrome/content/zotero/xpcom/file.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/chrome/content/zotero/xpcom/file.js b/chrome/content/zotero/xpcom/file.js index a42e7e93d..03bcb325d 100644 --- a/chrome/content/zotero/xpcom/file.js +++ b/chrome/content/zotero/xpcom/file.js @@ -227,6 +227,10 @@ Zotero.File = new function(){ fileName = fileName.replace(/[\/\\\?%\*:|"<>]/g, ''); // Replace newlines and tabs (which shouldn't be in the string in the first place) with spaces fileName = fileName.replace(/[\n\t]/g, ' '); + // Replace various thin spaces + fileName = fileName.replace(/[\u2000-\u200A]/g, ' '); + // Replace zero-width spaces + fileName = fileName.replace(/[\u200B-\u200E]/g, ''); if (!skipXML) { // Strip characters not valid in XML, since they won't sync and they're probably unwanted fileName = fileName.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\ud800-\udfff\ufffe\uffff]/g, '');