Re: Username and host can't be parsed when username contains @
- From: Bill Shannon <bill.shannon@sun.com>
- To: emeratius@gmail.com
- Cc: dev@javamail.kenai.com
- Subject: Re: Username and host can't be parsed when username contains @
- Date: Mon, 25 Oct 2010 12:25:31 -0700
If the username or password contain special characters, they need to be
encoded. If you use the URLName constructor that takes separate parameters
for the fields, the encoding is done for you. If you use the constructor
that takes a single string, it assumes it's a valid URL and that the encoding
has already been done.
emeratius@gmail.com wrote on 10/25/10 02:54 AM:
Hi,
I got the wrong host when the username contains @.
In URLName.parseString the fulluserpass and fullhost is collected by
indexOf('@').
I should be lastIndexOf('@')
// examine the fullhost, for username password etc.
int i = fullhost.lastIndexOf('@');
if (i != -1) {
String fulluserpass = fullhost.substring(0, i);
fullhost = fullhost.substring(i + 1);
| emeratius | 10/25/2010 | |
|
Re: Username and host can't be parsed when username contains @ |
Bill Shannon | 10/25/2010 |





