Release v2.19.1: repair managed font references
This commit is contained in:
1 parent
90253e98a4
commit
9ca372429b
11 files changed
+212
-23
No files matched your search
@@ -1,4 +1,5 @@
|
||||
const crypto = require('crypto');
|
||||
const { BASE_FONT_FAMILIES } = require('./font-families');
|
||||
|
||||
const REFERENCE_TYPES_BY_FIELD = {
|
||||
source_id: 'api-request',
|
||||
@@ -34,7 +35,10 @@ function addReference(references, seen, ownerKey, referenceType, value) {
|
||||
if (!Number.isFinite(numericValue)) return;
|
||||
referenceValue = String(numericValue);
|
||||
}
|
||||
if (referenceType === 'font-family') referenceValue = normalizeFontFamily(referenceValue);
|
||||
if (referenceType === 'font-family') {
|
||||
referenceValue = normalizeFontFamily(referenceValue);
|
||||
if (BASE_FONT_FAMILIES.has(referenceValue)) return;
|
||||
}
|
||||
if (!referenceValue) return;
|
||||
const key = String(ownerKey || '') + '\u0000' + referenceType + '\u0000' + referenceValue;
|
||||
if (seen.has(key)) return;
|
||||
@@ -75,10 +79,13 @@ function collectValueReferences(value, ownerKey, references, seen) {
|
||||
if (normalized) addReference(references, seen, ownerKey, 'media', normalized);
|
||||
});
|
||||
|
||||
const fontFamilies = /font-family\s*:\s*(?:"([^"]+)"|'([^']+)'|([^;}"']+))/gi;
|
||||
const fontValue = value.replace(/&(?:quot|apos|#0*34|#0*39|#x0*22|#x0*27);/gi, function (entity) {
|
||||
return /^&(?:quot|#0*34|#x0*22);$/i.test(entity) ? '"' : "'";
|
||||
});
|
||||
const fontFamilies = /font-family\s*:\s*((?:"[^"]*"|'[^']*'|[^;}"'])+)/gi;
|
||||
let match;
|
||||
while ((match = fontFamilies.exec(value))) {
|
||||
getFontFamilyCandidates(match[1] || match[2] || match[3]).forEach(function (family) {
|
||||
while ((match = fontFamilies.exec(fontValue))) {
|
||||
getFontFamilyCandidates(match[1]).forEach(function (family) {
|
||||
addReference(references, seen, ownerKey, 'font-family', family);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user