jspwiki-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jalka...@apache.org
Subject svn commit: r704606 - in /incubator/jspwiki/trunk: ChangeLog src/com/ecyrd/jspwiki/Release.java src/com/ecyrd/jspwiki/content/PageRenamer.java tests/com/ecyrd/jspwiki/content/PageRenamerTest.java
Date Tue, 14 Oct 2008 18:44:35 GMT
Author: jalkanen
Date: Tue Oct 14 11:44:34 2008
New Revision: 704606

URL: http://svn.apache.org/viewvc?rev=704606&view=rev
Log:
[JSPWIKI-398] Pages with spaces in them caused erratic rename
behaviour by renaming all the links on the page.

Modified:
    incubator/jspwiki/trunk/ChangeLog
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
    incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/content/PageRenamer.java
    incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/content/PageRenamerTest.java

Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=704606&r1=704605&r2=704606&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Tue Oct 14 11:44:34 2008
@@ -1,3 +1,10 @@
+2008-09-30  Janne Jalkanen <jalkanen@apache.org>
+
+        * 2.8.0-beta-21
+        
+        * [JSPWIKI-398] Pages with spaces in them caused erratic rename
+        behaviour by renaming all the links on the page.
+
 2008-10-14  Andrew Jaquith <ajaquith AT apache DOT org>
 
         * 2.8.0-beta-20

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java?rev=704606&r1=704605&r2=704606&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java Tue Oct 14 11:44:34 2008
@@ -77,7 +77,7 @@
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "20";
+    public static final String     BUILD         = "21";
     
     /**
      *  This is the generic version string you should use

Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/content/PageRenamer.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/content/PageRenamer.java?rev=704606&r1=704605&r2=704606&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/content/PageRenamer.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/content/PageRenamer.java Tue Oct 14 11:44:34
2008
@@ -367,32 +367,34 @@
         int hash = original.indexOf( '#' );
         int slash = original.indexOf( '/' );
         String reallink = original;
+        String oldStyleRealLink;
         
         if( hash != -1 ) reallink = original.substring( 0, hash );
         if( slash != -1 ) reallink = original.substring( 0,slash );
         
         reallink = MarkupParser.cleanLink( reallink );
+        oldStyleRealLink = MarkupParser.wikifyLink( reallink );
         
-        // WikiPage p  = context.getEngine().getPage( reallink );
+        //WikiPage realPage  = context.getEngine().getPage( reallink );
         // WikiPage p2 = context.getEngine().getPage( from );
         
         // System.out.println("   "+reallink+" :: "+ from);
         // System.out.println("   "+p+" :: "+p2);
         
         //
-        //  if the original contains blanks, then we should introduce a link, for example:
 [My Page]  =>  [My Page|My Renamed Page]
-        int blank = reallink.indexOf( " ");
-        
-        if( blank != -1 )
-        {
-            return reallink + "|" + newlink;
-        }
-        
-        //
         //  Yes, these point to the same page.
         //
-        if( reallink.equals(from) )
+        if( reallink.equals(from) || original.equals(from) || oldStyleRealLink.equals(from)
)
         {
+            //
+            //  if the original contains blanks, then we should introduce a link, for example:
 [My Page]  =>  [My Page|My Renamed Page]
+            int blank = reallink.indexOf( " ");
+            
+            if( blank != -1 )
+            {
+                return original + "|" + newlink;
+            }
+            
             return newlink + ((hash > 0) ? original.substring( hash ) : "") + ((slash
> 0) ? original.substring( slash ) : "") ;
         }
         

Modified: incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/content/PageRenamerTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/content/PageRenamerTest.java?rev=704606&r1=704605&r2=704606&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/content/PageRenamerTest.java (original)
+++ incubator/jspwiki/trunk/tests/com/ecyrd/jspwiki/content/PageRenamerTest.java Tue Oct 14
11:44:34 2008
@@ -44,6 +44,10 @@
         TestEngine.deleteTestPage("Main8887");
         TestEngine.deleteTestPage("TestPage1234");
         TestEngine.deleteTestPage("TestPageReferred");
+        TestEngine.deleteTestPage("RenameTest");
+        TestEngine.deleteTestPage("Link one");
+        TestEngine.deleteTestPage("Link uno");
+        TestEngine.deleteTestPage("Link two");
 
         TestEngine.emptyWorkDir();
     }
@@ -444,7 +448,7 @@
         m_engine.saveText( "TestPageReferred", "bla bla bla som content" );
         m_engine.saveText( "TestPageReferring", "[Test Page Referred]" );
 
-       rename( "TestPageReferred", "TestPageReferredNew" );
+        rename( "TestPageReferred", "TestPageReferredNew" );
 
         String data = m_engine.getPureText( "TestPageReferring", WikiProvider.LATEST_VERSION
);
         assertEquals( "page not renamed", "[Test Page Referred|TestPageReferredNew]", data.trim()
);
@@ -457,6 +461,25 @@
         assertEquals( "wrong ref", "TestPageReferring", (String) refs.iterator().next() );
     }
 
+    /** https://issues.apache.org/jira/browse/JSPWIKI-398 */
+    public void testReferrerChangeWithBlanks2() throws Exception
+    {
+        m_engine.saveText( "RenameTest", "[link one] [link two]" );
+        m_engine.saveText( "Link one", "Leonard" );
+        m_engine.saveText( "Link two", "Cohen" );
+
+        rename( "Link one", "Link uno" );
+       
+        String data = m_engine.getPureText( "RenameTest", WikiProvider.LATEST_VERSION );
+        assertEquals( "page not renamed", "[link one|Link uno] [link two]", data.trim() );
+
+        Collection refs = m_engine.getReferenceManager().findReferrers( "Link one" );
+        assertNull( "oldpage", refs );
+
+        refs = m_engine.getReferenceManager().findReferrers( "Link uno" );
+        assertEquals( "new size", 1, refs.size() );
+        assertEquals( "wrong ref", "RenameTest", (String) refs.iterator().next() );
+    }
 
     public static Test suite()
     {



Mime
View raw message