| Summary: | Konqueror renders CSS page wrong vs. Firefox | ||
|---|---|---|---|
| Product: | [Applications] konqueror | Reporter: | tilleyrw |
| Component: | general | Assignee: | Konqueror Bugs <konqueror-bugs-null> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | germain, martin.hohenberg |
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | Ubuntu | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
tilleyrw
2006-08-18 02:21:15 UTC
Still valid in 4.1.1 SVN commit 864150 by ggarand:
do not attempt to recover incorrectly written hexadecimal
colours when the parser is in strict mode.
BUG: 132581
M +26 -24 cssparser.cpp
--- trunk/KDE/kdelibs/khtml/css/cssparser.cpp #864149:864150
@@ -2134,31 +2134,33 @@
}
}
-static bool parseColor(int unit, const QString& name, QRgb& rgb)
+static bool parseColor(int unit, const QString& name, QRgb& rgb, bool strict)
{
int len = name.length();
if ( !len )
return false;
- const unsigned short* c =
- reinterpret_cast<const unsigned short*>( name.unicode() );
+ if (unit == CSSPrimitiveValue::CSS_RGBCOLOR || !strict) {
+ const unsigned short* c =
+ reinterpret_cast<const unsigned short*>( name.unicode() );
- rgb = 0xff; // fixed alpha
- if ( len == 6 ) {
- // RRGGBB
- bool error = false;
- for ( int i = 0; i < 6; ++i, ++c )
- rgb = rgb << 4 | hex2int( *c, &error );
- if ( !error )
- return true;
- } else if ( len == 3 ) {
- // RGB, shortcut for RRGGBB
- bool error = false;
- for ( int i = 0; i < 3; ++i, ++c )
- rgb = rgb << 8 | 0x11 * hex2int( *c, &error );
- if ( !error )
- return true;
+ rgb = 0xff; // fixed alpha
+ if ( len == 6 ) {
+ // RRGGBB
+ bool error = false;
+ for ( int i = 0; i < 6; ++i, ++c )
+ rgb = rgb << 4 | hex2int( *c, &error );
+ if ( !error )
+ return true;
+ } else if ( len == 3 ) {
+ // RGB, shortcut for RRGGBB
+ bool error = false;
+ for ( int i = 0; i < 3; ++i, ++c )
+ rgb = rgb << 8 | 0x11 * hex2int( *c, &error );
+ if ( !error )
+ return true;
+ }
}
if ( unit == CSSPrimitiveValue::CSS_IDENT ) {
@@ -2182,17 +2184,17 @@
CSSPrimitiveValueImpl *CSSParser::parseColorFromValue(Value* value)
{
QRgb c = khtml::transparentColor;
- if ( !strict && value->unit == CSSPrimitiveValue::CSS_NUMBER &&
+ if ( !strict && value->unit == CSSPrimitiveValue::CSS_NUMBER && // color: 000000 (quirk)
value->fValue >= 0. && value->fValue < 1000000. ) {
QString str;
str.sprintf( "%06d", (int)(value->fValue+.5) );
- if ( !::parseColor( value->unit, str, c ) )
+ if ( !::parseColor( CSSPrimitiveValue::CSS_RGBCOLOR, str, c, strict ) )
return 0;
}
- else if (value->unit == CSSPrimitiveValue::CSS_RGBCOLOR ||
- value->unit == CSSPrimitiveValue::CSS_IDENT ||
- (!strict && value->unit == CSSPrimitiveValue::CSS_DIMENSION)) {
- if ( !::parseColor( value->unit, qString( value->string ), c) )
+ else if (value->unit == CSSPrimitiveValue::CSS_RGBCOLOR || // color: #ff0000
+ value->unit == CSSPrimitiveValue::CSS_IDENT || // color: red || color: ff0000 (quirk)
+ (!strict && value->unit == CSSPrimitiveValue::CSS_DIMENSION)) { // color: 00ffff (quirk)
+ if ( !::parseColor( value->unit, qString( value->string ), c, strict) )
return 0;
}
else if ( value->unit == Value::Function &&
|