[4.17.0] Restore of message with embedded quote crashes
Hi,
I just did a backup with 4.17.0 on one phone, trying to import it to the other one. (You need to have the backup before starting Signal the first time, though—just delaying registering doesn't help, which is confusing.)
Signal promptly crashed. It turned out (from adb logcat) that it fails to escape messages correctly in SQL:
03-09 23:30:45.901 2986 3441 E AndroidRuntime: FATAL EXCEPTION: AsyncTask #5
03-09 23:30:45.901 2986 3441 E AndroidRuntime: Process: org.thoughtcrime.securesms, PID: 2986
03-09 23:30:45.901 2986 3441 E AndroidRuntime: java.lang.RuntimeException: An error occurred while executing doInBackground()
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at android.os.AsyncTask$3.done(AsyncTask.java:353)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:271)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at java.lang.Thread.run(Thread.java:764)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: Caused by: net.sqlcipher.database.SQLiteException: near "nye": syntax error: INSERT INTO sms VALUES (19,2,'<censored>',1,NULL,1454911174668,1454911174668,NULL,1,-1,23,NULL,0,NULL,'<censored>',NULL,NULL,-1,0,0,0,0)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at net.sqlcipher.database.SQLiteDatabase.native_execSQL(Native Method)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at net.sqlcipher.database.SQLiteDatabase.execSQL(SQLiteDatabase.java:2265)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at org.thoughtcrime.securesms.backup.FullBackupImporter.processStatement(FullBackupImporter.java:85)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at org.thoughtcrime.securesms.backup.FullBackupImporter.importFile(FullBackupImporter.java:67)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at org.thoughtcrime.securesms.RegistrationActivity$2.doInBackground(RegistrationActivity.java:367)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at org.thoughtcrime.securesms.RegistrationActivity$2.doInBackground(RegistrationActivity.java:359)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at android.os.AsyncTask$2.call(AsyncTask.java:333)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
03-09 23:30:45.901 2986 3441 E AndroidRuntime: ... 4 more
I've censored the message itself, but it contained the string “SAS' nye”, so it is reasonable to believe that the problem is the embedded quote.
duplicate #7478 thanks
FWIW: There was an update from Play Store today, but the exact same problem remains. I'll just assume the commit didn't make this one.
The fix is in creating the backup, not restoring it. So old backups still won't restore, but newly created ones will.
I took a new backup and tried to restore it, but alas:
03-11 01:07:08.325 24981 25167 E AndroidRuntime: Caused by: net.sqlcipher.database.SQLiteException: near "nye": syntax error: INSERT INTO sms VALUES (19,2,'<censored>',1,NULL,1454911174668,1454911174668,NULL,1,-1,23,NULL,0,NULL,'<censored> SAS\' nye <censored>',NULL,NULL,-1,0,0,0,0)
Seemingly the correct way to escape a quote in SQLite is to double it, not add a backslash.
I also just took a new backup with 4.17.1, attempted to restore with 4.17.1, and the same SQL exception with the quotes occurred.