[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:19:19 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit f985574130d8455806cee23e57023a304d33708b
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Jan 13 03:49:37 2003 +0000

            Reviewed by John.
    
    	- fixed 3144882 -- pretend to be WinIE for abcnews.com
    
            * WebView.subproj/WebControllerPrivate.h: Add an enum, UserAgentStringType, with values
    	Safari, MacIE, and WinIE. Also add NumUserAgentStringTypes and turn the userAgent and
    	userAgentWhenPretendingToBeMacIE strings into an array indexed by type.
    
            * WebView.subproj/WebController.m:
            (-[WebController setApplicationNameForUserAgent:]): Use a loop to discard the user agent
    	strings, since we have an array now.
            (-[WebController userAgentForURL:]): Change user agent algorithm to check two strings rather
    	than once against the spoof table, allowing two dots in the "domain name", which is needed
    	for "abcnews.go.com". Get a user agent string type from the table rather than just a boolean
    	"pretend to be MacIE". Store a string per type rather than one for normalcy and one for MacIE.
    	Add a case for WinIE to the user agent computations.
    
    	* English.lproj/StringsNotToBeLocalized.txt: Update for change above.
    
            * WebView.subproj/WebControllerPrivate.m:
            (-[WebControllerPrivate dealloc]): Use a loop to discard the user agent strings, since we have
    	an array now.
            (-[WebController _defaultsDidChange]): Ditto.
    
            * WebView.subproj/WebUserAgentSpoofTable.gperf: Add a UserAgentStringType field to the struct.
    	Add MacIE to each existing table entry, and add a new one that says WinIE for abcnews.go.com.
    
            * Makefile.am: Pass "-F ,0" to gperf so that we don't get warnings compiling empty entries
    	in the hash table.
    
            * WebView.subproj/WebUserAgentSpoofTable.c: Re-generated.
    
            - other changes
    
            * WebView.subproj/WebHTMLView.m: Removed some old, dead, #if 0'd code.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3307 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 6c24092..4935dd6 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,41 @@
+2003-01-12  Darin Adler  <darin at apple.com>
+
+        Reviewed by John.
+
+	- fixed 3144882 -- pretend to be WinIE for abcnews.com
+
+        * WebView.subproj/WebControllerPrivate.h: Add an enum, UserAgentStringType, with values
+	Safari, MacIE, and WinIE. Also add NumUserAgentStringTypes and turn the userAgent and
+	userAgentWhenPretendingToBeMacIE strings into an array indexed by type.
+
+        * WebView.subproj/WebController.m:
+        (-[WebController setApplicationNameForUserAgent:]): Use a loop to discard the user agent
+	strings, since we have an array now.
+        (-[WebController userAgentForURL:]): Change user agent algorithm to check two strings rather
+	than once against the spoof table, allowing two dots in the "domain name", which is needed
+	for "abcnews.go.com". Get a user agent string type from the table rather than just a boolean
+	"pretend to be MacIE". Store a string per type rather than one for normalcy and one for MacIE.
+	Add a case for WinIE to the user agent computations.
+
+	* English.lproj/StringsNotToBeLocalized.txt: Update for change above.
+
+        * WebView.subproj/WebControllerPrivate.m:
+        (-[WebControllerPrivate dealloc]): Use a loop to discard the user agent strings, since we have
+	an array now.
+        (-[WebController _defaultsDidChange]): Ditto.
+
+        * WebView.subproj/WebUserAgentSpoofTable.gperf: Add a UserAgentStringType field to the struct.
+	Add MacIE to each existing table entry, and add a new one that says WinIE for abcnews.go.com.
+
+        * Makefile.am: Pass "-F ,0" to gperf so that we don't get warnings compiling empty entries
+	in the hash table.
+
+        * WebView.subproj/WebUserAgentSpoofTable.c: Re-generated.
+        
+        - other changes
+        
+        * WebView.subproj/WebHTMLView.m: Removed some old, dead, #if 0'd code.
+
 2003-01-11  Darin Adler  <darin at apple.com>
 
         Reviewed by John.
diff --git a/WebKit/English.lproj/StringsNotToBeLocalized.txt b/WebKit/English.lproj/StringsNotToBeLocalized.txt
index d64c6a2..92265a9 100644
--- a/WebKit/English.lproj/StringsNotToBeLocalized.txt
+++ b/WebKit/English.lproj/StringsNotToBeLocalized.txt
@@ -77,6 +77,8 @@
 "MP4 Video"
 "Mozilla/4.0 (compatible; MSIE 5.2; Mac_PowerPC) AppleWebKit/%@ %@"
 "Mozilla/4.0 (compatible; MSIE 5.2; Mac_PowerPC) AppleWebKit/%@"
+"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT) AppleWebKit/%@ %@"
+"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT) AppleWebKit/%@"
 "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (like Gecko) %@"
 "Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (like Gecko)"
 "NETSCAPE2"
diff --git a/WebKit/Makefile.am b/WebKit/Makefile.am
index cb0ec8b..f1c29e0 100644
--- a/WebKit/Makefile.am
+++ b/WebKit/Makefile.am
@@ -7,7 +7,7 @@ clean-am:
 	rm -rf $(SYMROOTS)/Safari.app/Frameworks/WebKit.framework
 
 WebView.subproj/WebUserAgentSpoofTable.c: WebView.subproj/WebUserAgentSpoofTable.gperf Makefile.am previous-clean-timestamp
-	gperf -CEot -L 'ANSI-C' -k '*' -N _web_findSpoofTableEntry $< > $@ 
+	gperf -CEot -L 'ANSI-C' -k '*' -N _web_findSpoofTableEntry -F ,0 $< > $@ 
 
 BUILT_SOURCES = WebView.subproj/WebUserAgentSpoofTable.c
 CLEANFILES = $(BUILT_SOURCES)
diff --git a/WebKit/WebView.subproj/WebController.m b/WebKit/WebView.subproj/WebController.m
index 9cc87b8..c4f7b13 100644
--- a/WebKit/WebView.subproj/WebController.m
+++ b/WebKit/WebView.subproj/WebController.m
@@ -322,8 +322,11 @@ NSString *WebElementStringKey = 		@"WebElementString";
     NSString *name = [applicationName copy];
     [_private->applicationNameForUserAgent release];
     _private->applicationNameForUserAgent = name;
-    [_private->userAgent release];
-    _private->userAgent = nil;
+    int i;
+    for (i = 0; i != NumUserAgentStringTypes; ++i) {
+        [_private->userAgent[i] release];
+        _private->userAgent[i] = nil;
+    }
 }
 
 - (NSString *)applicationNameForUserAgent
@@ -369,17 +372,20 @@ NSString *WebElementStringKey = 		@"WebElementString";
 
     // Look to see if we need to spoof.
     // First step is to get the host as a C-format string.
-    BOOL pretendToBeMacIE = NO;
+    UserAgentStringType type = Safari;
     NSString *host = [URL host];
     char hostBuffer[256];
     if (host && CFStringGetCString((CFStringRef)host, hostBuffer, sizeof(hostBuffer), kCFStringEncodingASCII)) {
-        // Next step is to find the last part of the name. The part with only one dot.
+        // Next step is to find the last part of the name.
+        // We get the part with only two dots, and the part with only one dot.
+        const char *thirdToLastPeriod = NULL;
         const char *nextToLastPeriod = NULL;
         const char *lastPeriod = NULL;
         char c;
         char *p = hostBuffer;
         while ((c = *p)) {
             if (c == '.') {
+                thirdToLastPeriod = nextToLastPeriod;
                 nextToLastPeriod = lastPeriod;
                 lastPeriod = p;
             } else {
@@ -389,13 +395,23 @@ NSString *WebElementStringKey = 		@"WebElementString";
         }
         // Now look up that last part in the gperf spoof table.
         if (lastPeriod) {
-            const char *domain = nextToLastPeriod ? nextToLastPeriod + 1 : hostBuffer;
-            pretendToBeMacIE = _web_findSpoofTableEntry(domain, p - domain) != NULL;
+            const char *lastPart;
+            const struct UserAgentSpoofTableEntry *entry = NULL;
+            if (nextToLastPeriod) {
+                lastPart = thirdToLastPeriod ? thirdToLastPeriod + 1 : hostBuffer;
+                entry = _web_findSpoofTableEntry(lastPart, p - lastPart);
+            }
+            if (!entry) {
+                lastPart = nextToLastPeriod ? nextToLastPeriod + 1 : hostBuffer;
+                entry = _web_findSpoofTableEntry(lastPart, p - lastPart);
+            }
+            if (entry) {
+                type = entry->type;
+            }
         }
     }
     
-    NSString **userAgentStorage = pretendToBeMacIE
-        ? &_private->userAgentWhenPretendingToBeMacIE : &_private->userAgent;
+    NSString **userAgentStorage = &_private->userAgent[type];
 
     NSString *userAgent = *userAgentStorage;
     if (userAgent) {
@@ -409,22 +425,34 @@ NSString *WebElementStringKey = 		@"WebElementString";
         objectForInfoDictionaryKey:(id)kCFBundleVersionKey];
     NSString *applicationName = _private->applicationNameForUserAgent;
 
-    if (pretendToBeMacIE) {
-        if ([applicationName length]) {
-            userAgent = [NSString stringWithFormat:@"Mozilla/4.0 (compatible; MSIE 5.2; Mac_PowerPC) AppleWebKit/%@ %@",
-                language, sourceVersion, applicationName];
-        } else {
-            userAgent = [NSString stringWithFormat:@"Mozilla/4.0 (compatible; MSIE 5.2; Mac_PowerPC) AppleWebKit/%@",
-                language, sourceVersion];
-        }
-    } else {
-        if ([applicationName length]) {
-            userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (like Gecko) %@",
-                language, sourceVersion, applicationName];
-        } else {
-            userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (like Gecko)",
-                language, sourceVersion];
-        }
+    switch (type) {
+        case Safari:
+            if ([applicationName length]) {
+                userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (like Gecko) %@",
+                    language, sourceVersion, applicationName];
+            } else {
+                userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (like Gecko)",
+                    language, sourceVersion];
+            }
+            break;
+        case MacIE:
+            if ([applicationName length]) {
+                userAgent = [NSString stringWithFormat:@"Mozilla/4.0 (compatible; MSIE 5.2; Mac_PowerPC) AppleWebKit/%@ %@",
+                    language, sourceVersion, applicationName];
+            } else {
+                userAgent = [NSString stringWithFormat:@"Mozilla/4.0 (compatible; MSIE 5.2; Mac_PowerPC) AppleWebKit/%@",
+                    language, sourceVersion];
+            }
+            break;
+        case WinIE:
+            if ([applicationName length]) {
+                userAgent = [NSString stringWithFormat:@"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT) AppleWebKit/%@ %@",
+                    language, sourceVersion, applicationName];
+            } else {
+                userAgent = [NSString stringWithFormat:@"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT) AppleWebKit/%@",
+                    language, sourceVersion];
+            }
+            break;
     }
     
     *userAgentStorage = [userAgent retain];
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.h b/WebKit/WebView.subproj/WebControllerPrivate.h
index 7f75542..103a7d7 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.h
+++ b/WebKit/WebView.subproj/WebControllerPrivate.h
@@ -9,6 +9,9 @@
 @class WebError;
 @class WebFrame;
 
+typedef enum { Safari, MacIE, WinIE } UserAgentStringType;
+enum { NumUserAgentStringTypes = WinIE + 1 };
+
 @interface WebControllerPrivate : NSObject
 {
 @public
@@ -30,8 +33,7 @@
 
     NSString *applicationNameForUserAgent;
     NSString *userAgentOverride;
-    NSString *userAgent;
-    NSString *userAgentWhenPretendingToBeMacIE;
+    NSString *userAgent[NumUserAgentStringTypes];
     
     BOOL defersCallbacks;
 
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.m b/WebKit/WebView.subproj/WebControllerPrivate.m
index c60ae79..344d886 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.m
+++ b/WebKit/WebView.subproj/WebControllerPrivate.m
@@ -64,8 +64,10 @@
     [backForwardList release];
     [applicationNameForUserAgent release];
     [userAgentOverride release];
-    [userAgent release];
-    [userAgentWhenPretendingToBeMacIE release];
+    int i;
+    for (i = 0; i != NumUserAgentStringTypes; ++i) {
+        [userAgent[i] release];
+    }
     
     [controllerSetName release];
     [topLevelFrameName release];
@@ -334,10 +336,11 @@
 
 - (void)_defaultsDidChange
 {
-    [_private->userAgent release];
-    _private->userAgent = nil;
-    [_private->userAgentWhenPretendingToBeMacIE release];
-    _private->userAgentWhenPretendingToBeMacIE = nil;
+    int i;
+    for (i = 0; i != NumUserAgentStringTypes; ++i) {
+        [_private->userAgent[i] release];
+        _private->userAgent[i] = nil;
+    }
 }
 
 @end
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index f6267ff..a24c13d 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -672,62 +672,6 @@
     [self _updateMouseoverWithEvent:[[notification userInfo] objectForKey:@"NSEvent"]];
 }
 
-#if 0
-
-// Why don't we call KHTMLView's keyPressEvent/keyReleaseEvent?
-// Because we currently don't benefit from any of the code in there.
-
-// It implements its own version of keyboard scrolling, but we have our
-// version in WebView. It implements some keyboard access to individual
-// nodes, but we are probably going to handle that on the NSView side.
-// We already handle normal typing through the responder chain.
-
-// One of the benefits of not calling through to KHTMLView is that we don't
-// have to have the isScrollEvent function at all.
-
-- (void)keyDown: (NSEvent *)event
-{
-    LOG(Events, "keyDown: %@", event);
-    int state = 0;
-    
-    // FIXME: We don't want to call keyPressEvent for scrolling key events,
-    // so we have to have some logic for deciding which events go to the KHTMLView.
-    // Best option is probably to only pass in certain events that we know it
-    // handles in a way we like.
-    
-    if (passToWidget) {
-        [self _addModifiers:[event modifierFlags] toState:&state];
-        QKeyEvent kEvent(QEvent::KeyPress, 0, 0, state, NSSTRING_TO_QSTRING([event characters]), [event isARepeat], 1);
-        
-        KHTMLView *widget = _private->widget;
-        if (widget)
-            widget->keyPressEvent(&kEvent);
-    } else {
-        [super keyDown:event];
-    }
-}
-
-- (void)keyUp: (NSEvent *)event
-{
-    LOG(Events, "keyUp: %@", event);
-    int state = 0;
-    
-    // FIXME: Make sure this logic matches keyDown above.
-    
-    if (passToWidget) {
-        [self _addModifiers:[event modifierFlags] toState:&state];
-        QKeyEvent kEvent(QEvent::KeyPress, 0, 0, state, NSSTRING_TO_QSTRING([event characters]), [event isARepeat], 1);
-        
-        KHTMLView *widget = _private->widget;
-        if (widget)
-            widget->keyReleaseEvent(&kEvent);
-    } else {
-        [super keyUp:event];
-    }
-}
-
-#endif
-
 - (BOOL)supportsTextEncoding
 {
     return YES;
diff --git a/WebKit/WebView.subproj/WebUserAgentSpoofTable.c b/WebKit/WebView.subproj/WebUserAgentSpoofTable.c
index b8cdcbb..2a2420b 100644
--- a/WebKit/WebView.subproj/WebUserAgentSpoofTable.c
+++ b/WebKit/WebView.subproj/WebUserAgentSpoofTable.c
@@ -1,6 +1,6 @@
 /* ANSI-C code produced by gperf version 2.7.2 */
-/* Command-line: gperf -CEot -L ANSI-C -k '*' -N _web_findSpoofTableEntry WebView.subproj/WebUserAgentSpoofTable.gperf  */
-struct UserAgentSpoofTableEntry { const char *name; };
+/* Command-line: gperf -CEot -L ANSI-C -k '*' -N _web_findSpoofTableEntry -F ,0 WebView.subproj/WebUserAgentSpoofTable.gperf  */
+struct UserAgentSpoofTableEntry { const char *name; UserAgentStringType type; };
 /* maximum key range = 18, duplicates = 0 */
 
 #ifdef __GNUC__
@@ -26,7 +26,7 @@ hash (register const char *str, register unsigned int len)
       27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
       27, 27, 27, 27, 27, 27, 27,  0,  0,  0,
        0,  0, 10,  0,  0,  0,  5, 27,  0,  0,
-       0,  0,  0, 27,  0,  0,  0,  0,  0,  0,
+       0,  0,  0, 27,  0,  0,  0,  0,  5,  0,
       27,  5, 27, 27, 27, 27, 27, 27, 27, 27,
       27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
       27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
@@ -96,7 +96,7 @@ _web_findSpoofTableEntry (register const char *str, register unsigned int len)
 {
   enum
     {
-      TOTAL_KEYWORDS = 12,
+      TOTAL_KEYWORDS = 13,
       MIN_WORD_LENGTH = 9,
       MAX_WORD_LENGTH = 18,
       MIN_HASH_VALUE = 9,
@@ -105,23 +105,25 @@ _web_findSpoofTableEntry (register const char *str, register unsigned int len)
 
   static const struct UserAgentSpoofTableEntry wordlist[] =
     {
-      {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
-      {"watch.com"},
-      {"battle.net"},
-      {"porsche.com"},
-      {""},
-      {"hondacars.com"},
-      {"oregonlive.com"},
-      {"jaguar.com"},
-      {"olympic.org"},
-      {""},
-      {"hondaredriders.com"},
-      {""}, {""},
-      {"freebsd.org"},
-      {"firstusa.com"},
-      {"microsoft.com"},
-      {""}, {""},
-      {"bang-olufsen.com"}
+      {"",0}, {"",0}, {"",0}, {"",0}, {"",0}, {"",0}, {"",0},
+      {"",0}, {"",0},
+      {"watch.com", MacIE},
+      {"battle.net", MacIE},
+      {"porsche.com", MacIE},
+      {"",0},
+      {"hondacars.com", MacIE},
+      {"abcnews.go.com", WinIE},
+      {"jaguar.com", MacIE},
+      {"olympic.org", MacIE},
+      {"",0},
+      {"hondaredriders.com", MacIE},
+      {"oregonlive.com", MacIE},
+      {"",0},
+      {"freebsd.org", MacIE},
+      {"firstusa.com", MacIE},
+      {"microsoft.com", MacIE},
+      {"",0}, {"",0},
+      {"bang-olufsen.com", MacIE}
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
diff --git a/WebKit/WebView.subproj/WebUserAgentSpoofTable.gperf b/WebKit/WebView.subproj/WebUserAgentSpoofTable.gperf
index 6db2d8c..688e32b 100644
--- a/WebKit/WebView.subproj/WebUserAgentSpoofTable.gperf
+++ b/WebKit/WebView.subproj/WebUserAgentSpoofTable.gperf
@@ -1,31 +1,33 @@
-struct UserAgentSpoofTableEntry { const char *name; };
+struct UserAgentSpoofTableEntry { const char *name; UserAgentStringType type; };
 %%
-# At the moment, any entry in this table means "pretend to be Mac IE"
-# for all URLs within this domain, where domain is defined as URLs with
-# host strings of "xxx.com" or "<anything>.xxx.com".
+# Entries in this table apply to all hosts with strings of "xxx.com" or "<anything>.xxx.com".
+# Entries must have either one dot or two dots in them.
 #
 # pretend to be Mac IE because these sites forbid unknown browsers
-bang-olufsen.com
-hondacars.com
-hondaredriders.com
-jaguar.com
-porsche.com
+bang-olufsen.com, MacIE
+hondacars.com, MacIE
+hondaredriders.com, MacIE
+jaguar.com, MacIE
+porsche.com, MacIE
 #
 # pretend to be Mac IE because otherwise the site tries to use layers
-watch.com
+watch.com, MacIE
 #
 # pretend to be Mac IE to make the return key work to log in
-firstusa.com
+firstusa.com, MacIE
 #
 # pretend to be Mac IE to avoid bad-quality CSS the site gives us otherwise
-microsoft.com
-olympic.org
+microsoft.com, MacIE
+olympic.org, MacIE
 #
 # pretend to be Mac IE to get the cool animation on the battle.net/war3 page that Darin likes
-battle.net
+battle.net, MacIE
 #
 # pretend to be Mac IE to avoid gzipped HTML which we don't support yet
-freebsd.org
+freebsd.org, MacIE
 #
 # pretend to be Mac IE to work around bug and avoid "spewage" at the bottom of some pages
-oregonlive.com
+oregonlive.com, MacIE
+#
+# pretend to be Win IE to get the smaller font sizes the site gives for Windows
+abcnews.go.com, WinIE
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index 9cc87b8..c4f7b13 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -322,8 +322,11 @@ NSString *WebElementStringKey = 		@"WebElementString";
     NSString *name = [applicationName copy];
     [_private->applicationNameForUserAgent release];
     _private->applicationNameForUserAgent = name;
-    [_private->userAgent release];
-    _private->userAgent = nil;
+    int i;
+    for (i = 0; i != NumUserAgentStringTypes; ++i) {
+        [_private->userAgent[i] release];
+        _private->userAgent[i] = nil;
+    }
 }
 
 - (NSString *)applicationNameForUserAgent
@@ -369,17 +372,20 @@ NSString *WebElementStringKey = 		@"WebElementString";
 
     // Look to see if we need to spoof.
     // First step is to get the host as a C-format string.
-    BOOL pretendToBeMacIE = NO;
+    UserAgentStringType type = Safari;
     NSString *host = [URL host];
     char hostBuffer[256];
     if (host && CFStringGetCString((CFStringRef)host, hostBuffer, sizeof(hostBuffer), kCFStringEncodingASCII)) {
-        // Next step is to find the last part of the name. The part with only one dot.
+        // Next step is to find the last part of the name.
+        // We get the part with only two dots, and the part with only one dot.
+        const char *thirdToLastPeriod = NULL;
         const char *nextToLastPeriod = NULL;
         const char *lastPeriod = NULL;
         char c;
         char *p = hostBuffer;
         while ((c = *p)) {
             if (c == '.') {
+                thirdToLastPeriod = nextToLastPeriod;
                 nextToLastPeriod = lastPeriod;
                 lastPeriod = p;
             } else {
@@ -389,13 +395,23 @@ NSString *WebElementStringKey = 		@"WebElementString";
         }
         // Now look up that last part in the gperf spoof table.
         if (lastPeriod) {
-            const char *domain = nextToLastPeriod ? nextToLastPeriod + 1 : hostBuffer;
-            pretendToBeMacIE = _web_findSpoofTableEntry(domain, p - domain) != NULL;
+            const char *lastPart;
+            const struct UserAgentSpoofTableEntry *entry = NULL;
+            if (nextToLastPeriod) {
+                lastPart = thirdToLastPeriod ? thirdToLastPeriod + 1 : hostBuffer;
+                entry = _web_findSpoofTableEntry(lastPart, p - lastPart);
+            }
+            if (!entry) {
+                lastPart = nextToLastPeriod ? nextToLastPeriod + 1 : hostBuffer;
+                entry = _web_findSpoofTableEntry(lastPart, p - lastPart);
+            }
+            if (entry) {
+                type = entry->type;
+            }
         }
     }
     
-    NSString **userAgentStorage = pretendToBeMacIE
-        ? &_private->userAgentWhenPretendingToBeMacIE : &_private->userAgent;
+    NSString **userAgentStorage = &_private->userAgent[type];
 
     NSString *userAgent = *userAgentStorage;
     if (userAgent) {
@@ -409,22 +425,34 @@ NSString *WebElementStringKey = 		@"WebElementString";
         objectForInfoDictionaryKey:(id)kCFBundleVersionKey];
     NSString *applicationName = _private->applicationNameForUserAgent;
 
-    if (pretendToBeMacIE) {
-        if ([applicationName length]) {
-            userAgent = [NSString stringWithFormat:@"Mozilla/4.0 (compatible; MSIE 5.2; Mac_PowerPC) AppleWebKit/%@ %@",
-                language, sourceVersion, applicationName];
-        } else {
-            userAgent = [NSString stringWithFormat:@"Mozilla/4.0 (compatible; MSIE 5.2; Mac_PowerPC) AppleWebKit/%@",
-                language, sourceVersion];
-        }
-    } else {
-        if ([applicationName length]) {
-            userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (like Gecko) %@",
-                language, sourceVersion, applicationName];
-        } else {
-            userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (like Gecko)",
-                language, sourceVersion];
-        }
+    switch (type) {
+        case Safari:
+            if ([applicationName length]) {
+                userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (like Gecko) %@",
+                    language, sourceVersion, applicationName];
+            } else {
+                userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (like Gecko)",
+                    language, sourceVersion];
+            }
+            break;
+        case MacIE:
+            if ([applicationName length]) {
+                userAgent = [NSString stringWithFormat:@"Mozilla/4.0 (compatible; MSIE 5.2; Mac_PowerPC) AppleWebKit/%@ %@",
+                    language, sourceVersion, applicationName];
+            } else {
+                userAgent = [NSString stringWithFormat:@"Mozilla/4.0 (compatible; MSIE 5.2; Mac_PowerPC) AppleWebKit/%@",
+                    language, sourceVersion];
+            }
+            break;
+        case WinIE:
+            if ([applicationName length]) {
+                userAgent = [NSString stringWithFormat:@"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT) AppleWebKit/%@ %@",
+                    language, sourceVersion, applicationName];
+            } else {
+                userAgent = [NSString stringWithFormat:@"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT) AppleWebKit/%@",
+                    language, sourceVersion];
+            }
+            break;
     }
     
     *userAgentStorage = [userAgent retain];
diff --git a/WebKit/WebView.subproj/WebViewPrivate.h b/WebKit/WebView.subproj/WebViewPrivate.h
index 7f75542..103a7d7 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.h
+++ b/WebKit/WebView.subproj/WebViewPrivate.h
@@ -9,6 +9,9 @@
 @class WebError;
 @class WebFrame;
 
+typedef enum { Safari, MacIE, WinIE } UserAgentStringType;
+enum { NumUserAgentStringTypes = WinIE + 1 };
+
 @interface WebControllerPrivate : NSObject
 {
 @public
@@ -30,8 +33,7 @@
 
     NSString *applicationNameForUserAgent;
     NSString *userAgentOverride;
-    NSString *userAgent;
-    NSString *userAgentWhenPretendingToBeMacIE;
+    NSString *userAgent[NumUserAgentStringTypes];
     
     BOOL defersCallbacks;
 
diff --git a/WebKit/WebView.subproj/WebViewPrivate.m b/WebKit/WebView.subproj/WebViewPrivate.m
index c60ae79..344d886 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.m
+++ b/WebKit/WebView.subproj/WebViewPrivate.m
@@ -64,8 +64,10 @@
     [backForwardList release];
     [applicationNameForUserAgent release];
     [userAgentOverride release];
-    [userAgent release];
-    [userAgentWhenPretendingToBeMacIE release];
+    int i;
+    for (i = 0; i != NumUserAgentStringTypes; ++i) {
+        [userAgent[i] release];
+    }
     
     [controllerSetName release];
     [topLevelFrameName release];
@@ -334,10 +336,11 @@
 
 - (void)_defaultsDidChange
 {
-    [_private->userAgent release];
-    _private->userAgent = nil;
-    [_private->userAgentWhenPretendingToBeMacIE release];
-    _private->userAgentWhenPretendingToBeMacIE = nil;
+    int i;
+    for (i = 0; i != NumUserAgentStringTypes; ++i) {
+        [_private->userAgent[i] release];
+        _private->userAgent[i] = nil;
+    }
 }
 
 @end

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list