Skip to content

Commit 3f98bb1

Browse files
committed
limit text to 524288 characters which is always < 2Mb with UTF-8
1 parent bf3cd76 commit 3f98bb1

File tree

1 file changed

+2
-1
lines changed
  • WordPressUtils/src/main/java/org/wordpress/android/util

1 file changed

+2
-1
lines changed

WordPressUtils/src/main/java/org/wordpress/android/util/SqlUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ public static boolean dropAllTables(SQLiteDatabase db) throws SQLiteException {
129129
* https://github.com/android/platform_frameworks_base/blob/b77bc869241644a662f7e615b0b00ecb5aee373d/core/res/res/values/config.xml#L1268
130130
* https://github.com/android/platform_frameworks_base/blob/3bdbf644d61f46b531838558fabbd5b990fc4913/core/java/android/database/CursorWindow.java#L103
131131
*/
132-
private static final int MAX_TEXT_LEN = 1024 * 1024;
132+
// Max 512K characters (a UTF-8 char is 4 bytes max, so a 512K characters string is always < 2Mb)
133+
private static final int MAX_TEXT_LEN = 1024 * 1024 / 2;
133134
public static String maxSQLiteText(final String text) {
134135
if (text.length() <= MAX_TEXT_LEN) {
135136
return text;

0 commit comments

Comments
 (0)