Permalink
Browse files

Merge remote-tracking branch 'ErisDS/escape-type'

  • Loading branch information...
2 parents c375a38 + 24fb800 commit 0de73e918348411f39ab7236639e05b6a79b6746 @jbt committed May 10, 2014
Showing with 15 additions and 0 deletions.
  1. +15 −0 src/docker.js
View
15 src/docker.js
@@ -629,6 +629,15 @@ Docker.prototype.parseMultiline = function(comment){
// to remove the type from it.
function grabType(bits){
var type = bits.shift();
+ var badChars = /[&<>"'`]/g;
+ var escape = {
+ "&": "&amp;",
+ "<": "&lt;",
+ ">": "&gt;",
+ '"': "&quot;",
+ "'": "&#x27;",
+ "`": "&#x60;"
+ };
// Carry on adding bits until we reach a closing brace
while(bits.length && type.indexOf('}') === -1) type += bits.shift();
@@ -641,6 +650,12 @@ Docker.prototype.parseMultiline = function(comment){
type = type.replace(/\}.*$/,'}');
}
+ function escapeChar(chr) {
+ return escape[chr] || "&amp;";
+ }
+
+ type = type.replace(badChars, escapeChar);
+
return type.replace(/[{}]/g,'');
}

0 comments on commit 0de73e9

Please sign in to comment.