Skip to content

Commit

Permalink
Use exported escaping function
Browse files Browse the repository at this point in the history
Fixes #244
  • Loading branch information
mjackson committed Aug 31, 2012
1 parent 52c7e43 commit a6420e4
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions mustache.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ var Mustache;
return Object.prototype.toString.call(obj) === "[object Array]";
};

// OSWASP Guidelines: escape all non alphanumeric characters in ASCII space.
// OSWASP Guidelines: Escape all non alphanumeric characters in ASCII space.
var jsCharsRe = /[\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\xFF\u2028\u2029]/gm;

function quote(text) {
Expand Down Expand Up @@ -94,12 +94,9 @@ var Mustache;
});
}

// Export these utility functions.
exports.isWhitespace = isWhitespace;
exports.isArray = isArray;
exports.quote = quote;
exports.escapeRe = escapeRe;
exports.escapeHtml = escapeHtml;
// Export the escaping function so that the user may override it.
// See https://github.com/janl/mustache.js/issues/244
exports.escape = escapeHtml;

function Scanner(string) {
this.string = string;
Expand Down Expand Up @@ -319,7 +316,7 @@ var Mustache;
var string = (value == null) ? "" : String(value);

if (escape) {
return escapeHtml(string);
return exports.escape(string);
}

return string;
Expand Down

0 comments on commit a6420e4

Please sign in to comment.