| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 static const char separatorCharacter = '_'; | 46 static const char separatorCharacter = '_'; |
| 47 | 47 |
| 48 PassRefPtr<SecurityOrigin> createSecurityOriginFromDatabaseIdentifier(const Stri
ng& databaseIdentifier) | 48 PassRefPtr<SecurityOrigin> createSecurityOriginFromDatabaseIdentifier(const Stri
ng& databaseIdentifier) |
| 49 { | 49 { |
| 50 if (!databaseIdentifier.containsOnlyASCII()) | 50 if (!databaseIdentifier.containsOnlyASCII()) |
| 51 return SecurityOrigin::createUnique(); | 51 return SecurityOrigin::createUnique(); |
| 52 | 52 |
| 53 // Make sure there's a first separator | 53 // Make sure there's a first separator |
| 54 size_t separator1 = databaseIdentifier.find(separatorCharacter); | 54 size_t separator1 = databaseIdentifier.find(separatorCharacter); |
| 55 if (separator1 == notFound) | 55 if (separator1 == kNotFound) |
| 56 return SecurityOrigin::createUnique(); | 56 return SecurityOrigin::createUnique(); |
| 57 | 57 |
| 58 // Make sure there's a second separator | 58 // Make sure there's a second separator |
| 59 size_t separator2 = databaseIdentifier.reverseFind(separatorCharacter); | 59 size_t separator2 = databaseIdentifier.reverseFind(separatorCharacter); |
| 60 if (separator2 == notFound) | 60 if (separator2 == kNotFound) |
| 61 return SecurityOrigin::createUnique(); | 61 return SecurityOrigin::createUnique(); |
| 62 | 62 |
| 63 // Ensure there were at least 2 separator characters. Some hostnames on intr
anets have | 63 // Ensure there were at least 2 separator characters. Some hostnames on intr
anets have |
| 64 // underscores in them, so we'll assume that any additional underscores are
part of the host. | 64 // underscores in them, so we'll assume that any additional underscores are
part of the host. |
| 65 if (separator1 == separator2) | 65 if (separator1 == separator2) |
| 66 return SecurityOrigin::createUnique(); | 66 return SecurityOrigin::createUnique(); |
| 67 | 67 |
| 68 // Make sure the port section is a valid port number or doesn't exist | 68 // Make sure the port section is a valid port number or doesn't exist |
| 69 bool portOkay; | 69 bool portOkay; |
| 70 int port = databaseIdentifier.right(databaseIdentifier.length() - separator2
- 1).toInt(&portOkay); | 70 int port = databaseIdentifier.right(databaseIdentifier.length() - separator2
- 1).toInt(&portOkay); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 96 // to avoid breaking existing persistent state. | 96 // to avoid breaking existing persistent state. |
| 97 if (securityOrigin->needsDatabaseIdentifierQuirkForFiles()) | 97 if (securityOrigin->needsDatabaseIdentifierQuirkForFiles()) |
| 98 return "file__0"; | 98 return "file__0"; |
| 99 | 99 |
| 100 String separatorString(&separatorCharacter, 1); | 100 String separatorString(&separatorCharacter, 1); |
| 101 | 101 |
| 102 return securityOrigin->protocol() + separatorString + securityOrigin->host()
+ separatorString + String::number(securityOrigin->port()); | 102 return securityOrigin->protocol() + separatorString + securityOrigin->host()
+ separatorString + String::number(securityOrigin->port()); |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace WebCore | 105 } // namespace WebCore |
| OLD | NEW |