You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "David Delbecq (JIRA)" <ji...@codehaus.org> on 2008/07/08 13:41:26 UTC

[jira] Created: (DOXIA-247) unable to parse document when the last character is '}'

unable to parse document when the last character is '}'
-------------------------------------------------------

                 Key: DOXIA-247
                 URL: http://jira.codehaus.org/browse/DOXIA-247
             Project: Maven Doxia
          Issue Type: Bug
    Affects Versions: 1.0-alpha-11
            Reporter: David Delbecq


When last character of a document is '}', maven doxia issues a, array out of bound exception. It tries to get next character to find out if we found a '}}' pair, but doesn't check bounds of document:
{code}
org.apache.maven.doxia.parser.ParseException: String index out of range: 14
        at org.apache.maven.doxia.module.confluence.ConfluenceParser.parse(ConfluenceParser.java:139)
....
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 14
        at java.lang.String.charAt(String.java:558)
        at org.apache.maven.doxia.module.confluence.parser.ParagraphBlockParser.visit(ParagraphBlockParser.java:134)
        at org.apache.maven.doxia.module.confluence.ConfluenceParser.parse(ConfluenceParser.java:103)
        at org.apache.maven.doxia.module.confluence.ConfluenceParser.parse(ConfluenceParser.java:131)
{code}

testcase:
{code:title=AppTest.java|borderStyle=solid}
package org.apache.doxia.test.BUGTestCase;

import java.io.StringReader;

/**
 * Unit test for simple App.
 */
public class AppTest 
extends TestCase
{
	/**
	 * Create the test case
	 *
	 * @param testName name of the test case
	 */
	public AppTest( String testName )
	{
		super( testName );
	}

	/**
	 * @return the suite of tests being tested
	 */
	public static Test suite()
	{
		return new TestSuite( AppTest.class );
	}

	/**
	 * Rigourous Test :-)
	 * @throws ParseException 
	 */
	public void testEndBracket() throws ParseException
	{
		String document = "Test" +
		"\n\n* list1"+
		"\n\n* list2"+
		"\n\n* list2"+
		"\n{pre}123{/pre}";    			
		StringWriter writer = new StringWriter();
		ConfluenceParser parser = new ConfluenceParser();
		XhtmlSink sink = new XhtmlSink(writer);
		/* parsing with additional space at end works*/
		parser.parse(new StringReader(document+" "), sink);
		assertTrue("generated document should have a size >0",writer.toString().length()>0);
		/* parsing with document ending in } fails*/
		try{
			parser.parse(new StringReader(document), sink);
		} catch (Exception e){
			e.printStackTrace();
			fail("parsing with document ending in } should not fails");
		}
		assertTrue("generated document should have a size >0",writer.toString().length()>0);
	}
	/**
	 * Rigourous Test :-)
	 * @throws ParseException 
	 */
	public void testEndBracketInList() throws ParseException
	{
		String document1 = "Test" +
		"\n\n* list1"+
		"\n\n* list2"+
		"\n\n* list2{pre}123{/pre} "+
		"\n123";
		String document2 = "Test" +
		"\n\n* list1"+
		"\n\n* list2"+
		"\n\n* list2{pre}123{/pre}"+
		"\n123";    			
		StringWriter writer = new StringWriter();
		ConfluenceParser parser = new ConfluenceParser();
		XhtmlSink sink = new XhtmlSink(writer);
		/* parsing with additional space at end of list item works*/
		parser.parse(new StringReader(document1), sink);
		assertTrue("generated document should have a size >0",writer.toString().length()>0);
		/* parsing with end of list item ending in } fails*/
		try{
			parser.parse(new StringReader(document2), sink);
		} catch (Exception e){
			e.printStackTrace();
			fail("parsing with end of list item ending in } should not fails");
		}
		assertTrue("generated document should have a size >0",writer.toString().length()>0);
	}
}
{code}


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Closed: (DOXIA-247) unable to parse document when the last character is '}'

Posted by "Lukas Theussl (JIRA)" <ji...@codehaus.org>.
     [ http://jira.codehaus.org/browse/DOXIA-247?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukas Theussl closed DOXIA-247.
-------------------------------

         Assignee: Lukas Theussl
       Resolution: Fixed
    Fix Version/s: 1.0-beta-1

This is fixed already in 1.0-beta-1 (r589828), I added your tests to ConfluenceParserTest. Thanks!

> unable to parse document when the last character is '}'
> -------------------------------------------------------
>
>                 Key: DOXIA-247
>                 URL: http://jira.codehaus.org/browse/DOXIA-247
>             Project: Maven Doxia
>          Issue Type: Bug
>    Affects Versions: 1.0-alpha-11
>            Reporter: David Delbecq
>            Assignee: Lukas Theussl
>             Fix For: 1.0-beta-1
>
>
> When last character of a document is '}', maven doxia issues a, array out of bound exception. It tries to get next character to find out if we found a '}}' pair, but doesn't check bounds of document:
> {code}
> org.apache.maven.doxia.parser.ParseException: String index out of range: 14
>         at org.apache.maven.doxia.module.confluence.ConfluenceParser.parse(ConfluenceParser.java:139)
> ....
> Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 14
>         at java.lang.String.charAt(String.java:558)
>         at org.apache.maven.doxia.module.confluence.parser.ParagraphBlockParser.visit(ParagraphBlockParser.java:134)
>         at org.apache.maven.doxia.module.confluence.ConfluenceParser.parse(ConfluenceParser.java:103)
>         at org.apache.maven.doxia.module.confluence.ConfluenceParser.parse(ConfluenceParser.java:131)
> {code}
> testcase:
> {code:title=AppTest.java|borderStyle=solid}
> package org.apache.doxia.test.BUGTestCase;
> import java.io.StringReader;
> /**
>  * Unit test for simple App.
>  */
> public class AppTest 
> extends TestCase
> {
> 	/**
> 	 * Create the test case
> 	 *
> 	 * @param testName name of the test case
> 	 */
> 	public AppTest( String testName )
> 	{
> 		super( testName );
> 	}
> 	/**
> 	 * @return the suite of tests being tested
> 	 */
> 	public static Test suite()
> 	{
> 		return new TestSuite( AppTest.class );
> 	}
> 	/**
> 	 * Rigourous Test :-)
> 	 * @throws ParseException 
> 	 */
> 	public void testEndBracket() throws ParseException
> 	{
> 		String document = "Test" +
> 		"\n\n* list1"+
> 		"\n\n* list2"+
> 		"\n\n* list2"+
> 		"\n{pre}123{/pre}";    			
> 		StringWriter writer = new StringWriter();
> 		ConfluenceParser parser = new ConfluenceParser();
> 		XhtmlSink sink = new XhtmlSink(writer);
> 		/* parsing with additional space at end works*/
> 		parser.parse(new StringReader(document+" "), sink);
> 		assertTrue("generated document should have a size >0",writer.toString().length()>0);
> 		/* parsing with document ending in } fails*/
> 		try{
> 			parser.parse(new StringReader(document), sink);
> 		} catch (Exception e){
> 			e.printStackTrace();
> 			fail("parsing with document ending in } should not fails");
> 		}
> 		assertTrue("generated document should have a size >0",writer.toString().length()>0);
> 	}
> 	/**
> 	 * Rigourous Test :-)
> 	 * @throws ParseException 
> 	 */
> 	public void testEndBracketInList() throws ParseException
> 	{
> 		String document1 = "Test" +
> 		"\n\n* list1"+
> 		"\n\n* list2"+
> 		"\n\n* list2{pre}123{/pre} "+
> 		"\n123";
> 		String document2 = "Test" +
> 		"\n\n* list1"+
> 		"\n\n* list2"+
> 		"\n\n* list2{pre}123{/pre}"+
> 		"\n123";    			
> 		StringWriter writer = new StringWriter();
> 		ConfluenceParser parser = new ConfluenceParser();
> 		XhtmlSink sink = new XhtmlSink(writer);
> 		/* parsing with additional space at end of list item works*/
> 		parser.parse(new StringReader(document1), sink);
> 		assertTrue("generated document should have a size >0",writer.toString().length()>0);
> 		/* parsing with end of list item ending in } fails*/
> 		try{
> 			parser.parse(new StringReader(document2), sink);
> 		} catch (Exception e){
> 			e.printStackTrace();
> 			fail("parsing with end of list item ending in } should not fails");
> 		}
> 		assertTrue("generated document should have a size >0",writer.toString().length()>0);
> 	}
> }
> {code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira