From 9b349633d1d2a78b7dfc5857a6cd45c8a153ca47 Mon Sep 17 00:00:00 2001 From: Jorg K Date: Sun, 24 Apr 2016 20:49:16 +0200 Subject: [PATCH] Bug 1267069 - Strip quotes in font names. r=aceman,IanN --- editor/ui/composer/content/editor.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/editor/ui/composer/content/editor.js b/editor/ui/composer/content/editor.js index 827483a616..7e390e1e9f 100644 --- a/editor/ui/composer/content/editor.js +++ b/editor/ui/composer/content/editor.js @@ -667,6 +667,12 @@ function onFontFaceChange(fontFaceMenuList, commandID) var commandNode = document.getElementById(commandID); var editorFont = commandNode.getAttribute("state"); + // Strip quotes in font names. Experiments have shown that we only + // ever get double quotes around the font name, never single quotes, + // even if they were in the HTML source. Also single or double + // quotes within the font name are never returned. + editorFont = editorFont.replace(/"/g, ""); + switch (editorFont) { case "mixed": // Selection is the "mixed" ( > 1 style) state. @@ -717,7 +723,7 @@ function onFontFaceChange(fontFaceMenuList, commandID) let afterUsedFontSection = false; // The menu items not only have "label" and "value", but also some other attributes: - // "value_parsed": Is the toLowerCase() and space stripped value. + // "value_parsed": Is the toLowerCase() and space-stripped value. // "value_cache": Is a concatenation of all editor fonts that were ever mapped // onto this menu item. This is done for optimization. // "used": This item is in the used font section. @@ -934,6 +940,13 @@ function initFontFaceMenu(menuPopup) var mixed = { value: false }; var editorFont = GetCurrentEditor().getFontFaceState(mixed); + + // Strip quotes in font names. Experiments have shown that we only + // ever get double quotes around the font name, never single quotes, + // even if they were in the HTML source. Also single or double + // quotes within the font name are never returned. + editorFont = editorFont.replace(/"/g, ""); + if (!mixed.value) { switch (editorFont)