Author: ajaquith
Date: Mon May  4 23:48:58 2009
New Revision: 771502

URL: http://svn.apache.org/viewvc?rev=771502&view=rev
Log:
To prevent wiki paths that have space prefixes from being interpreted as 
inter-wiki links,  JSPWikiMarkupParser prioritizes these first. This means that 
that wiki space names can't be the same as those for an interwiki prefixes. 
(Which is ok: when you think about it, an outside wiki is really just a space 
managed by someone else.) This fix was needed prevent various unit tests from 
bombing.

Modified:
    
incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java

Modified: 
incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
URL: 
http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java?rev=771502&r1=771501&r2=771502&view=diff
==============================================================================
--- 
incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
 (original)
+++ 
incubator/jspwiki/trunk/src/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
 Mon May  4 23:48:58 2009
@@ -697,6 +697,31 @@
     }
 
     /**
+     * Returns <code>true</code> if the link passed contains
+     * a colon, and the contents to the left of the colon matches
+     * one of the configured wiki spaces as returned by
+     * {...@link WikiEngine#getSpaces()}.
+     * @param link the link to examine
+     * @return the result
+     */
+    private boolean isSpaceLink( String link )
+    {
+        int colonPos = link.indexOf( ':' );
+        if ( colonPos != -1 )
+        {
+            String possibleSpace = link.substring( 0, colonPos );
+            for ( String space : m_engine.getSpaces() )
+            {
+                if ( space.equals( possibleSpace ) )
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
      *  Matches the given link to the list of image name patterns
      *  to determine whether it should be treated as an inline image
      *  or not.
@@ -1542,7 +1567,7 @@
                     addElement( outlinkImage() );
                 }
             }
-            else if( link.isInterwikiLink() )
+            else if( link.isInterwikiLink() && !isSpaceLink( linktext ) )
             {
                 // It's an interwiki link
                 // InterWiki links also get added to external link chain


Reply via email to