Skip to content

Commit 6a38787

Browse files
authored
fix(deno_telemetry): guard against malformed URLs when parsing baggage headers (#711)
1 parent 80c324e commit 6a38787

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

vendor/deno_telemetry/telemetry.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,16 +1515,21 @@ function parsePairKeyValue(
15151515
BAGGAGE_KEY_PAIR_SEPARATOR,
15161516
);
15171517
if (separatorIndex <= 0) return;
1518-
const key = decodeURIComponent(
1519-
StringPrototypeTrim(
1520-
StringPrototypeSubstring(keyPairPart, 0, separatorIndex),
1521-
),
1522-
);
1523-
const value = decodeURIComponent(
1524-
StringPrototypeTrim(
1525-
StringPrototypeSubstring(keyPairPart, separatorIndex + 1),
1526-
),
1527-
);
1518+
let key, value;
1519+
try {
1520+
key = decodeURIComponent(
1521+
StringPrototypeTrim(
1522+
StringPrototypeSubstring(keyPairPart, 0, separatorIndex),
1523+
),
1524+
);
1525+
value = decodeURIComponent(
1526+
StringPrototypeTrim(
1527+
StringPrototypeSubstring(keyPairPart, separatorIndex + 1),
1528+
),
1529+
);
1530+
} catch {
1531+
return;
1532+
}
15281533
let metadata;
15291534
if (valueProps.length > 0) {
15301535
metadata = baggageEntryMetadataFromString(

0 commit comments

Comments
 (0)