Skip to content

Commit

Permalink
Bug 1565942 - Allow the loading of TYPE_FONT from file: URLs, r=bzbar…
Browse files Browse the repository at this point in the history
…sky a=RyanVM

Differential Revision: https://phabricator.services.mozilla.com/D38561

--HG--
extra : source : 86db1d535ac582d547c03b7d7049e82da94706c2
extra : intermediate-source : 94b2c630c42c5720b9cdd4cc0c390408c927d69c
  • Loading branch information
bakulf committed Jul 18, 2019
1 parent e8b0e02 commit d5439e7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions layout/style/FontFaceSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,15 +588,24 @@ nsresult FontFaceSet::StartLoad(gfxUserFontEntry* aUserFontEntry,
nsCOMPtr<nsILoadGroup> loadGroup(mDocument->GetDocumentLoadGroup());
gfxFontSrcPrincipal* principal = aUserFontEntry->GetPrincipal();

uint32_t securityFlags = 0;
bool isFile = false;
if (NS_SUCCEEDED(aFontFaceSrc->mURI->get()->SchemeIs("file", &isFile)) &&
isFile) {
securityFlags = nsILoadInfo::SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS;
} else {
securityFlags = nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS;
}

nsCOMPtr<nsIChannel> channel;
// Note we are calling NS_NewChannelWithTriggeringPrincipal() with both a
// node and a principal. This is because the document where the font is
// being loaded might have a different origin from the principal of the
// stylesheet that initiated the font load.
rv = NS_NewChannelWithTriggeringPrincipal(
getter_AddRefs(channel), aFontFaceSrc->mURI->get(), mDocument,
principal ? principal->get() : nullptr,
nsILoadInfo::SEC_REQUIRE_CORS_DATA_INHERITS, nsIContentPolicy::TYPE_FONT,
principal ? principal->get() : nullptr, securityFlags,
nsIContentPolicy::TYPE_FONT,
nullptr, // PerformanceStorage
loadGroup);
NS_ENSURE_SUCCESS(rv, rv);
Expand Down

0 comments on commit d5439e7

Please sign in to comment.