Fenix: [Bug] Crashes when adding an invalid search engine

Created on 7 Jan 2020  ·  6Comments  ·  Source: mozilla-mobile/fenix

Steps to reproduce

Try to add a new search engine with the wrong protocol

Example:

  • "https://%s
  • a://%s
  • ftp://%s

https://i.imgur.com/kKvUCCW.png

Expected behavior

Show message: "Check that search string matches Example format"

Actual behavior

Browser crashes

https://i.imgur.com/VDWVNU3.png

Device information

  • Android device: 9
  • Fenix version: Nightly (Build #20070607) / 3.0.1 (Build #13502256)
SearchProvider Settings crash engverified 🐞 bug

Most helpful comment

It's no surprise because the fix in #7536 only checks if the string contains the substring "http", but the "http" can be anywhere in the string. Instead it should be checked if the string starts with "http".

All 6 comments

Sentry issue: FENIX-3JQ

The first one does not crash on Preview Nightly. Using a different protocol crashes with

java.lang.IllegalArgumentException: URI scheme must be http or https
    at org.mozilla.geckoview.GeckoWebExecutor.fetch(GeckoWebExecutor.java:12)
    at mozilla.components.browser.engine.gecko.fetch.GeckoViewFetchClient.fetch(GeckoViewFetchClient.kt:37)
    at org.mozilla.fenix.settings.search.AddSearchEngineFragment$createCustomEngine$1$result$1.invokeSuspend(AddSearchEngineFragment.kt:9)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:2)
    at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:15)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:1)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:47)

Hi, I've just checked this matter on the latest Nightly Build #20100616 from 01/10 using the following devices:
• Google Pixel 3a (Android 9)
• Huawei Mate 20 Lite (Android 8.1.0)
• Samsung Galaxy S7 (Android 7)
• OnePlus A3 (Android 6.0.1)
• LG Nexus 4 (Android 5.1.1)

I've noticed that the app is till crashing once I've used the first example ("https://%s).
It seems to be happen when you add any type of symbol before the desired Search string.

► Video
20200110_095837

► Video without any symbol
20200110_095902

  --------- beginning of crash
2020-01-10 10:06:40.360 3950-3950/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: org.mozilla.fenix.nightly, PID: 3950
    java.lang.IllegalArgumentException: URI scheme must be http or https
        at org.mozilla.geckoview.GeckoWebExecutor.fetch(GeckoWebExecutor.java:12)
        at mozilla.components.browser.engine.gecko.fetch.GeckoViewFetchClient.fetch(GeckoViewFetchClient.kt:37)
        at org.mozilla.fenix.settings.search.AddSearchEngineFragment$createCustomEngine$1$result$1.invokeSuspend(AddSearchEngineFragment.kt:9)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:2)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:15)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:1)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:15)
2020-01-10 10:06:40.362 3950-3950/? I/Process: Sending signal. PID: 3950 SIG: 9
2020-01-10 10:06:40.394 1134-1351/? W/InputDispatcher: channel '27a1877 org.mozilla.fenix.nightly/org.mozilla.fenix.nightly.App (server)' ~ Consumer closed input channel or an error occurred.  events=0x9
2020-01-10 10:06:40.394 1134-1351/? E/InputDispatcher: channel '27a1877 org.mozilla.fenix.nightly/org.mozilla.fenix.nightly.App (server)' ~ Channel is unrecoverably broken and will be disposed!
2020-01-10 10:06:40.396 1134-4676/? I/WindowManager: WIN DEATH: Window{27a1877 u0 org.mozilla.fenix.nightly/org.mozilla.fenix.nightly.App}
2020-01-10 10:06:40.396 1134-4676/? W/InputDispatcher: Attempted to unregister already unregistered input channel '27a1877 org.mozilla.fenix.nightly/org.mozilla.fenix.nightly.App (server)'
2020-01-10 10:06:40.396 1134-3190/? I/ActivityManager: Process org.mozilla.fenix.nightly (pid 3950) has died: fore TOP 
2020-01-10 10:06:40.397 1134-1191/? W/libprocessgroup: kill(-3950, 9) failed: No such process
2020-01-10 10:06:40.399 3996-3996/? I/ServiceChildProcess: Service has been unbound. Stopping.

@mcarare - I would kindly ask you to review and advise. ☺️
I'll remove the QA needed label until further notice.

It's no surprise because the fix in #7536 only checks if the string contains the substring "http", but the "http" can be anywhere in the string. Instead it should be checked if the string starts with "http".

@cadeyrn The thing is that you can actually omit the protocol and still have a valid search string. I think I will take another approach to this.

Hello, I can confirm that this issue is fixed on the Firefox Preview Nightly 1/13 #20130605.

Devices:

  • Nokia 6 (Android 7.1.1);
  • Motorola Moto G6 (Android 8);
  • Samsung Galaxy Note 8 (Android 9);
  • Google Pixel 2 (Android 9);
  • Google Pixel (Android Q).
Was this page helpful?
0 / 5 - 0 ratings