Piwigo / Piwigo-Android

Piwigo Native Android App
GNU General Public License v3.0
140 stars 43 forks source link

crash if SiteURL is not a valid URL #80

Closed ramack closed 5 years ago

ramack commented 5 years ago

If we for example omit the "http://" prefix the app terminates with something like:

STACK_TRACE=java.lang.IllegalArgumentException: Illegal URL: www.piwigo.org/demo/
    at retrofit2.Retrofit$Builder.baseUrl(Retrofit.java:456)
    at org.piwigo.io.RestServiceFactory.buildRetrofit(RestServiceFactory.java:88)
    at org.piwigo.io.RestServiceFactory.createForUrl(RestServiceFactory.java:51)
    at org.piwigo.io.repository.UserRepository.status(UserRepository.java:80)
    at org.piwigo.ui.login.LoginViewModel.onLoginClick(LoginViewModel.java:95)
    at org.piwigo.databinding.ActivityLoginBindingImpl._internalCallbackOnClick(ActivityLoginBindingImpl.java:451)

=> we should catch the exception and show a message that an invalid URL was entered.

ramack commented 5 years ago

@voriondev for this I think it would be wise to add some tests trying to connect to such illegal URLs but also some valid ones, with trainling "/" and without, with protocol spec and with just a hostname...

This is really a trouble for so many users, that we want to have some testing to ensure that we don't get a regression in future. And I think we should store the URL as full and valid URL in the account setting, so not what the user entered, that was autocorrected, but really what is used.

ramack commented 5 years ago

this one is closed, as we handle the non-standard port part in #100