cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmo...@apache.org
Subject git commit: CB-6823 Improve test for is source path ancestor when using copy-from or link-to
Date Fri, 30 May 2014 18:03:57 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master 9b97c5435 -> fcbc1a34c


CB-6823 Improve test for is source path ancestor when using copy-from or link-to


Project: http://git-wip-us.apache.org/repos/asf/cordova-lib/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-lib/commit/fcbc1a34
Tree: http://git-wip-us.apache.org/repos/asf/cordova-lib/tree/fcbc1a34
Diff: http://git-wip-us.apache.org/repos/asf/cordova-lib/diff/fcbc1a34

Branch: refs/heads/master
Commit: fcbc1a34cd404bfd3007707ab24bc27c94194961
Parents: 9b97c54
Author: Michal Mocny <mmocny@gmail.com>
Authored: Fri May 30 14:02:49 2014 -0400
Committer: Michal Mocny <mmocny@gmail.com>
Committed: Fri May 30 14:03:17 2014 -0400

----------------------------------------------------------------------
 cordova-lib/src/cordova/create.js | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/fcbc1a34/cordova-lib/src/cordova/create.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/create.js b/cordova-lib/src/cordova/create.js
index b846c20..49e9ed2 100644
--- a/cordova-lib/src/cordova/create.js
+++ b/cordova-lib/src/cordova/create.js
@@ -98,7 +98,12 @@ function create(dir, id, name, cfg) {
         var www_version = config_json.lib.www.version || 'not_versioned';
         var www_id = config_json.lib.www.id || 'dummy_id';
         symlink  = !!config_json.lib.www.link;
-        if ( www_dir.indexOf(path.resolve(config_json.lib.www.uri)) === 0 ) {
+
+        // Make sure that the source www/ is not a direct ancestor of the target www/, or
else we will recursively copy forever.
+        // To do this, we make sure that the shortest relative path from source-to-target
must start by going up at least one directory.
+        var relative_path_from_source_to_target = path.relative(config_json.lib.www.uri,
www_dir);
+        var does_relative_path_go_up_at_least_one_dir = relative_path_from_source_to_target.split(path.sep)[0]
== '..';
+        if (!does_relative_path_go_up_at_least_one_dir) {
             throw new CordovaError(
                 'Project must not be created inside the www assets dir.' +
                 '\n    project dir:\t' + dir +


Mime
View raw message