Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap trusted-types policy creation in a try/catch #475

Merged
merged 5 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.6.4 - (2022-11-15)

- Wrap Trusted Types policy-creation in a try/catch.

## 2.6.2 - (2022-07-28)

- Address Trusted Types compliance issue.
Expand Down
2 changes: 1 addition & 1 deletion lib/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const Constants = {
* @const
* @type {string}
*/
msRestVersion: "2.6.3",
msRestVersion: "2.6.4",

/**
* Specifies HTTP.
Expand Down
12 changes: 8 additions & 4 deletions lib/util/xml.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ const parser = new DOMParser();
// according to the spec. There are no HTML/XSS security concerns on the usage of
// parseFromString() here.
let ttPolicy: Pick<TrustedTypePolicy, "createHTML"> | undefined;
if (typeof self.trustedTypes !== "undefined") {
ttPolicy = self.trustedTypes.createPolicy("@azure/ms-rest-js#xml.browser", {
createHTML: (s) => s,
});
try {
if (typeof self.trustedTypes !== "undefined") {
ttPolicy = self.trustedTypes.createPolicy("@azure/ms-rest-js#xml.browser", {
createHTML: (s) => s,
});
}
} catch (e) {
console.warn('Could not create trusted types policy "@azure/ms-rest-js#xml.browser"');
}

export function parseXML(str: string): Promise<any> {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"email": "azsdkteam@microsoft.com",
"url": "https://github.com/Azure/ms-rest-js"
},
"version": "2.6.3",
"version": "2.6.4",
"description": "Isomorphic client Runtime for Typescript/node.js/browser javascript client libraries generated using AutoRest",
"tags": [
"isomorphic",
Expand Down