Commit c911ccf5 authored by kocienda's avatar kocienda
Browse files

Remove characters RFC 2396 describes as "unwise" from the

	BadChar character class. This causes them to remain unescaped
	in KURL objects. As a result, some extra escaping needed to
	be added into the getNSURL() function to enable NSURL
	objects to be created using a KURL.

	This enables me to fix this bug:
	Radar 3050437 (Clicking link leads to page with garbled content)

	Note, however, that my fix for 3050437 relies on this bug remaining unfixed:

	Radar 3102332 (Square bracket characters "sneak through" CFURL illegal character checks)

        * kwq/KWQKURL.mm:
        (KURL::getNSURL)


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2693 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 960f8f20
2002-11-15 Ken Kocienda <kocienda@apple.com>
Remove characters RFC 2396 describes as "unwise" from the
BadChar character class. This causes them to remain unescaped
in KURL objects. As a result, some extra escaping needed to
be added into the getNSURL() function to enable NSURL
objects to be created using a KURL.
This enables me to fix this bug:
Radar 3050437 (Clicking link leads to page with garbled content)
Note, however, that my fix for 3050437 relies on this bug remaining unfixed:
Radar 3102332 (Square bracket characters "sneak through" CFURL illegal character checks)
* kwq/KWQKURL.mm:
(KURL::getNSURL)
2002-11-15 Darin Adler <darin@apple.com>
 
- fixed 3027460 -- text areas don't have focus rectangles
......
2002-11-15 Ken Kocienda <kocienda@apple.com>
Remove characters RFC 2396 describes as "unwise" from the
BadChar character class. This causes them to remain unescaped
in KURL objects. As a result, some extra escaping needed to
be added into the getNSURL() function to enable NSURL
objects to be created using a KURL.
This enables me to fix this bug:
Radar 3050437 (Clicking link leads to page with garbled content)
Note, however, that my fix for 3050437 relies on this bug remaining unfixed:
Radar 3102332 (Square bracket characters "sneak through" CFURL illegal character checks)
* kwq/KWQKURL.mm:
(KURL::getNSURL)
2002-11-15 Darin Adler <darin@apple.com>
 
- fixed 3027460 -- text areas don't have focus rectangles
......
2002-11-15 Ken Kocienda <kocienda@apple.com>
Remove characters RFC 2396 describes as "unwise" from the
BadChar character class. This causes them to remain unescaped
in KURL objects. As a result, some extra escaping needed to
be added into the getNSURL() function to enable NSURL
objects to be created using a KURL.
This enables me to fix this bug:
Radar 3050437 (Clicking link leads to page with garbled content)
Note, however, that my fix for 3050437 relies on this bug remaining unfixed:
Radar 3102332 (Square bracket characters "sneak through" CFURL illegal character checks)
* kwq/KWQKURL.mm:
(KURL::getNSURL)
2002-11-15 Darin Adler <darin@apple.com>
 
- fixed 3027460 -- text areas don't have focus rectangles
......
......@@ -120,11 +120,11 @@ static const unsigned char characterClassTable[256] = {
/* 88 X */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
/* 89 Y */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
/* 90 Z */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
/* 91 [ */ BadChar,
/* 92 \ */ BadChar, /* 93 ] */ BadChar,
/* 94 ^ */ BadChar,
/* 91 [ */ 0,
/* 92 \ */ 0, /* 93 ] */ 0,
/* 94 ^ */ 0,
/* 95 _ */ UserInfoChar | HostnameChar,
/* 96 ` */ BadChar,
/* 96 ` */ 0,
/* 97 a */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | HexDigitChar | IPv6Char,
/* 98 b */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | HexDigitChar | IPv6Char,
/* 99 c */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar | HexDigitChar | IPv6Char,
......@@ -151,8 +151,8 @@ static const unsigned char characterClassTable[256] = {
/* 120 x */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
/* 121 y */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
/* 122 z */ SchemeFirstChar | SchemeChar | UserInfoChar | HostnameChar,
/* 123 { */ BadChar,
/* 124 | */ BadChar, /* 125 } */ BadChar, /* 126 ~ */ UserInfoChar, /* 127 del */ BadChar,
/* 123 { */ 0,
/* 124 | */ 0, /* 125 } */ 0, /* 126 ~ */ UserInfoChar, /* 127 del */ BadChar,
/* 128 */ BadChar, /* 129 */ BadChar, /* 130 */ BadChar, /* 131 */ BadChar,
/* 132 */ BadChar, /* 133 */ BadChar, /* 134 */ BadChar, /* 135 */ BadChar,
/* 136 */ BadChar, /* 137 */ BadChar, /* 138 */ BadChar, /* 139 */ BadChar,
......@@ -1065,7 +1065,20 @@ NSURL *KURL::getNSURL() const
string = [NSString stringWithFormat:@"file://%@", [string substringFromIndex:5]];
}
return [NSURL URLWithString:string];
NSURL *URL = [NSURL URLWithString:string];
if (!URL) {
// Try to create URL again, but this time do some more string escaping first.
// Eventually, we would prefer not to have to take this extra step, as the extra
// escaping causes bugs like 3064743.
// Note the set of unescaped characters contains the square brackets.
// This is a bit of license we take with CFURL and its code to detect characters
// it considers illegal. See 3102332 for more information.
CFStringRef stricterString = CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)string, CFSTR("[]%"), NULL, kCFStringEncodingUTF8);
URL = [NSURL URLWithString:(NSString *)stricterString];
CFRelease(stricterString);
}
return URL;
}
QString KURL::encodedHtmlRef() const
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment