Changeset 85056 in webkit
- Timestamp:
- Apr 27, 2011 9:22:48 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r85054 r85056 1 2011-04-27 Darin Adler <darin@apple.com> 2 3 Reviewed by Sam Weinig. 4 5 Somehow about:blank gets into the icon database 6 https://bugs.webkit.org/show_bug.cgi?id=58067 7 rdar://problem/6751446 8 9 Implemented the policy Brady suggested, where only http and https URLs can 10 be associated with and icon, guarding both on the way in to the database, 11 and on the way out. 12 13 * loader/icon/IconDatabase.cpp: 14 (WebCore::pageCanHaveIcon): Added. 15 (WebCore::IconDatabase::synchronousIconForPageURL): Call pageCanHaveIcon 16 instead of just checking for an empty URL. 17 (WebCore::IconDatabase::synchronousIconURLForPageURL): Ditto. 18 (WebCore::IconDatabase::retainIconForPageURL): Ditto. 19 (WebCore::IconDatabase::releaseIconForPageURL): Ditto. 20 (WebCore::IconDatabase::setIconURLForPageURL): Ditto. 21 (WebCore::IconDatabase::getOrCreatePageURLRecord): Ditto. 22 (WebCore::IconDatabase::importIconURLForPageURL): Broke assertion into 23 two separate assertions and added a third. 24 (WebCore::IconDatabase::performURLImport): Call pageCanHaveIcon. 25 26 * platform/KURL.cpp: Sorted includes. Moved a FIXME to the top of the file. 27 (WebCore::isLetterMatchIgnoringCase): Renamed matchLetter to this name, 28 overloaded it to work on both UChar and char, and added an assertion to it. 29 Also moved this to the top of the file and made the UChar version usable 30 in the shared code used even by Google. 31 (WebCore::KURL::invalidate): Updated for name change. 32 (WebCore::KURL::protocolIs): Use isLetterMatchIgnoringCase instead of 33 toASCIILower since it's faster. 34 (WebCore::KURL::parse): Updated for name changes. 35 (WebCore::protocolIs):Use isLetterMatchIgnoringCase instead of toASCIILower 36 since it's faster. 37 (WebCore::protocolIsInHTTPFamily): Added. 38 39 * platform/KURL.h: Tweaked formatting. Renamed protocolInHTTPFamily 40 to protocolIsInHTTPFamily and added a version that works on a string. 41 Kept the old name as an inline function so we don't have to rename 42 all the cal sites now. 43 44 * platform/KURLGoogle.cpp: Renamed as above. 45 (WebCore::KURLGooglePrivate::KURLGooglePrivate): Updated for rename. 46 (WebCore::KURLGooglePrivate::setUtf8): Ditto. 47 (WebCore::KURLGooglePrivate::setAscii): Ditto. 48 (WebCore::KURLGooglePrivate::initProtocolIsInHTTPFamily): Ditto. 49 (WebCore::KURLGooglePrivate::copyTo): Ditto. 50 (WebCore::KURL::KURL): Ditto. 51 (WebCore::KURL::protocolIsInHTTPFamily): Ditto. 52 (WebCore::KURL::invalidate): Ditto. 53 * platform/KURLGooglePrivate.h: Ditto. 54 55 * WebCore.exp.in: Updated for above changes. 56 1 57 2011-04-27 Yury Semikhatsky <yurys@chromium.org> 2 58 -
trunk/Source/WebCore/WebCore.exp.in
r85036 r85056 1191 1191 __ZNK7WebCore4Font5widthERKNS_7TextRunEPN3WTF7HashSetIPKNS_14SimpleFontDataENS4_7PtrHashIS8_EENS4_10HashTraitsIS8_EEEEPNS_13GlyphOverflowE 1192 1192 __ZNK7WebCore4Font8drawTextEPNS_15GraphicsContextERKNS_7TextRunERKNS_10FloatPointEii 1193 __ZNK7WebCore4KURL10protocolIsEPKc 1193 1194 __ZNK7WebCore4KURL11createCFURLEv 1194 1195 __ZNK7WebCore4KURL11isLocalFileEv … … 1602 1603 __ZN7WebCore17HTMLPlugInElement11getNPObjectEv 1603 1604 __ZNK7WebCore14SecurityOrigin9canAccessEPKS0_ 1604 __ZNK7WebCore4KURL10protocolIsEPKc1605 1605 __ZNK7WebCore4KURL7hasPathEv 1606 1606 __ZNK7WebCore4KURL9prettyURLEv -
trunk/Source/WebCore/loader/icon/IconDatabase.cpp
r84801 r85056 100 100 } 101 101 102 static inline bool pageCanHaveIcon(const String& pageURL) 103 { 104 return protocolIsInHTTPFamily(pageURL); 105 } 106 102 107 // ************************ 103 108 // *** Main Thread Only *** … … 219 224 // We should go our of our way to only copy it if we have to store it 220 225 221 if (!isOpen() || pageURLOriginal.isEmpty())226 if (!isOpen() || !pageCanHaveIcon(pageURLOriginal)) 222 227 return defaultIcon(size); 223 228 … … 306 311 // Also, in the case we have a real answer for the caller, we must deep copy that as well 307 312 308 if (!isOpen() || pageURLOriginal.isEmpty())313 if (!isOpen() || !pageCanHaveIcon(pageURLOriginal)) 309 314 return String(); 310 315 … … 396 401 // Cannot do anything with pageURLOriginal that would end up storing it without deep copying first 397 402 398 if (!isEnabled() || pageURLOriginal.isEmpty())403 if (!isEnabled() || !pageCanHaveIcon(pageURLOriginal)) 399 404 return; 400 405 … … 440 445 // Cannot do anything with pageURLOriginal that would end up storing it without deep copying first 441 446 442 if (!isEnabled() || pageURLOriginal.isEmpty())447 if (!isEnabled() || !pageCanHaveIcon(pageURLOriginal)) 443 448 return; 444 449 … … 575 580 ASSERT(!iconURLOriginal.isEmpty()); 576 581 577 if (!isOpen() || pageURLOriginal.isEmpty())582 if (!isOpen() || !pageCanHaveIcon(pageURLOriginal)) 578 583 return; 579 584 … … 885 890 ASSERT(!m_urlAndIconLock.tryLock()); 886 891 887 if ( pageURL.isEmpty())892 if (!pageCanHaveIcon(pageURL)) 888 893 return 0; 889 894 … … 921 926 922 927 // This function is only for setting actual existing url mappings so assert that neither of these URLs are empty 923 ASSERT(!iconURL.isEmpty() && !pageURL.isEmpty()); 928 ASSERT(!iconURL.isEmpty()); 929 ASSERT(!pageURL.isEmpty()); 930 ASSERT(pageCanHaveIcon(pageURL)); 924 931 925 932 setIconURLForPageURLInSQLDatabase(iconURL, pageURL); … … 1228 1235 // If database cleanup *is* allowed, we don't want to bother pulling in a page url from disk that noone is actually interested 1229 1236 // in - we'll prune it later instead! 1230 if (!pageRecord && databaseCleanupCounter && !pageURL.isEmpty()) {1237 if (!pageRecord && databaseCleanupCounter && pageCanHaveIcon(pageURL)) { 1231 1238 pageRecord = new PageURLRecord(pageURL); 1232 1239 m_pageURLToRecordMap.set(pageURL, pageRecord); -
trunk/Source/WebCore/platform/KURL.cpp
r84762 r85056 1 1 /* 2 * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2004, 2007, 2008, 2011 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 #include "config.h" 27 28 27 #include "KURL.h" 29 28 30 29 #include "TextEncoding.h" 31 #include < wtf/text/CString.h>30 #include <stdio.h> 32 31 #include <wtf/HashMap.h> 33 32 #include <wtf/HexNumber.h> 34 33 #include <wtf/StdLibExtras.h> 34 #include <wtf/text/CString.h> 35 35 #include <wtf/text/StringHash.h> 36 36 … … 44 44 #endif 45 45 46 #include <stdio.h> 46 // FIXME: This file makes too much use of the + operator on String. 47 // We either have to optimize that operator so it doesn't involve 48 // so many allocations, or change this to use StringBuffer instead. 47 49 48 50 using namespace std; … … 57 59 static const unsigned invalidPortNumber = 0xFFFF; 58 60 61 static inline bool isLetterMatchIgnoringCase(UChar character, char lowercaseLetter) 62 { 63 ASSERT(isASCIILower(lowercaseLetter)); 64 return (character | 0x20) == lowercaseLetter; 65 } 66 59 67 #if !USE(GOOGLEURL) 60 68 61 // FIXME: This file makes too much use of the + operator on String. 62 // We either have to optimize that operator so it doesn't involve 63 // so many allocations, or change this to use Vector<UChar> instead. 69 static inline bool isLetterMatchIgnoringCase(char character, char lowercaseLetter) 70 { 71 ASSERT(isASCIILower(lowercaseLetter)); 72 return (character | 0x20) == lowercaseLetter; 73 } 64 74 65 75 enum URLCharacterClasses { … … 296 306 { 297 307 m_isValid = false; 298 m_protocolI nHTTPFamily = false;308 m_protocolIsInHTTPFamily = false; 299 309 m_schemeEnd = 0; 300 310 m_userStart = 0; … … 693 703 // Do the comparison without making a new string object. 694 704 for (int i = 0; i < m_schemeEnd; ++i) { 695 if (!protocol[i] || toASCIILower(m_string[i]) != protocol[i])705 if (!protocol[i] || !isLetterMatchIgnoringCase(m_string[i], protocol[i])) 696 706 return false; 697 707 } … … 1086 1096 } 1087 1097 1088 static inline bool matchLetter(char c, char lowercaseLetter)1089 {1090 return (c | 0x20) == lowercaseLetter;1091 }1092 1093 1098 void KURL::parse(const String& string) 1094 1099 { … … 1194 1199 1195 1200 bool isFile = schemeEnd == 4 1196 && matchLetter(url[0], 'f')1197 && matchLetter(url[1], 'i')1198 && matchLetter(url[2], 'l')1199 && matchLetter(url[3], 'e');1200 1201 m_protocolI nHTTPFamily = matchLetter(url[0], 'h')1202 && matchLetter(url[1], 't')1203 && matchLetter(url[2], 't')1204 && matchLetter(url[3], 'p')1205 && (url[4] == ':' || ( matchLetter(url[4], 's') && url[5] == ':'));1201 && isLetterMatchIgnoringCase(url[0], 'f') 1202 && isLetterMatchIgnoringCase(url[1], 'i') 1203 && isLetterMatchIgnoringCase(url[2], 'l') 1204 && isLetterMatchIgnoringCase(url[3], 'e'); 1205 1206 m_protocolIsInHTTPFamily = isLetterMatchIgnoringCase(url[0], 'h') 1207 && isLetterMatchIgnoringCase(url[1], 't') 1208 && isLetterMatchIgnoringCase(url[2], 't') 1209 && isLetterMatchIgnoringCase(url[3], 'p') 1210 && (url[4] == ':' || (isLetterMatchIgnoringCase(url[4], 's') && url[5] == ':')); 1206 1211 1207 1212 if ((hierarchical && hasSecondSlash) || isNonFileHierarchicalScheme(url, schemeEnd)) { … … 1290 1295 } 1291 1296 1292 if (userStart == portEnd && !m_protocolI nHTTPFamily && !isFile) {1297 if (userStart == portEnd && !m_protocolIsInHTTPFamily && !isFile) { 1293 1298 // No authority found, which means that this is not a net_path, but rather an abs_path whose first two 1294 1299 // path segments are empty. For file, http and https only, an empty authority is allowed. … … 1345 1350 1346 1351 bool hostIsLocalHost = portEnd - userStart == 9 1347 && matchLetter(url[userStart], 'l')1348 && matchLetter(url[userStart+1], 'o')1349 && matchLetter(url[userStart+2], 'c')1350 && matchLetter(url[userStart+3], 'a')1351 && matchLetter(url[userStart+4], 'l')1352 && matchLetter(url[userStart+5], 'h')1353 && matchLetter(url[userStart+6], 'o')1354 && matchLetter(url[userStart+7], 's')1355 && matchLetter(url[userStart+8], 't');1352 && isLetterMatchIgnoringCase(url[userStart], 'l') 1353 && isLetterMatchIgnoringCase(url[userStart+1], 'o') 1354 && isLetterMatchIgnoringCase(url[userStart+2], 'c') 1355 && isLetterMatchIgnoringCase(url[userStart+3], 'a') 1356 && isLetterMatchIgnoringCase(url[userStart+4], 'l') 1357 && isLetterMatchIgnoringCase(url[userStart+5], 'h') 1358 && isLetterMatchIgnoringCase(url[userStart+6], 'o') 1359 && isLetterMatchIgnoringCase(url[userStart+7], 's') 1360 && isLetterMatchIgnoringCase(url[userStart+8], 't'); 1356 1361 1357 1362 // File URLs need a host part unless it is just file:// or file://localhost … … 1417 1422 // For canonicalization, ensure we have a '/' for no path. 1418 1423 // Do this only for URL with protocol http or https. 1419 if (m_protocolI nHTTPFamily && pathEnd == pathStart)1424 if (m_protocolIsInHTTPFamily && pathEnd == pathStart) 1420 1425 *p++ = '/'; 1421 1426 … … 1774 1779 if (!protocol[i]) 1775 1780 return url[i] == ':'; 1776 if ( toASCIILower(url[i]) != protocol[i])1781 if (!isLetterMatchIgnoringCase(url[i], protocol[i])) 1777 1782 return false; 1778 1783 } … … 1966 1971 } 1967 1972 1968 } 1973 bool protocolIsInHTTPFamily(const String& url) 1974 { 1975 unsigned length = url.length(); 1976 const UChar* characters = url.characters(); 1977 return length > 4 1978 && isLetterMatchIgnoringCase(characters[0], 'h') 1979 && isLetterMatchIgnoringCase(characters[1], 't') 1980 && isLetterMatchIgnoringCase(characters[2], 't') 1981 && isLetterMatchIgnoringCase(characters[3], 'p') 1982 && (characters[4] == ':' 1983 || (isLetterMatchIgnoringCase(characters[4], 's') && length > 5 && characters[5] == ':')); 1984 } 1985 1986 } -
trunk/Source/WebCore/platform/KURL.h
r83671 r85056 1 1 /* 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2011 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 94 94 KURL(const KURL& base, const String& relative, const TextEncoding&); 95 95 96 97 #if USE(GOOGLEURL) 98 // For conversions for other structures that have already parsed and 96 #if USE(GOOGLEURL) 97 // For conversions from other structures that have already parsed and 99 98 // canonicalized the URL. The input must be exactly what KURL would have 100 99 // done with the same input. 101 KURL(const CString& canonicalSpec, 102 const url_parse::Parsed& parsed, bool isValid); 100 KURL(const CString& canonicalSpec, const url_parse::Parsed&, bool isValid); 103 101 #endif 104 102 … … 160 158 bool protocolIs(const char*) const; 161 159 bool protocolIsData() const { return protocolIs("data"); } 162 bool protocolI nHTTPFamily() const;160 bool protocolIsInHTTPFamily() const; 163 161 bool isLocalFile() const; 164 162 … … 197 195 unsigned pathEnd() const; 198 196 unsigned pathAfterLastSlash() const; 197 199 198 operator const String&() const { return string(); } 200 199 … … 226 225 void print() const; 227 226 #endif 227 228 // FIXME: Remove this after changing all callers to use protocolIsInHTTPFamily. 229 bool protocolInHTTPFamily() const { return protocolIsInHTTPFamily(); } 228 230 229 231 private: … … 248 250 String m_string; 249 251 bool m_isValid : 1; 250 bool m_protocolI nHTTPFamily : 1;252 bool m_protocolIsInHTTPFamily : 1; 251 253 252 254 int m_schemeEnd; … … 281 283 282 284 bool protocolIs(const String& url, const char* protocol); 285 bool protocolIsInHTTPFamily(const String& url); 283 286 bool protocolIsJavaScript(const String& url); 284 287 … … 355 358 } 356 359 357 inline bool KURL::protocolI nHTTPFamily() const358 { 359 return m_protocolI nHTTPFamily;360 inline bool KURL::protocolIsInHTTPFamily() const 361 { 362 return m_protocolIsInHTTPFamily; 360 363 } 361 364 -
trunk/Source/WebCore/platform/KURLGoogle.cpp
r83671 r85056 155 155 KURLGooglePrivate::KURLGooglePrivate() 156 156 : m_isValid(false) 157 , m_protocolI nHTTPFamily(false)157 , m_protocolIsInHTTPFamily(false) 158 158 , m_utf8IsASCII(true) 159 159 , m_stringIsValid(false) … … 163 163 KURLGooglePrivate::KURLGooglePrivate(const url_parse::Parsed& parsed, bool isValid) 164 164 : m_isValid(isValid) 165 , m_protocolI nHTTPFamily(false)165 , m_protocolIsInHTTPFamily(false) 166 166 , m_parsed(parsed) 167 167 , m_utf8IsASCII(true) … … 197 197 m_utf8 = str; 198 198 m_stringIsValid = false; 199 initProtocolI nHTTPFamily();199 initProtocolIsInHTTPFamily(); 200 200 } 201 201 … … 205 205 m_utf8IsASCII = true; 206 206 m_stringIsValid = false; 207 initProtocolI nHTTPFamily();207 initProtocolIsInHTTPFamily(); 208 208 } 209 209 … … 259 259 } 260 260 261 void KURLGooglePrivate::initProtocolI nHTTPFamily()261 void KURLGooglePrivate::initProtocolIsInHTTPFamily() 262 262 { 263 263 if (!m_isValid) { 264 m_protocolI nHTTPFamily = false;264 m_protocolIsInHTTPFamily = false; 265 265 return; 266 266 } … … 268 268 const char* scheme = m_utf8.data() + m_parsed.scheme.begin; 269 269 if (m_parsed.scheme.len == 4) 270 m_protocolI nHTTPFamily = lowerCaseEqualsASCII(scheme, scheme + 4, "http");270 m_protocolIsInHTTPFamily = lowerCaseEqualsASCII(scheme, scheme + 4, "http"); 271 271 else if (m_parsed.scheme.len == 5) 272 m_protocolI nHTTPFamily = lowerCaseEqualsASCII(scheme, scheme + 5, "https");272 m_protocolIsInHTTPFamily = lowerCaseEqualsASCII(scheme, scheme + 5, "https"); 273 273 else 274 m_protocolI nHTTPFamily = false;274 m_protocolIsInHTTPFamily = false; 275 275 } 276 276 … … 278 278 { 279 279 dest->m_isValid = m_isValid; 280 dest->m_protocolI nHTTPFamily = m_protocolInHTTPFamily;280 dest->m_protocolIsInHTTPFamily = m_protocolIsInHTTPFamily; 281 281 dest->m_parsed = m_parsed; 282 282 … … 371 371 // empty string, which is what init() will create. 372 372 m_url.m_isValid = false; 373 m_url.m_protocolI nHTTPFamily = false;373 m_url.m_protocolIsInHTTPFamily = false; 374 374 } 375 375 } … … 444 444 } 445 445 446 bool KURL::protocolI nHTTPFamily() const447 { 448 return m_url.m_protocolI nHTTPFamily;446 bool KURL::protocolIsInHTTPFamily() const 447 { 448 return m_url.m_protocolIsInHTTPFamily; 449 449 } 450 450 … … 884 884 // initialized) string and parsed structure would be a waste of time. 885 885 m_url.m_isValid = false; 886 m_url.m_protocolI nHTTPFamily = false;886 m_url.m_protocolIsInHTTPFamily = false; 887 887 } 888 888 -
trunk/Source/WebCore/platform/KURLGooglePrivate.h
r83671 r85056 92 92 93 93 bool m_isValid; 94 bool m_protocolI nHTTPFamily;94 bool m_protocolIsInHTTPFamily; 95 95 url_parse::Parsed m_parsed; // Indexes into the UTF-8 version of the string. 96 96 97 97 private: 98 void initProtocolI nHTTPFamily();98 void initProtocolIsInHTTPFamily(); 99 99 100 100 CString m_utf8;
Note: See TracChangeset
for help on using the changeset viewer.