Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 4905ec5f9240c6826dca52cfea2ae496fbb7b8b3
      
https://github.com/WebKit/WebKit/commit/4905ec5f9240c6826dca52cfea2ae496fbb7b8b3
  Author: Sihui Liu <[email protected]>
  Date:   2025-10-17 (Fri, 17 Oct 2025)

  Changed paths:
    A LayoutTests/storage/indexeddb/database-name-with-surrogates-expected.txt
    A 
LayoutTests/storage/indexeddb/database-name-with-surrogates-private-expected.txt
    A LayoutTests/storage/indexeddb/database-name-with-surrogates-private.html
    A LayoutTests/storage/indexeddb/database-name-with-surrogates.html
    A LayoutTests/storage/indexeddb/resources/database-name-with-surrogates.js
    M Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
    M Source/WebKit/NetworkProcess/storage/IDBStorageManager.cpp
    M Source/WebKit/NetworkProcess/storage/IDBStorageManager.h
    M Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp

  Log Message:
  -----------
  IndexedDB should properly handle names containing unpaired UTF-16 surrogates
https://bugs.webkit.org/show_bug.cgi?id=300902
rdar://161082712

Reviewed by Chris Dumez.

SQLiteIDBBackingStore currently uses UTF-8 encoding for database name. UTF-8 is 
designed to encode valid Unicode code
points, and invalid code points like lone UTF-16 surrogate (e.g. U+D9B2) will 
be replaced with special bytes. According
to spec, database name is DOMString, which can contain unpaired UTF-16 
surrogates. This means the database name stored
in database (with UTF-8 encoding) can be different from database name created 
from JavaScript.

To preserve the exact UTF-16 data, now we make SQLiteIDBBackingStore store 
database name as blob instead of text. As
SQLite has dynamic typing, we don't need to change schema for this. For 
existing databases, we upgrade its metadata
version and database name on open, if the stored UTF-8 encoded name matches 
UTF-8 encoded requested name.

The patch also includes a change to close IndexedDB SQLite database connection 
when it becomes idle (no more client and
no in-memory data). This would help avoid resource leakage (fd, memory, etc), 
and it allows us to test re-open behavior
(with IDBDatabase.close) in the new tests.

Tests: storage/indexeddb/database-name-with-surrogates-private.html
       storage/indexeddb/database-name-with-surrogates.html

* LayoutTests/storage/indexeddb/database-name-with-surrogates-expected.txt: 
Added.
* 
LayoutTests/storage/indexeddb/database-name-with-surrogates-private-expected.txt:
 Added.
* LayoutTests/storage/indexeddb/database-name-with-surrogates-private.html: 
Added.
* LayoutTests/storage/indexeddb/database-name-with-surrogates.html: Added.
* LayoutTests/storage/indexeddb/resources/database-name-with-surrogates.js: 
Added.
(test.request2.onsuccess):
(test.request.onsuccess):
(test):
(testIDBFactoryDatabases):
* Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::createAndPopulateInitialDatabaseInfo):
(WebCore::IDBServer::getDatabaseNameFromDatabase):
(WebCore::IDBServer::migrateIDBDatabaseInfoTableIfNecessary):
(WebCore::IDBServer::SQLiteIDBBackingStore::extractExistingDatabaseInfo):
(WebCore::IDBServer::SQLiteIDBBackingStore::databaseNameAndVersionFromFile):
* Source/WebKit/NetworkProcess/storage/IDBStorageManager.cpp:
(WebKit::IDBStorageManager::tryCloseDatabase):
* Source/WebKit/NetworkProcess/storage/IDBStorageManager.h:
* Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp:
(WebKit::NetworkStorageManager::databaseConnectionClosed):

Canonical link: https://commits.webkit.org/301753@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to