maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vsive...@apache.org
Subject svn commit: r811802 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src: main/java/org/apache/maven/doxia/module/fo/FoAggregateSink.java test/java/org/apache/maven/doxia/module/fo/FoAggregateSinkTest.java
Date Sun, 06 Sep 2009 10:49:38 GMT
Author: vsiveton
Date: Sun Sep  6 10:49:37 2009
New Revision: 811802

URL: http://svn.apache.org/viewvc?rev=811802&view=rev
Log:
o be sure that relative link is not outside the base (to prevent StringIndexOutOfBoundsException)
o added test case

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoAggregateSink.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoAggregateSinkTest.java

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoAggregateSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoAggregateSink.java?rev=811802&r1=811801&r2=811802&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoAggregateSink.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/main/java/org/apache/maven/doxia/module/fo/FoAggregateSink.java
Sun Sep  6 10:49:37 2009
@@ -518,6 +518,15 @@
                 base = base.substring( 0, base.lastIndexOf( "/" ) );
 
                 anchor = anchor.substring( 3 );
+
+                if ( base.lastIndexOf( "/" ) == -1 )
+                {
+                    while ( anchor.startsWith( "../" ) )
+                    {
+                        anchor = anchor.substring( 3 );
+                    }
+                    break;
+                }
             }
         }
 

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoAggregateSinkTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoAggregateSinkTest.java?rev=811802&r1=811801&r2=811802&view=diff
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoAggregateSinkTest.java
(original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fo/src/test/java/org/apache/maven/doxia/module/fo/FoAggregateSinkTest.java
Sun Sep  6 10:49:37 2009
@@ -176,5 +176,29 @@
         assertTrue( result.indexOf( "<fo:basic-link internal-destination=\"./folder/test\">"
) != -1 );
         assertTrue( result.indexOf( "<fo:basic-link internal-destination=\"./folder/whatsnew-1.1\">"
) != -1 );
         assertTrue( result.indexOf( "<fo:block id=\"./whatsnew-1.1\">" ) != -1 );
+
+        writer = new StringWriter();
+        try
+        {
+            sink = new FoAggregateSink( writer );
+            sink.setDocumentName( "./subdir/dir/index.html" );
+            sink.link( "../../root.html" );
+            sink.text( "../../root.html" );
+            sink.link_();
+            sink.link( "../../../outside.html" );
+            sink.text( "../../../outside.html" );
+            sink.link_();
+            sink.body();
+            sink.body_();
+        }
+        finally
+        {
+            sink.close();
+        }
+
+        result = writer.toString();
+
+        assertTrue( result.indexOf( "<fo:basic-link internal-destination=\"./root\">"
) != -1 );
+        assertTrue( result.indexOf( "<fo:basic-link internal-destination=\"./outside\">"
) != -1 );
     }
 }



Mime
View raw message