mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #4931 from bspaulding/safe-taint-docs
Extracted "safe taint" in docs/homepage to align with best practice
(cherry picked from commit 06568114f3)
This commit is contained in:
@@ -6,6 +6,9 @@ var MarkdownEditor = React.createClass({
|
||||
handleChange: function() {
|
||||
this.setState({value: React.findDOMNode(this.refs.textarea).value});
|
||||
},
|
||||
rawMarkup: function() {
|
||||
return { __html: marked(this.state.value, {sanitize: true}) };
|
||||
},
|
||||
render: function() {
|
||||
return (
|
||||
<div className="MarkdownEditor">
|
||||
@@ -17,9 +20,7 @@ var MarkdownEditor = React.createClass({
|
||||
<h3>Output</h3>
|
||||
<div
|
||||
className="content"
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: marked(this.state.value, {sanitize: true})
|
||||
}}
|
||||
dangerouslySetInnerHTML={this.rawMarkup()}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -257,14 +257,18 @@ That's React protecting you from an [XSS attack](https://en.wikipedia.org/wiki/C
|
||||
```javascript{4,10}
|
||||
// tutorial7.js
|
||||
var Comment = React.createClass({
|
||||
render: function() {
|
||||
rawMarkup: function() {
|
||||
var rawMarkup = marked(this.props.children.toString(), {sanitize: true});
|
||||
return { __html: rawMarkup };
|
||||
},
|
||||
|
||||
render: function() {
|
||||
return (
|
||||
<div className="comment">
|
||||
<h2 className="commentAuthor">
|
||||
{this.props.author}
|
||||
</h2>
|
||||
<span dangerouslySetInnerHTML={{"{{"}}__html: rawMarkup}} />
|
||||
<span dangerouslySetInnerHTML={this.rawMarkup()} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user