| Summary: | Null character causes early string termination in Web SQL | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Nolan Lawson <nolan> | ||||
| Component: | WebCore Misc. | Assignee: | Nobody <webkit-unassigned> | ||||
| Status: | RESOLVED WONTFIX | ||||||
| Severity: | Normal | CC: | aaron.oneal, ap, beidson, bfulgham, dbates, simon.fraser, webkit-bug-importer | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | 528+ (Nightly build) | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Attachments: |
|
||||||
|
Description
Nolan Lawson
2014-10-11 11:06:30 PDT
Created attachment 239681 [details]
Test case in pure HTML
This same issue is in the Cordova Web SQL plugin.
The problem has to do with how SQLITE_TEXT columns in statement results are converted to strings.
This will repro the bug:
columnValue = [NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, i)];
Whereas this returns the correct full-length string:
columnValue = [[NSString alloc] initWithBytes:(char *)sqlite3_column_text(statement, i)
length:sqlite3_column_bytes(statement, i)
encoding:NSUTF8StringEncoding];
The former uses '\0' to determine string termination whereas the latter uses the specified buffer length.
I'll submit a fix for the Cordova plugin.
The WebKit issue is in WebCore/SQLiteStatement.cpp:
http://www.opensource.apple.com/source/WebCore/WebCore-332/platform/sql/SQLiteStatement.cpp
The getColumnValue() and getColumnText() functions rely on the standard String constructor:
return String(reinterpret_cast<const UChar*>(sqlite3_column_text16(m_statement, col)));
There is a String constructor that accepts a length, so a similar fix can probably be applied.
http://www.opensource.apple.com/source/WebCore/WebCore-332/platform/text/PlatformString.h
Note: WebSQL has been disabled in our modern WebKit for some time, and is only still available as a backwards-compatibility affordance for very old legacy WebKit clients. I'm going to close this as WONT FIX since this feature is long-deprecated, and is no longer available in modern Web Browsing contexts. |