dist/ember.js in ember-source-1.0.0.rc5 vs dist/ember.js in ember-source-1.0.0.rc5.1

- old
+ new

@@ -1,7 +1,7 @@ -// Version: v1.0.0-rc.5-3-g835b8e5 -// Last commit: 835b8e5 (2013-06-01 14:23:38 -0400) +// Version: v1.0.0-rc.5-2-g9dc4ad8 +// Last commit: 9dc4ad8 (2013-07-25 20:19:21 -0400) (function() { /*global __fail__*/ @@ -149,12 +149,12 @@ }; }; })(); -// Version: v1.0.0-rc.5-3-g835b8e5 -// Last commit: 835b8e5 (2013-06-01 14:23:38 -0400) +// Version: v1.0.0-rc.5-2-g9dc4ad8 +// Last commit: 9dc4ad8 (2013-07-25 20:19:21 -0400) (function() { var define, requireModule; @@ -14112,10 +14112,49 @@ toDOM: function() { return this.list.join(" "); } }; +var BAD_TAG_NAME_TEST_REGEXP = /[^a-zA-Z\-]/; +var BAD_TAG_NAME_REPLACE_REGEXP = /[^a-zA-Z\-]/g; + +function stripTagName(tagName) { + if (!tagName) { + return tagName; + } + + if (!BAD_TAG_NAME_TEST_REGEXP.test(tagName)) { + return tagName; + } + + return tagName.replace(BAD_TAG_NAME_REPLACE_REGEXP, ''); +} + +var BAD_CHARS_REGEXP = /&(?!\w+;)|[<>"'`]/g; +var POSSIBLE_CHARS_REGEXP = /[&<>"'`]/; + +function escapeAttribute(value) { + // Stolen shamelessly from Handlebars + + var escape = { + "<": "&lt;", + ">": "&gt;", + '"': "&quot;", + "'": "&#x27;", + "`": "&#x60;" + }; + + var escapeChar = function(chr) { + return escape[chr] || "&amp;"; + }; + + var string = value.toString(); + + if(!POSSIBLE_CHARS_REGEXP.test(string)) { return string; } + return string.replace(BAD_CHARS_REGEXP, escapeChar); +} + /** `Ember.RenderBuffer` gathers information regarding the a view and generates the final representation. `Ember.RenderBuffer` will generate HTML which can be pushed to the DOM. @@ -14399,27 +14438,27 @@ attrs = this.elementAttributes, props = this.elementProperties, style = this.elementStyle, attr, prop; - buffer += '<' + tagName; + buffer += '<' + stripTagName(tagName); if (id) { - buffer += ' id="' + this._escapeAttribute(id) + '"'; + buffer += ' id="' + escapeAttribute(id) + '"'; this.elementId = null; } if (classes) { - buffer += ' class="' + this._escapeAttribute(classes.join(' ')) + '"'; + buffer += ' class="' + escapeAttribute(classes.join(' ')) + '"'; this.classes = null; } if (style) { buffer += ' style="'; for (prop in style) { if (style.hasOwnProperty(prop)) { - buffer += prop + ':' + this._escapeAttribute(style[prop]) + ';'; + buffer += prop + ':' + escapeAttribute(style[prop]) + ';'; } } buffer += '"'; @@ -14427,11 +14466,11 @@ } if (attrs) { for (attr in attrs) { if (attrs.hasOwnProperty(attr)) { - buffer += ' ' + attr + '="' + this._escapeAttribute(attrs[attr]) + '"'; + buffer += ' ' + attr + '="' + escapeAttribute(attrs[attr]) + '"'; } } this.elementAttributes = null; } @@ -14442,11 +14481,11 @@ var value = props[prop]; if (value || typeof(value) === 'number') { if (value === true) { buffer += ' ' + prop + '="' + prop + '"'; } else { - buffer += ' ' + prop + '="' + this._escapeAttribute(props[prop]) + '"'; + buffer += ' ' + prop + '="' + escapeAttribute(props[prop]) + '"'; } } } } @@ -14457,11 +14496,11 @@ this.buffer = buffer; }, pushClosingTag: function() { var tagName = this.tagNames.pop(); - if (tagName) { this.buffer += '</' + tagName + '>'; } + if (tagName) { this.buffer += '</' + stripTagName(tagName) + '>'; } }, currentTagName: function() { return this.tagNames[this.tagNames.length-1]; }, @@ -14555,35 +14594,10 @@ } }, innerString: function() { return this.buffer; - }, - - _escapeAttribute: function(value) { - // Stolen shamelessly from Handlebars - - var escape = { - "<": "&lt;", - ">": "&gt;", - '"': "&quot;", - "'": "&#x27;", - "`": "&#x60;" - }; - - var badChars = /&(?!\w+;)|[<>"'`]/g; - var possible = /[&<>"'`]/; - - var escapeChar = function(chr) { - return escape[chr] || "&amp;"; - }; - - var string = value.toString(); - - if(!possible.test(string)) { return string; } - return string.replace(badChars, escapeChar); } - }; })();