Skip to content

Commit

Permalink
XML Var. substitution - Escape XML characters (#6980)
Browse files Browse the repository at this point in the history
* xml poc

* patch task versions

* addressed review comments
  • Loading branch information
vincent1173 authored Apr 20, 2018
1 parent b740df3 commit 7bee928
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Tasks/AzureRmWebAppDeployment/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 4,
"Minor": 1,
"Patch": 0
"Patch": 1
},
"releaseNotes": "What's new in version 4.* (preview)<br />Supports Kudu Zip Deploy<br />Supports App Service Environments<br />Improved UI for discovering different App service types supported by the task<br/>Click [here](https://aka.ms/azurermwebdeployreadme) for more Information.",
"minimumAgentVersion": "2.104.1",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureRmWebAppDeployment/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 4,
"Minor": 1,
"Patch": 0
"Patch": 1
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"minimumAgentVersion": "2.104.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="rmappname" value="true"/>
<add key="log_level" value="" />
<add key="Content-Security-Policy" value="default-src 'self' 'unsafe-inline' 'unsafe-eval';" />
</appSettings>
<applicationSettings>
<myCustomSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="rmappname" value="true"/>
<add key="log_level" value="error,warning" />
<add key="Content-Security-Policy" value="default-src 'self' 'unsafe-inline' 'unsafe-eval';" />
</appSettings>
<applicationSettings>
<myCustomSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ export function substituteXmlVariables(configFile, tags, variableMap, parameterF
tl.debug(error);
return;
}
var replacableTokenValues = {};
var replacableTokenValues = {
"APOS_CHARACTER_TOKEN": "'"
};
var isSubstitutionApplied: boolean = false;
for(var tag of tags) {
var nodes = ltxDomUtiltiyInstance.getElementsByTagName(tag);
Expand Down Expand Up @@ -146,6 +148,7 @@ export function substituteXmlVariables(configFile, tags, variableMap, parameterF
}

if(isSubstitutionApplied) {
replaceEscapeXMLCharacters(xmlDocument);
var domContent = ( fileEncodeType[1]? '\uFEFF' : '' ) + ltxDomUtiltiyInstance.getContentWithHeader(xmlDocument);
for(var replacableTokenValue in replacableTokenValues) {
tl.debug('Substituting original value in place of temp_name: ' + replacableTokenValue);
Expand Down Expand Up @@ -262,4 +265,18 @@ function updateXmlConnectionStringsNodeAttribute(xmlDomNode, variableMap, replac
}

return isSubstitutionApplied;
}

function replaceEscapeXMLCharacters(xmlDOMNode) {
if(!xmlDOMNode || typeof xmlDOMNode == 'string') {
return;
}

for(var xmlAttribute in xmlDOMNode.attrs) {
xmlDOMNode.attrs[xmlAttribute] = xmlDOMNode.attrs[xmlAttribute].replace(/'/g, "APOS_CHARACTER_TOKEN");
}

for(var xmlChild of xmlDOMNode.children) {
replaceEscapeXMLCharacters(xmlChild);
}
}
2 changes: 1 addition & 1 deletion Tasks/IISWebAppDeploymentOnMachineGroup/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 37
"Patch": 38
},
"demands": [],
"minimumAgentVersion": "2.104.1",
Expand Down
2 changes: 1 addition & 1 deletion Tasks/IISWebAppDeploymentOnMachineGroup/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 0,
"Minor": 0,
"Patch": 37
"Patch": 38
},
"demands": [],
"minimumAgentVersion": "2.104.1",
Expand Down

0 comments on commit 7bee928

Please sign in to comment.