Reviewed by John.
- fixed <rdar://problem/
4020413> REGRESSION (Mail): can't use fonts with names that start with "#" in Mail (Korean fonts)
* khtml/css/css_valueimpl.cpp:
(DOM::isLegalIdentifier): Added. Commented out and not used.
(DOM::quoteStringIfNeeded): Quotes the string if needed. For now only if it starts with "#".
(DOM::CSSPrimitiveValueImpl::cssText): Call quoteStringIfNeeded when asked for cssText for an arbitrary string, since we
need text you can re-parse.
(DOM::FontFamilyValueImpl::cssText): Ditto.
* khtml/editing/markup.cpp:
(khtml::startMarkup): Added comments about lack of quoting for attributes.
(khtml::createMarkup): Ditto.
WebKit:
Reviewed by John.
- fixed <rdar://problem/
4020413> REGRESSION (Mail): can't use fonts with names that start with "#" in Mail (Korean fonts)
* WebView.subproj/WebHTMLView.m:
(-[WebHTMLView _styleFromFontAttributes:]): Quote font name when calling setFontFamily.
(-[WebHTMLView _addToStyle:fontA:fontB:]): Ditto.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@8779
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2005-03-04 Darin Adler <darin@apple.com>
+
+ Reviewed by John.
+
+ - fixed <rdar://problem/4020413> REGRESSION (Mail): can't use fonts with names that start with "#" in Mail (Korean fonts)
+
+ * khtml/css/css_valueimpl.cpp:
+ (DOM::isLegalIdentifier): Added. Commented out and not used.
+ (DOM::quoteStringIfNeeded): Quotes the string if needed. For now only if it starts with "#".
+ (DOM::CSSPrimitiveValueImpl::cssText): Call quoteStringIfNeeded when asked for cssText for an arbitrary string, since we
+ need text you can re-parse.
+ (DOM::FontFamilyValueImpl::cssText): Ditto.
+
+ * khtml/editing/markup.cpp:
+ (khtml::startMarkup): Added comments about lack of quoting for attributes.
+ (khtml::createMarkup): Ditto.
+
2005-03-04 Adele Amchan <adele@apple.com>
Reviewed by Maciej
namespace DOM {
+#if 0
+
+// Too risky to quote all legal identifiers right now.
+// Post-Tiger we should use this function or something like it.
+
+// Return true if this string qualifies as an identifier (from the point of view of CSS syntax).
+static bool isLegalIdentifier(const DOMString &string)
+{
+ int len = string.length();
+ if (len == 0) {
+ return false;
+ }
+ QChar *p = string.unicode();
+ int i = 0;
+ if (p[0] == '-') {
+ ++i;
+ }
+ if (i == len) {
+ return false;
+ }
+ ushort code = p[i].unicode();
+ if (!(code >= 0x80 || code == '_' || isalpha(code))) {
+ return false;
+ }
+ ++i;
+ while (i != len) {
+ code = p[i].unicode();
+ if (!(code >= 0x80 || code == '-' || code == '_' || isalnum(code))) {
+ return false;
+ }
+ ++i;
+ }
+ return true;
+}
+
+#endif
+
+// Quotes the string if it needs quoting.
+// We use single quotes for now beause markup.cpp uses double quotes.
+static DOMString quoteStringIfNeeded(const DOMString &string)
+{
+ // For now, just do this for strings that start with "#" to fix Korean font names that start with "#".
+ // Post-Tiger, we should isLegalIdentifier instead after working out all the ancillary issues.
+ if (string[0] != '#') {
+ return string;
+ }
+
+ // FIXME: Also need to transform control characters into \ sequences.
+ QString s = string.string();
+ s.replace('\\', "\\\\");
+ s.replace('\'', "\\'");
+ return '\'' + s + '\'';
+}
+
CSSStyleDeclarationImpl::CSSStyleDeclarationImpl(CSSRuleImpl *parent)
: StyleBaseImpl(parent)
{
// ###
break;
case CSSPrimitiveValue::CSS_STRING:
- text = DOMString(m_value.string);
+ text = quoteStringIfNeeded(m_value.string);
break;
case CSSPrimitiveValue::CSS_URI:
text = "url(";
DOM::DOMString FontFamilyValueImpl::cssText() const
{
- return parsedFontName;
+ return quoteStringIfNeeded(parsedFontName);
}
FontValueImpl::FontValueImpl()
style->ref();
defaultStyle->diff(style);
if (style->length() > 0) {
+ // FIXME: Handle case where style->cssText() has illegal characters in it, like "
QString openTag = QString("<span class=\"") + AppleStyleSpanClass + "\" style=\"" + style->cssText().string() + "\">";
markup = openTag + markup + "</span>";
}
NamedAttrMapImpl *attrs = el->attributes();
unsigned long length = attrs->length();
if (length == 0 && additionalStyle.length() > 0) {
+ // FIXME: Handle case where additionalStyle has illegal characters in it, like "
markup += " " + node->getDocument()->attrName(ATTR_STYLE).string() + "=\"" + additionalStyle.string() + "\"";
}
else {
DOMString value = attr->value();
if (attr->id() == ATTR_STYLE && additionalStyle.length() > 0)
value += "; " + additionalStyle;
+ // FIXME: Handle case where value has illegal characters in it, like "
markup += " " + node->getDocument()->attrName(attr->id()).string() + "=\"" + value.string() + "\"";
}
}
}
// add in the "default style" for this markup
+ // FIXME: Handle case where value has illegal characters in it, like "
QString openTag = QString("<span class=\"") + AppleStyleSpanClass + "\" style=\"" + defaultStyle->cssText().string() + "\">";
markups.prepend(openTag);
markups.append("</span>");
+2005-03-04 Darin Adler <darin@apple.com>
+
+ Reviewed by John.
+
+ - fixed <rdar://problem/4020413> REGRESSION (Mail): can't use fonts with names that start with "#" in Mail (Korean fonts)
+
+ * WebView.subproj/WebHTMLView.m:
+ (-[WebHTMLView _styleFromFontAttributes:]): Quote font name when calling setFontFamily.
+ (-[WebHTMLView _addToStyle:fontA:fontB:]): Ditto.
+
2005-03-04 Darin Adler <darin@apple.com>
Reviewed by John.
[style setFontStyle:@"normal"];
} else {
NSFontManager *fm = [NSFontManager sharedFontManager];
- [style setFontFamily:[font familyName]];
+ // FIXME: Need more sophisticated escaping code if we want to handle family names
+ // with characters like single quote or backslash in their names.
+ [style setFontFamily:[NSString stringWithFormat:@"'%@'", [font familyName]]];
[style setFontSize:[NSString stringWithFormat:@"%0.fpx", [font pointSize]]];
if ([fm weightOfFont:font] >= 9) {
[style setFontWeight:@"bold"];
NSString *fa = [a familyName];
NSString *fb = [b familyName];
if ([fa isEqualToString:fb]) {
- [style setFontFamily:fa];
+ // FIXME: Need more sophisticated escaping code if we want to handle family names
+ // with characters like single quote or backslash in their names.
+ [style setFontFamily:[NSString stringWithFormat:@"'%@'", fa]];
}
int sa = [a pointSize];