⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 184020 in webkit


Ignore:
Timestamp:
May 8, 2015, 3:56:33 PM (11 years ago)
Author:
bshafiei@apple.com
Message:

Merged r183646. rdar://problem/20840031

Location:
branches/safari-600.1.4.16-branch
Files:
5 edited
3 copied

Legend:

Unmodified
Added
Removed
  • branches/safari-600.1.4.16-branch/LayoutTests/ChangeLog

    r183519 r184020  
     12015-05-08  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Merge r183646.
     4
     5    2015-04-30  Brady Eidson  <beidson@apple.com>
     6
     7            Javascript using WebSQL can create their own WebKit info table.
     8            <rdar://problem/20688792> and https://bugs.webkit.org/show_bug.cgi?id=144466
     9
     10            Reviewed by Alex Christensen.
     11
     12            * storage/websql/alter-to-info-table-expected.txt: Added.
     13            * storage/websql/alter-to-info-table.html: Added.
     14            * storage/websql/alter-to-info-table.js: Added.
     15
    1162015-04-28  Babak Shafiei  <bshafiei@apple.com>
    217
  • branches/safari-600.1.4.16-branch/LayoutTests/storage/websql/test-authorizer-expected.txt

    r117816 r184020  
    1616SQLITE_ALTER_TABLE statement succeeded.
    1717SQLITE_ALTER_TABLE statement succeeded.
     18SQLITE_ALTER_INFO_TABLE statement failed: could not prepare statement (23 not authorized)
     19SQLITE_ALTER_INFO_TABLE statement failed: could not prepare statement (23 not authorized)
     20SQLITE_ALTER_INFO_TABLE statement failed: could not prepare statement (1 there is already another table or index with this name: __WebKitDatabaseInfoTable__)
    1821SQLITE_TRANSACTION statement failed: could not prepare statement (23 not authorized)
    1922SQLITE_ATTACH statement failed: could not prepare statement (23 not authorized)
     
    5356SQLITE_ALTER_TABLE statement failed: could not prepare statement (23 not authorized)
    5457SQLITE_ALTER_TABLE statement failed: could not prepare statement (1 no such table: TestTable)
     58SQLITE_ALTER_INFO_TABLE statement failed: could not prepare statement (23 not authorized)
     59SQLITE_ALTER_INFO_TABLE statement failed: could not prepare statement (23 not authorized)
     60SQLITE_ALTER_INFO_TABLE statement failed: could not prepare statement (1 there is already another table or index with this name: __WebKitDatabaseInfoTable__)
    5561SQLITE_TRANSACTION statement failed: could not prepare statement (23 not authorized)
    5662SQLITE_ATTACH statement failed: could not prepare statement (23 not authorized)
  • branches/safari-600.1.4.16-branch/LayoutTests/storage/websql/test-authorizer.js

    r120516 r184020  
    7373    // Rename the table back to its original name
    7474    executeStatement(tx, "ALTER TABLE TestTable RENAME To Test;", "SQLITE_ALTER_TABLE");
     75
     76    // These should always fail, as nobody gets to mess with the info table.
     77    executeStatement(tx, "ALTER TABLE __WebKitDatabaseInfoTable__ RENAME TO TestTable;", "SQLITE_ALTER_INFO_TABLE");
     78    executeStatement(tx, "ALTER TABLE main.__WebKitDatabaseInfoTable__ RENAME TO TestTable;", "SQLITE_ALTER_INFO_TABLE");
     79    executeStatement(tx, "ALTER TABLE Test RENAME TO __WebKitDatabaseInfoTable__;", "SQLITE_ALTER_INFO_TABLE");
    7580
    7681    executeStatement(tx, "BEGIN TRANSACTION;", "SQLITE_TRANSACTION");
  • branches/safari-600.1.4.16-branch/Source/WebCore/ChangeLog

    r183519 r184020  
     12015-05-08  Babak Shafiei  <bshafiei@apple.com>
     2
     3        Merge r183646.
     4
     5    2015-04-30  Brady Eidson  <beidson@apple.com>
     6
     7            Javascript using WebSQL can create their own WebKit info table.
     8            <rdar://problem/20688792> and https://bugs.webkit.org/show_bug.cgi?id=144466
     9
     10            Reviewed by Alex Christensen.
     11
     12            Test: storage/websql/alter-to-info-table.html
     13
     14            * Modules/webdatabase/DatabaseBackendBase.cpp:
     15            (WebCore::DatabaseBackendBase::databaseInfoTableName): Return the info table name.
     16            (WebCore::fullyQualifiedInfoTableName): Append "main." to the info table name.
     17            (WebCore::DatabaseBackendBase::DatabaseBackendBase): Use the fully qualified name.
     18            (WebCore::DatabaseBackendBase::performOpenAndVerify): Ditto.
     19            (WebCore::DatabaseBackendBase::getVersionFromDatabase): Ditto.
     20            (WebCore::DatabaseBackendBase::setVersionInDatabase): Ditto.
     21
    1222015-04-28  Babak Shafiei  <bshafiei@apple.com>
    223
  • branches/safari-600.1.4.16-branch/Source/WebCore/Modules/webdatabase/DatabaseBackendBase.cpp

    r169518 r184020  
    8686
    8787static const char versionKey[] = "WebKitDatabaseVersionKey";
    88 static const char infoTableName[] = "__WebKitDatabaseInfoTable__";
     88static const char unqualifiedInfoTableName[] = "__WebKitDatabaseInfoTable__";
     89
     90const char* DatabaseBackendBase::databaseInfoTableName()
     91{
     92    return unqualifiedInfoTableName;
     93}
     94
     95static const char* fullyQualifiedInfoTableName()
     96{
     97    static const char qualifier[] = "main.";
     98    static char qualifiedName[sizeof(qualifier) + sizeof(unqualifiedInfoTableName) - 1];
     99
     100    static std::once_flag onceFlag;
     101    std::call_once(onceFlag, []{
     102        char* newDestination = stpcpy(qualifiedName, qualifier);
     103        strcpy(newDestination, unqualifiedInfoTableName);
     104    });
     105
     106    return qualifiedName;
     107}
    89108
    90109static String formatErrorMessage(const char* message, int sqliteErrorCode, const char* sqliteErrorMessage)
     
    193212
    194213    return guid;
    195 }
    196 
    197 // static
    198 const char* DatabaseBackendBase::databaseInfoTableName()
    199 {
    200     return infoTableName;
    201214}
    202215
     
    221234    m_contextThreadSecurityOrigin = m_databaseContext->securityOrigin()->isolatedCopy();
    222235
    223     m_databaseAuthorizer = DatabaseAuthorizer::create(infoTableName);
     236    m_databaseAuthorizer = DatabaseAuthorizer::create(unqualifiedInfoTableName);
    224237
    225238    if (m_name.isNull())
     
    351364            }
    352365
    353             String tableName(infoTableName);
     366            String tableName(unqualifiedInfoTableName);
    354367            if (!m_sqliteDatabase.tableExists(tableName)) {
    355368                m_new = true;
     
    450463bool DatabaseBackendBase::getVersionFromDatabase(String& version, bool shouldCacheVersion)
    451464{
    452     String query(String("SELECT value FROM ") + infoTableName +  " WHERE key = '" + versionKey + "';");
     465    String query(String("SELECT value FROM ") + fullyQualifiedInfoTableName() +  " WHERE key = '" + versionKey + "';");
    453466
    454467    m_databaseAuthorizer->disable();
     
    470483    // The INSERT will replace an existing entry for the database with the new version number, due to the UNIQUE ON CONFLICT REPLACE
    471484    // clause in the CREATE statement (see Database::performOpenAndVerify()).
    472     String query(String("INSERT INTO ") + infoTableName +  " (key, value) VALUES ('" + versionKey + "', ?);");
     485    String query(String("INSERT INTO ") + fullyQualifiedInfoTableName() +  " (key, value) VALUES ('" + versionKey + "', ?);");
    473486
    474487    m_databaseAuthorizer->disable();
Note: See TracChangeset for help on using the changeset viewer.