[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 08:26:49 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit e98c94bf3304e25075c24fe5ff51a4e8eaecf4c6
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Feb 16 16:19:16 2004 +0000

            Reviewed by John and Don.
    
            - discovered that jaguar.com doesn't need spoofing any more, so removed
              the spoofing machinery entirely; if we ever have to bring it back we
              can, but I doubt we will
    
            * WebView.subproj/WebView.m: Removed include of WebUserAgentSpoofTable.c.
            (-[WebViewPrivate dealloc]): Release the new single userAgent rather than
            the array and userAgentOverride we used to.
            (-[WebView _preferencesChangedNotification:]): Release the single user agent,
            rather than the entire cache. Also only do it when the user agent is not
            overridden.
            (-[WebView setApplicationNameForUserAgent:]): Ditto.
            (-[WebView setCustomUserAgent:]): Set the new userAgentOverridden boolean,
            and also set userAgent itself.
            (-[WebView customUserAgent]): Return userAgent, but only if userAgentOverridden
            is true.
            (-[WebView userAgentForURL:]): Simplify, now that there's no automatic spoofing
            to do. Made even simpler by the fact that custom and computed user agents both
            share the same field now.
    
            * WebView.subproj/WebViewPrivate.h: Got rid of UserAgentStringType, turned the
            userAgent field into a single item instead of an array, and replaced the
            userAgentOverride field with a boolean userAgentOverridden field.
    
            * Makefile.am: Removed the rule to build WebUserAgentSpoofTable.c.
            * WebView.subproj/WebUserAgentSpoofTable.c: Removed.
            * WebView.subproj/WebUserAgentSpoofTable.gperf: Removed.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6092 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 2ea5361..9b9f315 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,5 +1,36 @@
 2004-02-15  Darin Adler  <darin at apple.com>
 
+        Reviewed by John and Don.
+
+        - discovered that jaguar.com doesn't need spoofing any more, so removed
+          the spoofing machinery entirely; if we ever have to bring it back we
+          can, but I doubt we will
+
+        * WebView.subproj/WebView.m: Removed include of WebUserAgentSpoofTable.c.
+        (-[WebViewPrivate dealloc]): Release the new single userAgent rather than
+        the array and userAgentOverride we used to.
+        (-[WebView _preferencesChangedNotification:]): Release the single user agent,
+        rather than the entire cache. Also only do it when the user agent is not
+        overridden.
+        (-[WebView setApplicationNameForUserAgent:]): Ditto.
+        (-[WebView setCustomUserAgent:]): Set the new userAgentOverridden boolean,
+        and also set userAgent itself.
+        (-[WebView customUserAgent]): Return userAgent, but only if userAgentOverridden
+        is true.
+        (-[WebView userAgentForURL:]): Simplify, now that there's no automatic spoofing
+        to do. Made even simpler by the fact that custom and computed user agents both
+        share the same field now.
+
+        * WebView.subproj/WebViewPrivate.h: Got rid of UserAgentStringType, turned the
+        userAgent field into a single item instead of an array, and replaced the
+        userAgentOverride field with a boolean userAgentOverridden field.
+
+        * Makefile.am: Removed the rule to build WebUserAgentSpoofTable.c.
+        * WebView.subproj/WebUserAgentSpoofTable.c: Removed.
+        * WebView.subproj/WebUserAgentSpoofTable.gperf: Removed.
+
+2004-02-15  Darin Adler  <darin at apple.com>
+
         Reviewed by Dave.
 
         * WebKit.pbproj/project.pbxproj: Tweak build styles a bit, fixing OptimizedWithSymbols,
diff --git a/WebKit/Makefile.am b/WebKit/Makefile.am
index 31a8d78..d46f440 100644
--- a/WebKit/Makefile.am
+++ b/WebKit/Makefile.am
@@ -6,12 +6,6 @@ clean-am:
 	rm -rf $(SYMROOTS)/WebKit.framework
 	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 -F ,0 $< > $@ 
-
-BUILT_SOURCES = WebView.subproj/WebUserAgentSpoofTable.c
-CLEANFILES = $(BUILT_SOURCES)
-
 previous-clean-timestamp: force-clean-timestamp
 	make clean && touch $@
 
diff --git a/WebKit/WebView.subproj/WebUserAgentSpoofTable.c b/WebKit/WebView.subproj/WebUserAgentSpoofTable.c
deleted file mode 100644
index 0693f4e..0000000
--- a/WebKit/WebView.subproj/WebUserAgentSpoofTable.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/* ANSI-C code produced by gperf version 2.7.2 */
-/* 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 = 1, duplicates = 0 */
-
-#ifdef __GNUC__
-__inline
-#else
-#ifdef __cplusplus
-inline
-#endif
-#endif
-static unsigned int
-hash (register const char *str, register unsigned int len)
-{
-  static const unsigned char asso_values[] =
-    {
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11,  0, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11,  0, 11,  0,
-      11, 11, 11,  0, 11, 11,  0, 11, 11,  0,
-      11,  0, 11, 11,  0, 11, 11,  0, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
-      11, 11, 11, 11, 11, 11
-    };
-  register int hval = len;
-
-  switch (hval)
-    {
-      default:
-      case 10:
-        hval += asso_values[(unsigned char)str[9]];
-      case 9:
-        hval += asso_values[(unsigned char)str[8]];
-      case 8:
-        hval += asso_values[(unsigned char)str[7]];
-      case 7:
-        hval += asso_values[(unsigned char)str[6]];
-      case 6:
-        hval += asso_values[(unsigned char)str[5]];
-      case 5:
-        hval += asso_values[(unsigned char)str[4]];
-      case 4:
-        hval += asso_values[(unsigned char)str[3]];
-      case 3:
-        hval += asso_values[(unsigned char)str[2]];
-      case 2:
-        hval += asso_values[(unsigned char)str[1]];
-      case 1:
-        hval += asso_values[(unsigned char)str[0]];
-        break;
-    }
-  return hval;
-}
-
-#ifdef __GNUC__
-__inline
-#endif
-const struct UserAgentSpoofTableEntry *
-_web_findSpoofTableEntry (register const char *str, register unsigned int len)
-{
-  enum
-    {
-      TOTAL_KEYWORDS = 1,
-      MIN_WORD_LENGTH = 10,
-      MAX_WORD_LENGTH = 10,
-      MIN_HASH_VALUE = 10,
-      MAX_HASH_VALUE = 10
-    };
-
-  static const struct UserAgentSpoofTableEntry wordlist[] =
-    {
-      {"",0}, {"",0}, {"",0}, {"",0}, {"",0}, {"",0}, {"",0},
-      {"",0}, {"",0}, {"",0},
-      {"jaguar.com", MacIE}
-    };
-
-  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
-    {
-      register int key = hash (str, len);
-
-      if (key <= MAX_HASH_VALUE && key >= 0)
-        {
-          register const char *s = wordlist[key].name;
-
-          if (*str == *s && !strcmp (str + 1, s + 1))
-            return &wordlist[key];
-        }
-    }
-  return 0;
-}
diff --git a/WebKit/WebView.subproj/WebUserAgentSpoofTable.gperf b/WebKit/WebView.subproj/WebUserAgentSpoofTable.gperf
deleted file mode 100644
index 128cf32..0000000
--- a/WebKit/WebView.subproj/WebUserAgentSpoofTable.gperf
+++ /dev/null
@@ -1,7 +0,0 @@
-struct UserAgentSpoofTableEntry { const char *name; UserAgentStringType type; };
-%%
-# 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
-jaguar.com, MacIE
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index ab07064..18549fd 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -55,14 +55,6 @@
 #import <Foundation/NSURLFileTypeMappings.h>
 #import <Foundation/NSURLRequestPrivate.h>
 
-static const struct UserAgentSpoofTableEntry *_web_findSpoofTableEntry(const char *, unsigned);
-
-// Turn off inlining to avoid warning with newer gcc.
-#undef __inline
-#define __inline
-#include "WebUserAgentSpoofTable.c"
-#undef __inline
-
 NSString *WebElementFrameKey =              @"WebElementFrame";
 NSString *WebElementImageKey =              @"WebElementImage";
 NSString *WebElementImageAltStringKey =     @"WebElementImageAltString";
@@ -122,11 +114,7 @@ NSString *_WebMainFrameURLKey =         @"mainFrameURL";
     
     [backForwardList release];
     [applicationNameForUserAgent release];
-    [userAgentOverride release];
-    int i;
-    for (i = 0; i != NumUserAgentStringTypes; ++i) {
-        [userAgent[i] release];
-    }
+    [userAgent release];
     
     [preferences release];
     [settings release];
@@ -574,22 +562,15 @@ NSString *_WebMainFrameURLKey =         @"mainFrameURL";
     [_private->settings setShouldPrintBackgrounds:[preferences shouldPrintBackgrounds]];
 }
 
-- (void)_releaseUserAgentStrings
-{
-    int i;
-    for (i = 0; i != NumUserAgentStringTypes; ++i) {
-        [_private->userAgent[i] release];
-        _private->userAgent[i] = nil;
-    }
-}
-
-
 - (void)_preferencesChangedNotification: (NSNotification *)notification
 {
     WebPreferences *preferences = (WebPreferences *)[notification object];
     
     ASSERT(preferences == [self preferences]);
-    [self _releaseUserAgentStrings];
+    if (!_private->userAgentOverridden) {
+        [_private->userAgent release];
+        _private->userAgent = nil;
+    }
     [self _updateWebCoreSettingsFromPreferences: preferences];
 }
 
@@ -1449,10 +1430,9 @@ NS_ENDHANDLER
     NSString *name = [applicationName copy];
     [_private->applicationNameForUserAgent release];
     _private->applicationNameForUserAgent = name;
-    int i;
-    for (i = 0; i != NumUserAgentStringTypes; ++i) {
-        [_private->userAgent[i] release];
-        _private->userAgent[i] = nil;
+    if (!_private->userAgentOverridden) {
+        [_private->userAgent release];
+        _private->userAgent = nil;
     }
 }
 
@@ -1464,13 +1444,14 @@ NS_ENDHANDLER
 - (void)setCustomUserAgent:(NSString *)userAgentString
 {
     NSString *override = [userAgentString copy];
-    [_private->userAgentOverride release];
-    _private->userAgentOverride = override;
+    [_private->userAgent release];
+    _private->userAgent = override;
+    _private->userAgentOverridden = override != nil;
 }
 
 - (NSString *)customUserAgent
 {
-    return [[_private->userAgentOverride retain] autorelease];
+    return _private->userAgentOverridden ? [[_private->userAgent retain] autorelease] : nil;
 }
 
 - (BOOL)supportsTextEncoding
@@ -1512,56 +1493,10 @@ NS_ENDHANDLER
 }
 
 // Get the appropriate user-agent string for a particular URL.
+// Since we no longer automatically spoof, this no longer requires looking at the URL.
 - (NSString *)userAgentForURL:(NSURL *)URL
 {
-    if (_private->userAgentOverride) {
-        return [[_private->userAgentOverride retain] autorelease];
-    }
-    
-    // Look to see if we need to spoof.
-    // First step is to get the host as a C-format string.
-    UserAgentStringType type = Safari;
-    NSString *host = [URL _web_hostString];
-    char hostBuffer[256];
-    if (host && CFStringGetCString((CFStringRef)host, hostBuffer, sizeof(hostBuffer), kCFStringEncodingASCII)) {
-        // 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 {
-                *p = tolower(c);
-            }
-            ++p;
-        }
-        // Now look up that last part in the gperf spoof table.
-        if (lastPeriod) {
-            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 = &_private->userAgent[type];
-
-    NSString *userAgent = *userAgentStorage;
+    NSString *userAgent = _private->userAgent;
     if (userAgent) {
         return [[userAgent retain] autorelease];
     }
@@ -1573,37 +1508,15 @@ NS_ENDHANDLER
         objectForInfoDictionaryKey:(id)kCFBundleVersionKey];
     NSString *applicationName = _private->applicationNameForUserAgent;
 
-    switch (type) {
-        case Safari:
-            if ([applicationName length]) {
-                userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (KHTML, like Gecko) %@",
-                    language, sourceVersion, applicationName];
-            } else {
-                userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (KHTML, 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;
+    if ([applicationName length]) {
+        userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (KHTML, like Gecko) %@",
+            language, sourceVersion, applicationName];
+    } else {
+        userAgent = [NSString stringWithFormat:@"Mozilla/5.0 (Macintosh; U; PPC Mac OS X; %@) AppleWebKit/%@ (KHTML, like Gecko)",
+            language, sourceVersion];
     }
 
-    *userAgentStorage = [userAgent retain];
+    _private->userAgent = [userAgent retain];
     return userAgent;
 }
 
@@ -2069,4 +1982,3 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
 }
 
 @end
-
diff --git a/WebKit/WebView.subproj/WebViewPrivate.h b/WebKit/WebView.subproj/WebViewPrivate.h
index 5920d50..4eee18e 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.h
+++ b/WebKit/WebView.subproj/WebViewPrivate.h
@@ -13,9 +13,6 @@
 @class WebCoreSettings;
 @protocol WebFormDelegate;
 
-typedef enum { Safari, MacIE, WinIE } UserAgentStringType;
-enum { NumUserAgentStringTypes = WinIE + 1 };
-
 #define NUM_LOCATION_CHANGE_DELEGATE_SELECTORS	10
 
 typedef struct _WebResourceDelegateImplementationCache {
@@ -58,8 +55,8 @@ extern NSString *_WebMainFrameURLKey;
     float textSizeMultiplier;
 
     NSString *applicationNameForUserAgent;
-    NSString *userAgentOverride;
-    NSString *userAgent[NumUserAgentStringTypes];
+    NSString *userAgent;
+    BOOL userAgentOverridden;
     
     BOOL defersCallbacks;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list