mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Enhance the sqlite3_create_function() interfaces to assume a value of
SQLITE_UTF8 is presented with a nonsense value for the preferred encoding. This is undocumented behavior added for robustness. FossilOrigin-Name: c1bb5cff527af6a97b025d646581c68ac9b56924ae199f86964026a7bc9724fd
This commit is contained in:
37
src/main.c
37
src/main.c
@@ -1854,22 +1854,33 @@ int sqlite3CreateFunc(
|
||||
** If SQLITE_ANY is specified, add three versions of the function
|
||||
** to the hash table.
|
||||
*/
|
||||
if( enc==SQLITE_UTF16 ){
|
||||
enc = SQLITE_UTF16NATIVE;
|
||||
}else if( enc==SQLITE_ANY ){
|
||||
int rc;
|
||||
rc = sqlite3CreateFunc(db, zFunctionName, nArg,
|
||||
(SQLITE_UTF8|extraFlags)^SQLITE_FUNC_UNSAFE,
|
||||
pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
|
||||
if( rc==SQLITE_OK ){
|
||||
switch( enc ){
|
||||
case SQLITE_UTF16:
|
||||
enc = SQLITE_UTF16NATIVE;
|
||||
break;
|
||||
case SQLITE_ANY: {
|
||||
int rc;
|
||||
rc = sqlite3CreateFunc(db, zFunctionName, nArg,
|
||||
(SQLITE_UTF16LE|extraFlags)^SQLITE_FUNC_UNSAFE,
|
||||
(SQLITE_UTF8|extraFlags)^SQLITE_FUNC_UNSAFE,
|
||||
pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
|
||||
if( rc==SQLITE_OK ){
|
||||
rc = sqlite3CreateFunc(db, zFunctionName, nArg,
|
||||
(SQLITE_UTF16LE|extraFlags)^SQLITE_FUNC_UNSAFE,
|
||||
pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
|
||||
}
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
}
|
||||
enc = SQLITE_UTF16BE;
|
||||
break;
|
||||
}
|
||||
if( rc!=SQLITE_OK ){
|
||||
return rc;
|
||||
}
|
||||
enc = SQLITE_UTF16BE;
|
||||
case SQLITE_UTF8:
|
||||
case SQLITE_UTF16LE:
|
||||
case SQLITE_UTF16BE:
|
||||
break;
|
||||
default:
|
||||
enc = SQLITE_UTF8;
|
||||
break;
|
||||
}
|
||||
#else
|
||||
enc = SQLITE_UTF8;
|
||||
|
Reference in New Issue
Block a user