Commit 4ea6a4b6 authored by kocienda's avatar kocienda

Fix for this bug:

	Radar 3102708 (REGRESSION: assertion failure backing up to page)

	KWQCheckCacheObjectStatus did not create an NSURL in a way that
	dealt with the fact that we handle non-NSURL-compliant URL strings.
	I have fixed it so it does, and in the process, factored out
	the code to do it into a new KURL static function (KURL::getNSURLFromString).

        * kwq/KWQKURL.h:
        * kwq/KWQKURL.mm:
        (KURL::getNSURL): Now calls through to KURL::getNSURLFromString
        (KURL::encode_string)
        (KURL::getNSURLFromString): New function to handle NSURL creation
        * kwq/KWQLoader.mm:
        (KWQCheckCacheObjectStatus)


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@2704 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b1bda391
2002-11-15 Ken Kocienda <kocienda@apple.com>
Fix for this bug:
Radar 3102708 (REGRESSION: assertion failure backing up to page)
KWQCheckCacheObjectStatus did not create an NSURL in a way that
dealt with the fact that we handle non-NSURL-compliant URL strings.
I have fixed it so it does, and in the process, factored out
the code to do it into a new KURL static function (KURL::getNSURLFromString).
* kwq/KWQKURL.h:
* kwq/KWQKURL.mm:
(KURL::getNSURL): Now calls through to KURL::getNSURLFromString
(KURL::encode_string)
(KURL::getNSURLFromString): New function to handle NSURL creation
* kwq/KWQLoader.mm:
(KWQCheckCacheObjectStatus)
2002-11-15 David Hyatt <hyatt@apple.com>
Fix asserts in tables.
......
2002-11-15 Ken Kocienda <kocienda@apple.com>
Fix for this bug:
Radar 3102708 (REGRESSION: assertion failure backing up to page)
KWQCheckCacheObjectStatus did not create an NSURL in a way that
dealt with the fact that we handle non-NSURL-compliant URL strings.
I have fixed it so it does, and in the process, factored out
the code to do it into a new KURL static function (KURL::getNSURLFromString).
* kwq/KWQKURL.h:
* kwq/KWQKURL.mm:
(KURL::getNSURL): Now calls through to KURL::getNSURLFromString
(KURL::encode_string)
(KURL::getNSURLFromString): New function to handle NSURL creation
* kwq/KWQLoader.mm:
(KWQCheckCacheObjectStatus)
2002-11-15 David Hyatt <hyatt@apple.com>
Fix asserts in tables.
......
2002-11-15 Ken Kocienda <kocienda@apple.com>
Fix for this bug:
Radar 3102708 (REGRESSION: assertion failure backing up to page)
KWQCheckCacheObjectStatus did not create an NSURL in a way that
dealt with the fact that we handle non-NSURL-compliant URL strings.
I have fixed it so it does, and in the process, factored out
the code to do it into a new KURL static function (KURL::getNSURLFromString).
* kwq/KWQKURL.h:
* kwq/KWQKURL.mm:
(KURL::getNSURL): Now calls through to KURL::getNSURLFromString
(KURL::encode_string)
(KURL::getNSURLFromString): New function to handle NSURL creation
* kwq/KWQLoader.mm:
(KWQCheckCacheObjectStatus)
2002-11-15 David Hyatt <hyatt@apple.com>
Fix asserts in tables.
......
......@@ -75,6 +75,7 @@ public:
static QString decode_string(const QString &);
static QString encode_string(const QString &);
static NSURL *getNSURLFromString(const QString &);
friend bool operator==(const KURL &, const KURL &);
......
......@@ -1057,28 +1057,7 @@ void KURL::parse(const char *url, const QString *originalString)
NSURL *KURL::getNSURL() const
{
NSString *string = urlString.getNSString();
// Had to re-add this hack to work around CFURL bug 2908969, and to prevent the symptoms
// described in bug 3032058.
if ([string hasPrefix:@"file:/"] && ![string hasPrefix:@"file://"]) {
string = [NSString stringWithFormat:@"file://%@", [string substringFromIndex:5]];
}
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;
return KURL::getNSURLFromString(urlString);
}
QString KURL::encodedHtmlRef() const
......@@ -1134,3 +1113,31 @@ QString KURL::encode_string(const QString& notEncodedString)
return result;
}
NSURL *KURL::getNSURLFromString(const QString &urlString)
{
NSString *string = urlString.getNSString();
// Had to re-add this hack to work around CFURL bug 2908969, and to prevent the symptoms
// described in bug 3032058.
if ([string hasPrefix:@"file:/"] && ![string hasPrefix:@"file://"]) {
string = [NSString stringWithFormat:@"file://%@", [string substringFromIndex:5]];
}
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);
if (stricterString) {
URL = [NSURL URLWithString:(NSString *)stricterString];
CFRelease(stricterString);
}
}
return URL;
}
......@@ -88,11 +88,10 @@ void KWQCheckCacheObjectStatus(DocLoader *loader, CachedObject *cachedObject)
// Notify the caller that we "loaded".
WebCoreBridge *bridge = ((KHTMLPart *)loader->part())->kwq->bridge();
NSURL *URL = [[NSURL alloc] initWithString:cachedObject->url().string().getNSString()];
NSURL *URL = KURL::getNSURLFromString(cachedObject->url().string());
ASSERT(URL);
CachedImage *cachedImage = dynamic_cast<CachedImage *>(cachedObject);
[bridge objectLoadedFromCache:URL response:(id)cachedObject->response() size:cachedImage ? cachedImage->dataSize() : cachedObject->size()];
[URL release];
}
void KWQRetainResponse(void *response)
......
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