Make sure to escape parameter values since they are pass as XML attributes
This commit is contained in:
@@ -51,9 +51,9 @@ public class CalabashHelper {
|
||||
|
||||
strBuff
|
||||
.append("<c:param name=\"")
|
||||
.append(entry.getKey())
|
||||
.append(escapeXmlAttribute(entry.getKey()))
|
||||
.append("\" namespace=\"\" value=\"")
|
||||
.append(rawValue)
|
||||
.append(escapeXmlAttribute(rawValue))
|
||||
.append("\"/>");
|
||||
}
|
||||
}
|
||||
@@ -74,6 +74,18 @@ public class CalabashHelper {
|
||||
return sources.get(0);
|
||||
}
|
||||
|
||||
private static String escapeXmlAttribute(String value) {
|
||||
if (value == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return value
|
||||
.replace("&", "&")
|
||||
.replace("\"", """)
|
||||
.replace("'", "'")
|
||||
.replace("%", "%");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link Source} for use in a Calabash pipeline.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user