Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML Var. substitution - Escape XML characters #6980

Merged
merged 4 commits into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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