[Pkg-mozext-commits] [greasemonkey] 07/13: Don't overwrite scripts with dependencies that have the same name.

David Prévot taffit at moszumanska.debian.org
Thu Jul 17 20:10:00 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository greasemonkey.

commit 3487d18dec39af59d85b9f55b2eaf10043890218
Author: Ventero <ventero at ventero.de>
Date:   Thu Apr 3 05:33:43 2014 +0200

    Don't overwrite scripts with dependencies that have the same name.
    
    Fixes #1906.
---
 modules/remoteScript.js | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/modules/remoteScript.js b/modules/remoteScript.js
index bb91c03..2a7f9f8 100644
--- a/modules/remoteScript.js
+++ b/modules/remoteScript.js
@@ -317,10 +317,26 @@ RemoteScript.prototype.install = function(aOldScript, aOnlyDependencies) {
 
   if (aOnlyDependencies) {
     // Just move the dependencies in.
-    var enumerator = this._tempDir.directoryEntries;
-    while (enumerator.hasMoreElements()) {
-      var file = enumerator.getNext().QueryInterface(Ci.nsIFile);
-      file.moveTo(this.script.baseDirFile, null);
+    for (var i = 0, dep = null; dep = this._dependencies[i]; i++) {
+      // Make sure this is actually a file, not a data URI.
+      if (!dep._filename) continue;
+
+      // Grab a unique file name to ensure we don't overwrite the script in case
+      // it has the same name as one of the dependencies. See #1906.
+      var target = GM_util.getTempFile(this.script.baseDirFile, dep.filename);
+
+      var file = this._tempDir.clone();
+      file.append(dep.filename);
+      file.moveTo(this.script.baseDirFile, target.leafName);
+
+      dep.setFilename(target);
+    }
+
+    // Only delete the temporary directory if it's empty.
+    try {
+      this._tempDir.remove(false);
+    } catch (e) {
+      // silently ignore
     }
   } else {
     // Completely install the new script.

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/greasemonkey.git



More information about the Pkg-mozext-commits mailing list