You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martin Makundi <ma...@koodaripalvelut.com> on 2008/11/15 07:00:23 UTC

Bug?

Hi!

I get this exception (I do not yet know how to repeat it, it does not
come up very often) and the code is quite funny, it expects a certain
pattern:

2008-11-14 10:03:32,271 650030871 [btpool0-628] ERROR RequestCycle  -
String index out of range: -1
java.lang.StringIndexOutOfBoundsException: String index out of range: -1
       at java.lang.AbstractStringBuilder.setLength(AbstractStringBuilder.java:143)
       at java.lang.StringBuffer.setLength(StringBuffer.java:153)
       at org.apache.wicket.protocol.http.RequestUtils.toAbsolutePath(RequestUtils.java:240)
       at org.apache.wicket.protocol.http.RequestUtils.toAbsolutePath(RequestUtils.java:203)

You will find on line 240 the code is like this:

			while (tempRelative.indexOf("../") == 0)
			{
				// Delete ../ from relative path
				tempRelative.delete(0, 3);

				// Delete last slash from result
				result.setLength(result.length() - 1);   /// LIne 240

				// Delete everyting up to last slash
				result.delete(result.lastIndexOf("/") + 1, result.length());
			}

Suppose the tempRelative ="../" then it will definitely crash.

Is the code ok?

**
Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org