cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shaz...@apache.org
Subject cordova-lib git commit: CB-10057 - removing <access> tag does not remove ATS entry
Date Sat, 21 Nov 2015 09:43:36 GMT
Repository: cordova-lib
Updated Branches:
  refs/heads/master fc74c6397 -> ba30bfda5


CB-10057 - removing <access> tag does not remove ATS entry


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

Branch: refs/heads/master
Commit: ba30bfda5860f672f5e2901e9d15c7daab566b71
Parents: fc74c63
Author: Shazron Abdullah <shazron@apache.org>
Authored: Sat Nov 21 01:43:29 2015 -0800
Committer: Shazron Abdullah <shazron@apache.org>
Committed: Sat Nov 21 01:43:29 2015 -0800

----------------------------------------------------------------------
 cordova-lib/src/cordova/metadata/ios_parser.js | 27 ++++++++++++---------
 1 file changed, 15 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-lib/blob/ba30bfda/cordova-lib/src/cordova/metadata/ios_parser.js
----------------------------------------------------------------------
diff --git a/cordova-lib/src/cordova/metadata/ios_parser.js b/cordova-lib/src/cordova/metadata/ios_parser.js
index 7ea8dcf..21baed5 100644
--- a/cordova-lib/src/cordova/metadata/ios_parser.js
+++ b/cordova-lib/src/cordova/metadata/ios_parser.js
@@ -110,10 +110,12 @@ ios_parser.prototype.update_from_config = function(config) {
         delete infoPlist['UIInterfaceOrientation'];
     }
     
-    var ats = (infoPlist['NSAppTransportSecurity'] || {});
-    ats = writeATSEntries(config, ats);
+    // replace Info.plist ATS entries according to <access> and <allow-navigation>
config.xml entries 
+    var ats = writeATSEntries(config);
     if (Object.keys(ats).length > 0) {
         infoPlist['NSAppTransportSecurity'] = ats;
+    } else {
+        delete infoPlist['NSAppTransportSecurity'];
     }
 
     var info_contents = plist.build(infoPlist);
@@ -387,7 +389,7 @@ function parseWhitelistUrlForATS(url, minimum_tls_version, requires_forward_secr
     if (url === '*') {
         return {
             Hostname : '*'
-        }
+        };
     }
     
     // Guiding principle: we only set values in retObj if they are NOT the default
@@ -436,30 +438,31 @@ function parseWhitelistUrlForATS(url, minimum_tls_version, requires_forward_secr
     App Transport Security (ATS) writer from <access> and <allow-navigation>
tags
     in config.xml
 */
-function writeATSEntries(config, ats0) {
+function writeATSEntries(config) {
   var pObj = processAccessAndAllowNavigationEntries(config);
   
-    var ats = JSON.parse(JSON.stringify(ats0)); // (shallow) copy, to prevent side effects,
+testable
+    var ats = {};
 
-    if (!ats['NSExceptionDomains']) {
-        ats['NSExceptionDomains'] = {};
-    }
-    
     for(var hostname in pObj) {
         if (pObj.hasOwnProperty(hostname)) {
-              var entry = pObj[hostname];
-              var exceptionDomain = ats['NSExceptionDomains'][hostname] || {}; // get existing,
if any
               if (hostname === '*') {
                   ats['NSAllowsArbitraryLoads'] = true;
                   continue;              
               }
               
+              var entry = pObj[hostname];
+              var exceptionDomain = {};
+              
               for(var key in entry) {
                   if (entry.hasOwnProperty(key) && key !== 'Hostname') {
                       exceptionDomain[key] = entry[key];
                   }
               }
-              // assign the domain to ats
+
+              if (!ats['NSExceptionDomains']) {
+                  ats['NSExceptionDomains'] = {};
+              }
+
               ats['NSExceptionDomains'][hostname] = exceptionDomain;
         }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message