[fenix] For https://github.com/mozilla-mobile/fenix/issues/7522 Catch IllegalArgumentException when validating search string

pull/600/head
mcarare 5 years ago committed by Emily Kager
parent 72604bb955
commit 3af16e3185

@ -171,8 +171,7 @@ class AddSearchEngineFragment : Fragment(), CompoundButton.OnCheckedChangeListen
custom_search_engine_search_string_field.error = when { custom_search_engine_search_string_field.error = when {
searchString.isEmpty() -> searchString.isEmpty() ->
resources.getString(R.string.search_add_custom_engine_error_empty_search_string) resources.getString(R.string.search_add_custom_engine_error_empty_search_string)
!searchString.contains("%s") !searchString.contains("%s") ->
|| !searchString.contains("http") ->
resources.getString(R.string.search_add_custom_engine_error_missing_template) resources.getString(R.string.search_add_custom_engine_error_missing_template)
else -> null else -> null
} }

@ -20,6 +20,8 @@ object SearchStringValidator {
client.fetch(request) client.fetch(request)
} catch (e: IOException) { } catch (e: IOException) {
return Result.CannotReach return Result.CannotReach
} catch (e: IllegalArgumentException) {
return Result.CannotReach
} }
// read the response stream to ensure the body is closed correctly. workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1603114 // read the response stream to ensure the body is closed correctly. workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=1603114

Loading…
Cancel
Save