Description
The application crashes with a java.lang.NumberFormatException when a user enters non-numeric text into a preference field that expects a float value. This occurs because the input is not validated before the application attempts to parse it.
Environment
App Version: 10.11.7
Device: x86 Android Emulator
Android Version: 9.0 (API 28) / 6.0 (Reproducible across versions)
Testing Method: Automated testing
Steps to Reproduce
1.Open AnyMemo and go to Options -> Customize scheduling algorithm.
2.Click on any setting that requires a numeric value, such as "Grade 0" (The interval when you first grade a card).
3.In the input dialog, delete the number.
4.Click OK.
5.The application crashes immediately.
The logcat is as follows
03-19 19:01:44.781 3768 3768 E AndroidRuntime: FATAL EXCEPTION: main
03-19 19:01:44.781 3768 3768 E AndroidRuntime: Process: org.liberty.android.fantastischmemo, PID: 3768
03-19 19:01:44.781 3768 3768 E AndroidRuntime: java.lang.NumberFormatException: For input string: "test"
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at java.lang.Float.parseFloat(Float.java:451)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at java.lang.Float.valueOf(Float.java:416)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at org.liberty.android.fantastischmemo.ui.widgets.FloatEditTextPreference.persistString(FloatEditTextPreference.java:1)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.preference.EditTextPreference.setText(EditTextPreference.java:94)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.preference.EditTextPreference.onDialogClosed(EditTextPreference.java:148)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.preference.DialogPreference.onDismiss(DialogPreference.java:395)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1393)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6669)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
https://github.com/user-attachments/assets/6d2380fa-cc28-4180-82fe-95ea82ac7279
Description
The application crashes with a java.lang.NumberFormatException when a user enters non-numeric text into a preference field that expects a float value. This occurs because the input is not validated before the application attempts to parse it.
Environment
App Version: 10.11.7
Device: x86 Android Emulator
Android Version: 9.0 (API 28) / 6.0 (Reproducible across versions)
Testing Method: Automated testing
Steps to Reproduce
1.Open AnyMemo and go to Options -> Customize scheduling algorithm.
2.Click on any setting that requires a numeric value, such as "Grade 0" (The interval when you first grade a card).
3.In the input dialog, delete the number.
4.Click OK.
5.The application crashes immediately.
The logcat is as follows
03-19 19:01:44.781 3768 3768 E AndroidRuntime: FATAL EXCEPTION: main
03-19 19:01:44.781 3768 3768 E AndroidRuntime: Process: org.liberty.android.fantastischmemo, PID: 3768
03-19 19:01:44.781 3768 3768 E AndroidRuntime: java.lang.NumberFormatException: For input string: "test"
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at sun.misc.FloatingDecimal.parseFloat(FloatingDecimal.java:122)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at java.lang.Float.parseFloat(Float.java:451)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at java.lang.Float.valueOf(Float.java:416)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at org.liberty.android.fantastischmemo.ui.widgets.FloatEditTextPreference.persistString(FloatEditTextPreference.java:1)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.preference.EditTextPreference.setText(EditTextPreference.java:94)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.preference.EditTextPreference.onDialogClosed(EditTextPreference.java:148)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.preference.DialogPreference.onDismiss(DialogPreference.java:395)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1393)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.os.Looper.loop(Looper.java:193)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6669)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
03-19 19:01:44.781 3768 3768 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
https://github.com/user-attachments/assets/6d2380fa-cc28-4180-82fe-95ea82ac7279