]> khamidou — GitHub mirrors - electron.git/commitdiff
Fix hanlding trailing slash in asar package, close #2222
authorCheng Zhao <zcbenz@gmail.com>
Thu, 16 Jul 2015 10:48:35 +0000 (03:48 -0700)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 16 Jul 2015 10:49:26 +0000 (03:49 -0700)
atom/common/asar/archive.cc
spec/asar-spec.coffee

index 79b82416cd0a8508b1112421734d24932f031ac2..be99530c9c985527cd23ebbbd06e44da371a3728 100644 (file)
@@ -54,6 +54,11 @@ bool GetChildNode(const base::DictionaryValue* root,
                   const std::string& name,
                   const base::DictionaryValue* dir,
                   const base::DictionaryValue** out) {
+  if (name == "") {
+    *out = root;
+    return true;
+  }
+
   const base::DictionaryValue* files = NULL;
   return GetFilesNode(root, dir, &files) &&
          files->GetDictionaryWithoutPathExpansion(name, out);
index 977676a1936a4e27c4188c36aeed1d174dfba7ab..a49417258fecbda07b88d4efda1264937e00caad 100644 (file)
@@ -85,6 +85,11 @@ describe 'asar package', ->
           done()
 
     describe 'fs.lstatSync', ->
+      it 'handles path with trailing slash correctly', ->
+        p = path.join fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1'
+        fs.lstatSync p
+        fs.lstatSync p + '/'
+
       it 'returns information of root', ->
         p = path.join fixtures, 'asar', 'a.asar'
         stats = fs.lstatSync p
@@ -136,6 +141,10 @@ describe 'asar package', ->
           assert.throws throws, /ENOENT/
 
     describe 'fs.lstat', ->
+      it 'handles path with trailing slash correctly', (done) ->
+        p = path.join fixtures, 'asar', 'a.asar', 'link2', 'link2', 'file1'
+        fs.lstat p + '/', done
+
       it 'returns information of root', (done) ->
         p = path.join fixtures, 'asar', 'a.asar'
         stats = fs.lstat p, (err, stats) ->