Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Avoid unnecessary mime check for data urls.
Browse files Browse the repository at this point in the history
RELNOTES: Avoid unnecessary mime check for data urls.

PiperOrigin-RevId: 424690815
Change-Id: I15515b4826ac9bc20d2b293305a45eb8865cc4d2
  • Loading branch information
Closure Team authored and copybara-github committed Jan 27, 2022
1 parent 73847ba commit 987094d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions closure/goog/html/safeurl.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ goog.html.SafeUrl.unwrap = function(safeUrl) {
safeUrl.constructor === goog.html.SafeUrl) {
return safeUrl.privateDoNotAccessOrElseSafeUrlWrappedValue_;
} else {
goog.asserts.fail('expected object of type SafeUrl, got \'' +
safeUrl + '\' of type ' + goog.typeOf(safeUrl));
goog.asserts.fail(
'expected object of type SafeUrl, got \'' + safeUrl + '\' of type ' +
goog.typeOf(safeUrl));
return 'type_error:SafeUrl';
}
};
Expand Down Expand Up @@ -348,8 +349,7 @@ goog.html.SafeUrl.tryFromDataUrl = function(dataUrl) {
// origins. Only Firefox for versions prior to v57 behaves differently:
// https://blog.mozilla.org/security/2017/10/04/treating-data-urls-unique-origins-firefox-57/
// Older versions of IE don't understand `data:` urls, so it is not an issue.
var valid = match && goog.html.SafeUrl.isSafeMimeType(match[1]);
if (valid) {
if (match) {
return goog.html.SafeUrl.createSafeUrlSecurityPrivateDoNotAccessOrElse(
filteredDataUrl);
}
Expand Down

0 comments on commit 987094d

Please # to comment.