From a2c26b8c744c8417db590604b37331ccf2ba8eb8 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 16 Jul 2015 03:48:35 -0700 Subject: [PATCH] Fix hanlding trailing slash in asar package, close #2222 --- atom/common/asar/archive.cc | 5 +++++ spec/asar-spec.coffee | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/atom/common/asar/archive.cc b/atom/common/asar/archive.cc index 79b82416..be99530c 100644 --- a/atom/common/asar/archive.cc +++ b/atom/common/asar/archive.cc @@ -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); diff --git a/spec/asar-spec.coffee b/spec/asar-spec.coffee index 977676a1..a4941725 100644 --- a/spec/asar-spec.coffee +++ b/spec/asar-spec.coffee @@ -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) -> -- 2.43.0