Merge pull request #6287 from RyanCavanaugh/fix6241
Escape quotes when they appear as HTML entities in JSX text
This commit is contained in:
commit
6be0206242
5 changed files with 15 additions and 1 deletions
|
@ -7221,7 +7221,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||||
// Replace entities like
|
// Replace entities like
|
||||||
result = result.replace(/&(\w+);/g, function(s: any, m: string) {
|
result = result.replace(/&(\w+);/g, function(s: any, m: string) {
|
||||||
if (entities[m] !== undefined) {
|
if (entities[m] !== undefined) {
|
||||||
return String.fromCharCode(entities[m]);
|
const ch = String.fromCharCode(entities[m]);
|
||||||
|
// " needs to be escaped
|
||||||
|
return ch === "\"" ? "\\\"" : ch;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -8,7 +8,9 @@ declare module JSX {
|
||||||
declare var React: any;
|
declare var React: any;
|
||||||
|
|
||||||
<div>Dot goes here: · ¬AnEntity; </div>;
|
<div>Dot goes here: · ¬AnEntity; </div>;
|
||||||
|
<div>Be careful of "-ed strings!</div>;
|
||||||
|
|
||||||
|
|
||||||
//// [file.js]
|
//// [file.js]
|
||||||
React.createElement("div", null, "Dot goes here: · ¬AnEntity; ");
|
React.createElement("div", null, "Dot goes here: · ¬AnEntity; ");
|
||||||
|
React.createElement("div", null, "Be careful of \"-ed strings!");
|
||||||
|
|
|
@ -19,3 +19,7 @@ declare var React: any;
|
||||||
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))
|
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))
|
||||||
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))
|
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))
|
||||||
|
|
||||||
|
<div>Be careful of "-ed strings!</div>;
|
||||||
|
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))
|
||||||
|
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))
|
||||||
|
|
||||||
|
|
|
@ -20,3 +20,8 @@ declare var React: any;
|
||||||
>div : any
|
>div : any
|
||||||
>div : any
|
>div : any
|
||||||
|
|
||||||
|
<div>Be careful of "-ed strings!</div>;
|
||||||
|
><div>Be careful of "-ed strings!</div> : JSX.Element
|
||||||
|
>div : any
|
||||||
|
>div : any
|
||||||
|
|
||||||
|
|
|
@ -9,3 +9,4 @@ declare module JSX {
|
||||||
declare var React: any;
|
declare var React: any;
|
||||||
|
|
||||||
<div>Dot goes here: · ¬AnEntity; </div>;
|
<div>Dot goes here: · ¬AnEntity; </div>;
|
||||||
|
<div>Be careful of "-ed strings!</div>;
|
||||||
|
|
Loading…
Reference in a new issue