| Title | UserProfile error when retrieving a Cookie with an empty username |
| Date | 14-Nov-2004 18:01:29 EET |
| Version | 2.1.120 |
| Submitter | Arkub |
| PageProvider used | |
| Criticality | BadBug |
| Servlet Container | |
| Browser version | |
| URL | |
| Status | ClosedBug |
| Java version |
Hi there,
It looks like when clicking the "login" button with an empty username field, a cookie containing "username=" is set. Then when the method UserProfile.parseStringRepresentation is invoked, the used StringTokenizer crashes sadly by desperately looking for a value token, and the user then get a "java.util.NoSuchElementException java.util.StringTokenizer.nextToken(StringTokenizer.java:259) com.ecyrd.jspwiki.auth.UserProfile.parseStringRepresentation(UserProfile.java:115)" message on every page.
I guess following code should avoid the crash, or the Cookie might not be set when no username is available.
while( tok.hasMoreTokens() )
{
String param = tok.nextToken();
if( param.equals("username") && tok.hasMoreTokens())
{
String value = tok.nextToken();
prof.setName( value );
}
}
instead of
[...] String param = tok.nextToken(); String value = tok.nextToken(); [...]
jspWiki rocks, thanks for that.
Confirmed. Oops.
Fixed in 2.1.124.