Illegal character in host name - Android 4.0.4
I just tried to set up DavDroid on an old Android 4.0.4 Device and did not get far. I need to sign in with URL and Password. But everytime i tried to sign in, DAVDroid didn't even make an attempt. I only get the error message "Illegal character in host name at index 0: "my_host.name.eu"".
If i remove the _ (underline) from the URL, everything works just fine (except that I my not communicazing with my Server). IUn a newer Android 7 Device, everything works fine and _ in URLs is no problemm. It seems like you use some old and bugfy Android 4 stuff to check for a valid URL and sadly this code is broken on Android 4.0.4
Are you sure that
_is an allowed character?
<domain> ::= <subdomain> | " " <subdomain> ::= <label> | <subdomain> "." <label> <label> ::= <letter> [ [ <ldh-str> ] <let-dig> ] <ldh-str> ::= <let-dig-hyp> | <let-dig-hyp> <ldh-str> <let-dig-hyp> ::= <let-dig> | "-" <let-dig> ::= <letter> | <digit> <letter> ::= any one of the 52 alphabetic characters A through Z in upper case and a through z in lower case <digit> ::= any one of the ten digits 0 through 9
DAVdroid doesn't use special validity checks, but it has to refuse URLs which throw an
UriSyntaxException(https://gitlab.com/bitfireAT/davdroid/blob/de5903b3758b732d0135c27ca0bf967328629959/app/src/main/java/at/bitfire/davdroid/ui/setup/LoginCredentialsFragment.java#L142 ff). So I guess there's nothing we can do in this case.
Hello and thanks for you answer
First of: The use of _ is allowed, even if it is not suggested for domain names (and for subdomains...).
Second: Why does is work on Android 7 and 7.1.1 without any problems but gives me the "Illegal character" on Adroid 4.0.4? That still looks like a bug to me?!
And third: Of course we can discuss about RFCs and specifications here but I initially thought this forum would be a place where everyone tries to solve some problems? A simple override for the URI-Check would be a solution or a constant behavior on all Android-Plattforms would at least make things more predictible...
And third: Of course we can discuss about RFCs and specifications here but I initially thought this forum would be a place where everyone tries to solve some problems?
Well, before I solve a supposed problem, I'd like to know whether it actually is a problem. In my opinion, it doesn't make sense to hack around randomly using a trial-and-error approach, or to create a dozen of new bugs by introducing non-standard-compliant behavior.
A simple override for the URI-Check would be a solution or a constant behavior on all Android-Plattforms would at least make things more predictible...
I don't know how overriding an
UriSyntaxExceptioncould help, because such an URL wouldn't be processed correctly at a later time.
However, if you know a working solution, please provide a patch, I'll try to review it.
By the way, when we're talking about solutions: Why don't you just use a host name with only digits, letters and
-, as recommended in the DNS standards? To me, this sounds easier and more compatible (also with other applications) than working around years-old Android 4.0.4 behavior with the risk of introducing other problems.