Bug 15321 - wordWrap throws StringArrayIndexOutOfBoundsExceptions
Summary: wordWrap throws StringArrayIndexOutOfBoundsExceptions
Status: RESOLVED WORKSFORME
Alias: None
Product: Taglibs
Classification: Unclassified
Component: String Taglib (show other bugs)
Version: 1.0
Hardware: Other other
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-12-12 16:54 UTC by Robert Taylor
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Taylor 2002-12-12 16:54:11 UTC
wordWrap seems to be blowing up if the tag attempts to wrap a string that
contains a newline character as the 81st character. It will not blow up
if the 81st character is not a new line character.

This is my usage:
<string:wordWrap><bean:write name="form" property="body" 
ignore="true"/></string:wordWrap>

Partial stack trace:
2120: java.lang.StringIndexOutOfBoundsException: String index out of range: 80
2120:   at java.lang.String.charAt(String.java:455)
2120:   at org.apache.taglibs.string.util.StringW.wordWrap(StringW.java:181)
2120:   at org.apache.taglibs.string.WordWrapTag.changeString
(WordWrapTag.java:159)
2120:   at org.apache.taglibs.string.StringTagSupport.doEndTag
(StringTagSupport.java:135)
Comment 1 Henri Yandell 2003-01-28 23:14:44 UTC
Ought to be fixed. Awaiting confirmation.
Comment 2 Felipe Leme 2004-03-10 04:20:37 UTC
Robert,

Could you please try it again and, if the bug persists, reopen the bug providing
a better test case?

For instance, I created the following JSP page:

<%-- jsp page starts here --%>
<%@ taglib uri="http://jakarta.apache.org/taglibs/string-1.0.1" prefix="str" %>

<%

StringBuffer buffer = new StringBuffer(100);

for ( int i=1; i<=80; i++ ) {
   buffer.append( (char) i%10 );
}

String word = request.getParameter("word");
if ( word == null ) {
   word = "";
}
%>

Word: <str:wordWrap><%=word%></str:wordWrap>
<br>
Length: <str:length><%=word%></str:length>

<form>

Word: <textarea cols="80" rows="10" name="word"><%=buffer.toString()%></textArea>
<br>
<input type="submit">
</form>
<%-- jsp page ends here --%>

And ran it with many inputs:

http://localhost:8080/taglibs/bug15321.jsp?word=12345678901234567890123456789012345678901234567890123456789012345678901234567890
http://localhost:8080/taglibs/bug15321.jsp?word=12345678901234567890123456789012345678901234567890123456789012345678901234567890%0D
http://localhost:8080/taglibs/bug15321.jsp?word=12345678901234567890123456789012345678901234567890123456789012345678901234567890%0A
http://localhost:8080/taglibs/bug15321.jsp?word=12345678901234567890123456789012345678901234567890123456789012345678901234567890%0A%0D


None of them caused an exception, so I think it might have been already fixed.

Felipe