mirror of
https://github.com/classilla/tenfourfox.git
synced 2025-01-26 23:32:55 +00:00
closes #513: add more font entries, allow blocking through CSS-FLAPI
This commit is contained in:
parent
5cf00f4a2f
commit
8be8e20573
@ -278,6 +278,7 @@ gfxPlatformMac::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags)
|
||||
// Start with leftmost, using hostname as a screen (TenFourFox issue 492).
|
||||
|
||||
HTTP_OR_HTTPS_SUBDIR("fonts.gstatic.com", "/ea/notosansjapanese/v6/NotoSansJP-");
|
||||
HTTP_OR_HTTPS_SUBDIR("fonts.gstatic.com", "/s/notosansjp/v14/");
|
||||
|
||||
HTTP_OR_HTTPS_SUBDIR("www.icloud.com", "/fonts/SFNSText-");
|
||||
|
||||
@ -285,11 +286,18 @@ gfxPlatformMac::IsFontFormatSupported(nsIURI *aFontURI, uint32_t aFormatFlags)
|
||||
HTTP_OR_HTTPS_SUBDIR("typeface.nytimes.com", "/fonts/nyt-cheltenham-");
|
||||
|
||||
// Don't cut to SF-Pro-; there are some dingbat fonts that DO work.
|
||||
HTTP_OR_HTTPS_SUBDIR("www.apple.com", "/wss/fonts/SF-Pro-JP/v1/");
|
||||
HTTP_OR_HTTPS_SUBDIR("www.apple.com", "/wss/fonts/SF-Pro-Text/v1/");
|
||||
HTTP_OR_HTTPS_SUBDIR("www.apple.com", "/wss/fonts/SF-Pro-Display/v1/");
|
||||
|
||||
HTTP_OR_HTTPS_SUBDIR("lib.intuitcdn.net", "/fonts/AvenirNext/1.0/");
|
||||
|
||||
HTTP_OR_HTTPS_SUBDIR("use.typekit.net", "/af/e3bd4a/00000000000000003b9ade5d/");
|
||||
HTTP_OR_HTTPS_SUBDIR("use.typekit.net", "/af/dd9acd/0000000000000000000177dc/");
|
||||
HTTP_OR_HTTPS_SUBDIR("use.typekit.net", "/af/7088b5/0000000000000000000177de/");
|
||||
HTTP_OR_HTTPS_SUBDIR("use.typekit.net", "/af/430cc5/0000000000000000000177da/");
|
||||
HTTP_OR_HTTPS_SUBDIR("platform-assets.typekit.net", "/AND-Regular.");
|
||||
|
||||
// Check hostname and subpatterns (TenFourFox issue 477).
|
||||
HOST_AND_KEY("www.latimes.com", "/fonts/KisFBDisplay-");
|
||||
HOST_AND_KEY("www.nerdwallet.com", "Gotham-Book--critical");
|
||||
|
@ -17,6 +17,10 @@
|
||||
#include "nsIDocument.h"
|
||||
#include "nsStyleUtil.h"
|
||||
|
||||
// TenFourFox issue 513
|
||||
#include "nsICryptoHash.h"
|
||||
#include "nsNetCID.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
@ -196,6 +200,54 @@ FontFace::Constructor(const GlobalObject& aGlobal,
|
||||
void
|
||||
FontFace::InitializeSource(const StringOrArrayBufferOrArrayBufferView& aSource)
|
||||
{
|
||||
// TenFourFox issue 513: hash the string or the buffer and thus
|
||||
// have yet another font blacklist. The string could be a URL,
|
||||
// but it could also be a data URL, and I'd rather not duplicate
|
||||
// the logic from gfx/thebes in this file too.
|
||||
nsAutoCString fullHash;
|
||||
nsresult rv;
|
||||
|
||||
#define FONT_FACE_ENSURE_SUCCESS if (NS_FAILED(rv)) { SetStatus(FontFaceLoadStatus::Error); return; }
|
||||
nsCOMPtr<nsICryptoHash> crypto = do_CreateInstance(NS_CRYPTO_HASH_CONTRACTID, &rv);
|
||||
FONT_FACE_ENSURE_SUCCESS
|
||||
rv = crypto->Init(nsICryptoHash::SHA1);
|
||||
FONT_FACE_ENSURE_SUCCESS
|
||||
if (aSource.IsString()) {
|
||||
rv = crypto->Update(reinterpret_cast<const uint8_t*>(aSource.GetAsString().BeginReading()),
|
||||
aSource.GetAsString().Length());
|
||||
} else {
|
||||
if (aSource.IsArrayBuffer()) {
|
||||
GetDataFrom(aSource.GetAsArrayBuffer(),
|
||||
mSourceBuffer, mSourceBufferLength);
|
||||
} else {
|
||||
MOZ_ASSERT(aSource.IsArrayBufferView());
|
||||
GetDataFrom(aSource.GetAsArrayBufferView(),
|
||||
mSourceBuffer, mSourceBufferLength);
|
||||
}
|
||||
|
||||
rv = crypto->Update(reinterpret_cast<const uint8_t*>(mSourceBuffer), mSourceBufferLength);
|
||||
}
|
||||
FONT_FACE_ENSURE_SUCCESS
|
||||
rv = crypto->Finish(true, fullHash);
|
||||
FONT_FACE_ENSURE_SUCCESS
|
||||
#undef FONT_FACE_ENSURE_SUCCESS
|
||||
else {
|
||||
#if DEBUG
|
||||
fprintf(stderr, "Hashed binary font loaded through CFLAPI: %s\n", fullHash.get());
|
||||
#endif
|
||||
if (0 ||
|
||||
// various TypeKit fonts
|
||||
fullHash.Equals("0J8+zdBD2+R6x1AGwjdcnDKsexg=") ||
|
||||
fullHash.Equals("43Ex5T5rNbucBuC/8634OUdpNbc=") ||
|
||||
fullHash.Equals("4AlprMOrpYDZsCQW6LUmjOzj84M=") ||
|
||||
fullHash.Equals("Yb+MwthynLt2Y4pvXDv5pumHX2E=") ||
|
||||
0) {
|
||||
fprintf(stderr, "Warning: TenFourFox blocking ATSUI-incompatible CSS Font Loading API source (with SHA-1 hash of %s).\n", fullHash.get());
|
||||
SetStatus(FontFaceLoadStatus::Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (aSource.IsString()) {
|
||||
if (!ParseDescriptor(eCSSFontDesc_Src,
|
||||
aSource.GetAsString(),
|
||||
@ -218,15 +270,6 @@ FontFace::InitializeSource(const StringOrArrayBufferOrArrayBufferView& aSource)
|
||||
|
||||
mSourceType = FontFace::eSourceType_Buffer;
|
||||
|
||||
if (aSource.IsArrayBuffer()) {
|
||||
GetDataFrom(aSource.GetAsArrayBuffer(),
|
||||
mSourceBuffer, mSourceBufferLength);
|
||||
} else {
|
||||
MOZ_ASSERT(aSource.IsArrayBufferView());
|
||||
GetDataFrom(aSource.GetAsArrayBufferView(),
|
||||
mSourceBuffer, mSourceBufferLength);
|
||||
}
|
||||
|
||||
SetStatus(FontFaceLoadStatus::Loading);
|
||||
DoLoad();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user