Skip to content

Commit 701f08a

Browse files
committed
encode selector attributes
1 parent 9165085 commit 701f08a

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

packages/react-dom-bindings/src/client/ReactDOMFloatClient.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,18 @@ export function getResource(
444444
matcher = 'meta[charset]';
445445
} else if (typeof content === 'string') {
446446
if (typeof httpEquiv === 'string') {
447-
matcher = `meta[http-equiv="${httpEquiv}"][content="${content}"]`;
447+
matcher = `meta[http-equiv="${escapeSelectorAttributeValueInsideDoubleQuotes(
448+
httpEquiv,
449+
)}"][content="${escapeSelectorAttributeValueInsideDoubleQuotes(
450+
content,
451+
)}"]`;
448452
} else if (typeof property === 'string') {
449453
propertyString = property;
450-
matcher = `meta[property="${property}"][content="${content}"]`;
454+
matcher = `meta[property="${escapeSelectorAttributeValueInsideDoubleQuotes(
455+
property,
456+
)}"][content="${escapeSelectorAttributeValueInsideDoubleQuotes(
457+
content,
458+
)}"]`;
451459

452460
const parentPropertyPath = property
453461
.split(':')
@@ -460,9 +468,17 @@ export function getResource(
460468
matcher = parentResource.matcher + matcher;
461469
}
462470
} else if (typeof name === 'string') {
463-
matcher = `meta[name="${name}"][content="${content}"]`;
471+
matcher = `meta[name="${escapeSelectorAttributeValueInsideDoubleQuotes(
472+
name,
473+
)}"][content="${escapeSelectorAttributeValueInsideDoubleQuotes(
474+
content,
475+
)}"]`;
464476
} else if (typeof itemProp === 'string') {
465-
matcher = `meta[itemprop="${itemProp}"][content="${content}"]`;
477+
matcher = `meta[itemprop="${escapeSelectorAttributeValueInsideDoubleQuotes(
478+
itemProp,
479+
)}"][content="${escapeSelectorAttributeValueInsideDoubleQuotes(
480+
content,
481+
)}"]`;
466482
}
467483
}
468484
if (matcher) {

0 commit comments

Comments
 (0)