From 1053ac3441fabf260ad50e61b2ea1e76cea7aed7 Mon Sep 17 00:00:00 2001 From: anekos Date: Sat, 28 Nov 2009 07:12:24 +0000 Subject: 不正なファイル名になったりするのを修正 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@36022 d0d07461-0603-4401-acd4-de1884942a52 --- zip-de-download.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'zip-de-download.js') diff --git a/zip-de-download.js b/zip-de-download.js index a4a1cb3..8e642d3 100644 --- a/zip-de-download.js +++ b/zip-de-download.js @@ -1,5 +1,5 @@ let INFO = - @@ -151,6 +151,10 @@ __proto__ = (function(){ liberator.modules.services.get("directory").get("Home", Ci.nsIFile).path; return getFile(path); } + function fixFilename(filename){ + const badChars = /[\\\/:;\*\?\"\<\>\|\#]/g; + return liberator.has('windows') ? filename.replace(badChars, '_') : filename; + } let self = { downloadZip: function(path, urls, comment, isAppend){ let zipW = new zipWriter(); @@ -221,7 +225,7 @@ __proto__ = (function(){ liberator.assert(info.xpath, "not registered in SITE_IFO"); let urls = this.getURLs(info); - let title = liberator.modules.buffer.title; + let title = fixFilename(liberator.modules.buffer.title); let comment = [title, liberator.modules.buffer.URL].join("\n"); let file; if (!zipPath){ -- cgit v1.2.3