Bug 22488 - Make DRT smarter about charset encoding when post-processing webarchive content
Summary: Make DRT smarter about charset encoding when post-processing webarchive content
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: 523.x (Safari 3)
Hardware: Mac OS X 10.5
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-25 10:48 PST by David Kilzer (:ddkilzer)
Modified: 2008-11-26 11:38 PST (History)
4 users (show)

See Also:


Attachments
Patch v1 (3.14 KB, patch)
2008-11-25 10:57 PST, David Kilzer (:ddkilzer)
beidson: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2008-11-25 10:48:45 PST
* SUMMARY
When attempting to create a layout test for Bug 22466, I tried moving fast/encoding/preload-encoding.html to an http test.  After setting the charset encoding for the "gb2312" files using a .htaccess file, I found that DRT would crash in convertWebResourceDataToString() because dataAsString was nil using the hard-coded UTF-8 encoding:

NSString *dataAsString = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
[resource setObject:dataAsString forKey:@"WebResourceData"];

* THE FIX
The better way to do this is to:

1. Attempt to convert the IANA charset into an NSStringEncoding value.
2. Check that dataAsString is non-nil before replacing it in the dictionary.

Instead of crashing, the worst that will happen is that the string data won't be decoded in the webarchive test output.
Comment 1 David Kilzer (:ddkilzer) 2008-11-25 10:57:47 PST
Created attachment 25488 [details]
Patch v1

Suggested fix.

No layout test since this is a DRT fix.
Comment 2 David Kilzer (:ddkilzer) 2008-11-26 11:38:39 PST
$ git svn dcommit
Committing to http://svn.webkit.org/repository/webkit/trunk ...
	M	WebKitTools/ChangeLog
	M	WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm
Committed r38786

http://trac.webkit.org/changeset/38786