cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [1/2] git commit: CB-7377 Whitelist. Windows build error due to 'invalid URI rules in config.xml'
Date Tue, 26 Aug 2014 23:44:37 GMT
Repository: cordova-windows
Updated Branches:
  refs/heads/master 9ccd84e02 -> ea8315431


CB-7377 Whitelist. Windows build error due to 'invalid URI rules in config.xml'


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

Branch: refs/heads/master
Commit: 68f01153bd26a04eaa94ab505d70cc80d2fa52df
Parents: 352e526
Author: sgrebnov <v-segreb@microsoft.com>
Authored: Tue Aug 26 13:02:29 2014 +0400
Committer: sgrebnov <v-segreb@microsoft.com>
Committed: Tue Aug 26 13:02:29 2014 +0400

----------------------------------------------------------------------
 .../cordova/lib/ApplyPlatformConfig.ps1         | 36 ++++++++++++++++----
 1 file changed, 29 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-windows/blob/68f01153/windows/template/cordova/lib/ApplyPlatformConfig.ps1
----------------------------------------------------------------------
diff --git a/windows/template/cordova/lib/ApplyPlatformConfig.ps1 b/windows/template/cordova/lib/ApplyPlatformConfig.ps1
index 9e65a71..f4d4723 100644
--- a/windows/template/cordova/lib/ApplyPlatformConfig.ps1
+++ b/windows/template/cordova/lib/ApplyPlatformConfig.ps1
@@ -26,8 +26,6 @@ Write-Host "Applying Platform Config..."
 
 Function UpdateManifest ($manifestFile)
 {
-  $configFile = "$platformRoot\config.xml"
-  [xml]$config = Get-Content $configFile -Encoding UTF8
   [xml]$manifest = Get-Content $manifestFile -Encoding UTF8
 
   # Replace app start page with config.xml setting.
@@ -95,22 +93,20 @@ Function UpdateManifest ($manifestFile)
   }
 
   # Add domain whitelist rules
-  $acls = [string[]]$config.widget.access.origin
   $rules = $manifest.Package.Applications.Application.ApplicationContentUriRules
 
   # Remove existing rules from manifest
   if ($rules) {
-    $manifest.Package.Applications.Application.RemoveChild($rules)
+    $manifest.Package.Applications.Application.RemoveChild($rules) | Out-Null
   }
-
   if ($acls -and ($acls -notcontains "*")) {
     $rules = $manifest.CreateElement("ApplicationContentUriRules", $manifest.DocumentElement.NamespaceURI)
-    $manifest.Package.Applications.Application.AppendChild($rules)
+    $manifest.Package.Applications.Application.AppendChild($rules) | Out-Null
     $acls | foreach {
       $elem = $manifest.CreateElement("Rule", $manifest.DocumentElement.NamespaceURI)
       $elem.SetAttribute("Match", $_)
       $elem.SetAttribute("Type", "include")
-      $rules.AppendChild($elem)
+      $rules.AppendChild($elem) | Out-Null
     }
   }
 
@@ -204,6 +200,26 @@ Function CopyImage($src, $dest)
   Copy-Item $resolvedPath -Destination (join-path $platformRoot $dest)
 }
 
+Function Get-Access-Rules () 
+{
+  $aclsAll = ([string[]]$config.widget.access.origin)
+  if ($aclsAll -eq $null) {
+    return @();
+  }
+
+  $acls = @()
+ 
+  $aclsAll | foreach {
+      $_
+      if ($_.StartsWith("https://","CurrentCultureIgnoreCase") -or ($_ -eq "*")) {
+        $acls += $_
+      } else {
+        Write-Host "Access rules must begin with 'https://', the following rule is ignored:
$_"
+      }
+    }
+  return $acls
+}
+
 Function UpdateAssets ()
 {
   $configFile = "$platformRoot\config.xml"
@@ -276,6 +292,12 @@ Function UpdateAssets ()
 
 }
 
+$configFile = "$platformRoot\config.xml"
+[xml]$config = Get-Content $configFile -Encoding UTF8
+
+# Domain whitelist rules defined in configuration file
+$acls = Get-Access-Rules $config
+
 UpdateManifest "$platformRoot\package.windows.appxmanifest"
 UpdateManifest "$platformRoot\package.windows80.appxmanifest"
 UpdateManifest "$platformRoot\package.phone.appxmanifest"


Mime
View raw message