[webkit-changes] cvs commit: WebCore/kwq KWQLoader.mm
Darin
darin at opensource.apple.com
Mon Dec 19 11:50:46 PST 2005
darin 05/12/19 11:50:46
Modified: . ChangeLog
kwq KWQLoader.mm
Log:
Reviewed by Geoff Garen and John Sullivan.
- fix http://bugzilla.opendarwin.org/show_bug.cgi?id=4312
XMLHttpRequest headers that have two CRLF sequences lead to Obj-C exception
* kwq/KWQLoader.mm:
(+[NSDictionary _webcore_dictionaryWithHeaderString:_webcore_dictionaryWithHeaderString:]):
Check length of string before calling characterAtIndex:0 since it will fail for an empty string.
Revision Changes Path
1.4 +11 -0 WebCore/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebCore/ChangeLog,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ChangeLog 19 Dec 2005 19:41:38 -0000 1.3
+++ ChangeLog 19 Dec 2005 19:50:45 -0000 1.4
@@ -1,3 +1,14 @@
+2005-12-19 Darin Adler <darin at apple.com>
+
+ Reviewed by Geoff Garen and John Sullivan.
+
+ - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=4312
+ XMLHttpRequest headers that have two CRLF sequences lead to Obj-C exception
+
+ * kwq/KWQLoader.mm:
+ (+[NSDictionary _webcore_dictionaryWithHeaderString:_webcore_dictionaryWithHeaderString:]):
+ Check length of string before calling characterAtIndex:0 since it will fail for an empty string.
+
2005-12-19 Mitz Pettel <opendarwin.org at mitzpettel.com>
Reviewed by Beth
1.124 +14 -13 WebCore/kwq/KWQLoader.mm
Index: KWQLoader.mm
===================================================================
RCS file: /cvs/root/WebCore/kwq/KWQLoader.mm,v
retrieving revision 1.123
retrieving revision 1.124
diff -u -r1.123 -r1.124
--- KWQLoader.mm 3 Oct 2005 21:13:06 -0000 1.123
+++ KWQLoader.mm 19 Dec 2005 19:50:45 -0000 1.124
@@ -60,26 +60,27 @@
@end
@implementation NSDictionary (WebCore_Extras)
+
+ (id)_webcore_dictionaryWithHeaderString:(NSString *)string
{
NSMutableDictionary *headers = [[NSMutableDictionary alloc] init];
NSArray *lines = [string componentsSeparatedByString:@"\r\n"];
-
NSEnumerator *e = [lines objectEnumerator];
- NSString *line;
-
NSString *lastHeaderName = nil;
- while ((line = (NSString *)[e nextObject]) != nil) {
- if (([line characterAtIndex:0] == ' ' || [line characterAtIndex:0] == '\t')
- && lastHeaderName != nil) {
- // lines that start with space or tab continue the previous header value
- NSString *oldVal = [headers objectForKey:lastHeaderName];
- ASSERT(oldVal);
- [headers setObject:[NSString stringWithFormat:@"%@ %@", oldVal, [line stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" \t"]]]
- forKey:lastHeaderName];
- continue;
+ while (NSString *line = (NSString *)[e nextObject]) {
+ if ([line length]) {
+ unichar firstChar = [line characterAtIndex:0];
+ if ((firstChar == ' ' || firstChar == '\t') && lastHeaderName != nil) {
+ // lines that start with space or tab continue the previous header value
+ NSString *oldVal = [headers objectForKey:lastHeaderName];
+ ASSERT(oldVal);
+ NSString *newVal = [line stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@" \t"]];
+ [headers setObject:[NSString stringWithFormat:@"%@ %@", oldVal, newVal]
+ forKey:lastHeaderName];
+ continue;
+ }
}
NSRange colonRange = [line rangeOfString:@":"];
@@ -100,7 +101,7 @@
}
}
- NSDictionary *dictionary = [NSDictionary dictionaryWithDictionary:headers];
+ NSDictionary *dictionary = [NSDictionary dictionaryWithDictionary:headers];
[headers release];
More information about the webkit-changes
mailing list