Skip to content

Commit f0fc42a

Browse files
committed
Merge pull request facebook#1464 from spicyj/style-esc
Don't double-escape style names
2 parents 0377ec5 + da34209 commit f0fc42a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/browser/ui/__tests__/ReactDOMComponent-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,12 @@ describe('ReactDOMComponent', function() {
257257
expect(genMarkup({ className: 'a b' })).toHaveAttribute('class', 'a b');
258258
expect(genMarkup({ className: '' })).toHaveAttribute('class', '');
259259
});
260+
261+
it("should escape style names and values", function() {
262+
expect(genMarkup({
263+
style: {'b&ckground': '<3'}
264+
})).toHaveAttribute('style', 'b&amp;ckground:&lt;3;');
265+
});
260266
});
261267

262268
describe('createContentMarkup', function() {

src/browser/ui/dom/CSSPropertyOperations.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,11 @@
2222
var CSSProperty = require('CSSProperty');
2323

2424
var dangerousStyleValue = require('dangerousStyleValue');
25-
var escapeTextForBrowser = require('escapeTextForBrowser');
2625
var hyphenateStyleName = require('hyphenateStyleName');
2726
var memoizeStringOnly = require('memoizeStringOnly');
2827

2928
var processStyleName = memoizeStringOnly(function(styleName) {
30-
return escapeTextForBrowser(hyphenateStyleName(styleName));
29+
return hyphenateStyleName(styleName);
3130
});
3231

3332
/**
@@ -42,6 +41,7 @@ var CSSPropertyOperations = {
4241
* "width:200px;height:0;"
4342
*
4443
* Undefined values are ignored so that declarative programming is easier.
44+
* The result should be HTML-escaped before insertion into the DOM.
4545
*
4646
* @param {object} styles
4747
* @return {?string}

0 commit comments

Comments
 (0)