You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by br...@apache.org on 2020/02/15 12:15:00 UTC

[jspwiki] branch master updated: 2.11.0-M7-git-07: fix order of processing, addit. unit tests

This is an automated email from the ASF dual-hosted git repository.

brushed pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git


The following commit(s) were added to refs/heads/master by this push:
     new e06501f  2.11.0-M7-git-07: fix order of processing, addit. unit tests
e06501f is described below

commit e06501f00b4986624a610418370180f4116f06e6
Author: brushed <di...@gmail.com>
AuthorDate: Sat Feb 15 13:14:41 2020 +0100

    2.11.0-M7-git-07: fix order of processing, addit. unit tests
---
 ChangeLog.md                                       | 42 ++++++++++++----------
 .../src/main/java/org/apache/wiki/Release.java     |  2 +-
 .../apache/wiki/attachment/AttachmentManager.java  | 16 ++++-----
 .../wiki/attachment/AttachmentManagerTest.java     | 16 +++++++++
 4 files changed, 49 insertions(+), 27 deletions(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index 7857aeb..a22f71e 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -17,14 +17,20 @@ specific language governing permissions and limitations
 under the License.
 -->
 
+**2002-02-14  Dirk Frederickx (brushed AT apache DOT org)**
+
+* _2.11.0-M7-git-07_
+
+* AttachmentManager:  fix the order of processing.  Added a few extra unit tests.
+
 **2020-01-28  Juan Pablo Santos (juanpablo AT apache DOT org)**
 
 * _2.11.0-M7-git-06_
 
 * [JSPWIKI-120](https://issues.apache.org/jira/browse/JSPWIKI-120): Separate rendering engine from core
-    * `CommandResolver` renamed as `org.apache.wiki.ui.DefaultCommandResolver`, with new 
+    * `CommandResolver` renamed as `org.apache.wiki.ui.DefaultCommandResolver`, with new
        `org.apache.wiki.ui.CommandResolver` extracted as interface of the latter
-    * `ProgressManager` renamed as `org.apache.wiki.ui.progress.DefaultProgressManager`, with new 
+    * `ProgressManager` renamed as `org.apache.wiki.ui.progress.DefaultProgressManager`, with new
       `org.apache.wiki.ui.progress.ProgressManager` extracted as interface of the latter
     * removed `createContext(..)` method from `WikiEngine` use new constructor on `WikiContext` instead
     * removed `WikiEngine#getRedirectURL(..)` use same method on `WikiContext`
@@ -46,12 +52,12 @@ under the License.
 * _2.11.0-M7-git-05_
 
 * [JSPWIKI-120](https://issues.apache.org/jira/browse/JSPWIKI-120): Separate rendering engine from core
-    * `RenderingManager` renamed as `org.apache.wiki.render.DefaultRenderingManager`, with new 
+    * `RenderingManager` renamed as `org.apache.wiki.render.DefaultRenderingManager`, with new
        `org.apache.wiki.render.RenderingManager` extracted as interface of the latter
     * moved `textToHtml(..)` methods from `WikiEngine` to `RenderingManager`
     * moved `getHTML(..)` methods from `WikiEngine` to `RenderingManager`
     * moved `beautifyTitle( String )` and `beautifyTitleNoBreak` methods from `WikiEngine` to `RenderingManager`
-* `VAR_EXECUTE_PLUGINS` and `WYSIWYG_EDITOR_MODE` constants from `RenderingManager` moved to `WikiContext` (the latter 
+* `VAR_EXECUTE_PLUGINS` and `WYSIWYG_EDITOR_MODE` constants from `RenderingManager` moved to `WikiContext` (the latter
 as `VAR_WYSIWYG_EDITOR_MODE`)
 * constant `PROP_RUNFILTERS` from `WikiEngine` moved to `VariableManager` as `VAR_RUNFILTERS`.
 * constants `PUNCTUATION_CHARS_ALLOWED` and `LEGACY_CHARS_ALLOWED` from `MarkupParser` moved to `TextUtil`.
@@ -61,9 +67,9 @@ as `VAR_WYSIWYG_EDITOR_MODE`)
 
 * _2.11.0-M7-git-04_
 
-* [JSPWIKI-120](https://issues.apache.org/jira/browse/JSPWIKI-120): Separate rendering engine from core - following methods moved from 
+* [JSPWIKI-120](https://issues.apache.org/jira/browse/JSPWIKI-120): Separate rendering engine from core - following methods moved from
 `WikiEngine` to `PageManager`
-    * `deletePage(..)` and `deleteVersion(..)` methods 
+    * `deletePage(..)` and `deleteVersion(..)` methods
     * `getPage(..)`
     * `pageExist(..)` methods, renamed as `wikiPageExist(..)`
     * `saveText()`
@@ -71,14 +77,14 @@ as `VAR_WYSIWYG_EDITOR_MODE`)
     * `getPureText( String, int )`
     * `getRecentChanges()`
     * `getVersionHistory()`
-    * `getCurrentProvider()` 
-    * `getCurrentProviderInfo()` and `getPageCount` were deleted - use instead existing `getProviderDescription()` and `getTotalPageCount` 
+    * `getCurrentProvider()`
+    * `getCurrentProviderInfo()` and `getPageCount` were deleted - use instead existing `getProviderDescription()` and `getTotalPageCount`
     methods from `PageManager`
-* `WorkflowManager` renamed as `org.apache.wiki.workflow.DefaultWorkflowManager`, with new 
+* `WorkflowManager` renamed as `org.apache.wiki.workflow.DefaultWorkflowManager`, with new
  `org.apache.wiki.workflow.WorkflowManager` extracted as interface of the latter
 * Explicit casting from `WikiEngine#getAttribute()` and ` WikiPage#getAttribute()` no longer needed in most cases now
 * `WikiTagBase#ATTR_CONTEXT` constant moved to `WikiContext`
-* `TestEngine` now includes test class and method where it was created next to the timestamp, which is useful when you have tons of 
+* `TestEngine` now includes test class and method where it was created next to the timestamp, which is useful when you have tons of
 timestamped dirs and want to know which folder was generated by what test
     * Also, if no folder is given for work, pages and attachment dirs, it tries to place them under `./target/`
 * Applied format & fixes suggested by intellij to another bunch of files
@@ -88,10 +94,10 @@ timestamped dirs and want to know which folder was generated by what test
 * _2.11.0-M7-git-03_
 
 * [JSPWIKI-120](https://issues.apache.org/jira/browse/JSPWIKI-120): Separate rendering engine from core
-    * `ReferenceManager` renamed + moved to `org.apache.wiki.references.DefaultReferenceManager`, with new 
+    * `ReferenceManager` renamed + moved to `org.apache.wiki.references.DefaultReferenceManager`, with new
     `org.apache.wiki.references.ReferenceManager` extracted as interface of the latter
     * `scanWikiLinks(..)` and `updateReferences(..)` methods from `WikiEngine` moved to `ReferenceManager`
-* `WikiDifferenceManager`, `WikiVariableManager` and `WikiPageRenamer` renamed to `DefaultDifferenceManager`, `DefaultVariableManager` 
+* `WikiDifferenceManager`, `WikiVariableManager` and `WikiPageRenamer` renamed to `DefaultDifferenceManager`, `DefaultVariableManager`
   and `DefaultPageRenamer` respectively; it's a better suited prefix for default implementations and also follows the existing naming
   with the existing bunch of `Default[XYZ]Manager` that currently exist
 * Moved `[Default]VariableManager` to their own package under `org.apache.wiki.variables`
@@ -131,8 +137,8 @@ timestamped dirs and want to know which folder was generated by what test
 
 * Maven plugins changes
     * Change javadocs' doclet to [UMLDoclet](https://github.com/talsma-ict/umldoclet), which can be used with JDK >= 9 (see associated note on [`mvn_cheat-sheet.md`](https://github.com/apache/jspwiki/blob/master/mvn_cheat-sheet.md#3-reports-specific) for details)
-    * Set `compilerVersion` to `jdk.version` on jspc-maven-plugin 
-  
+    * Set `compilerVersion` to `jdk.version` on jspc-maven-plugin
+
 * [JSPWIKI-1126](https://issues.apache.org/jira/browse/JSPWIKI-1126): Dependency updates
     * Flexmark to 0.50.44
     * Lucene to 8.3.1
@@ -145,16 +151,16 @@ timestamped dirs and want to know which folder was generated by what test
 
 * _2.11.0-M6-git-04_
 
-* [JSPWIKI-1120](https://issues.apache.org/jira/browse/JSPWIKI-1120): Strings and Boxed types should be compared using "equals()". 
+* [JSPWIKI-1120](https://issues.apache.org/jira/browse/JSPWIKI-1120): Strings and Boxed types should be compared using "equals()".
   Contributed by Haris Adzemovic, thanks!
 
 **2019-11-01  Juan Pablo Santos (juanpablo AT apache DOT org)**
 
 * _2.11.0-M6-git-03_
 
-* [JSPWIKI-1125](https://issues.apache.org/jira/browse/JSPWIKI-1125): Bringing in Docker support to ASF repo from https://github.com/metskem/docker-jspwiki. 
+* [JSPWIKI-1125](https://issues.apache.org/jira/browse/JSPWIKI-1125): Bringing in Docker support to ASF repo from https://github.com/metskem/docker-jspwiki.
   See https://jspwiki-wiki.apache.org/Wiki.jsp?page=Docker for details.
-  
+
 * Dependency updates
     * Flexmark to 0.50.42
     * Selenide to 5.5.0
@@ -381,7 +387,7 @@ and also scans `.md` and `.xml` files.
 
 * _2.11.0-M4-git-12_
 
-* [JSPWIKI-1104](https://issues.apache.org/jira/browse/JSPWIKI-1104) [InsertPagePlugin](https://jspwiki-wiki.apache.org/Wiki.jsp?page=InsertPagePlugin) 
+* [JSPWIKI-1104](https://issues.apache.org/jira/browse/JSPWIKI-1104) [InsertPagePlugin](https://jspwiki-wiki.apache.org/Wiki.jsp?page=InsertPagePlugin)
   now also supports cookie based inserts.
   The UserPreferences page has been extended to allow the users to view and
   delete page-based cookies.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/Release.java b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
index 225c8ba..19026cc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/Release.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
@@ -69,7 +69,7 @@ public final class Release {
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "git-06";
+    public static final String     BUILD         = "git-07";
 
     /**
      *  This is the generic version string you should use when printing out the version.  It is of
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentManager.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentManager.java
index 8ec4634..7391967 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentManager.java
@@ -649,6 +649,14 @@ public class AttachmentManager
         }
 
         //
+        //  Some browser send the full path info with the filename, so we need
+        //  to remove it here by simply splitting along slashes and then taking the path.
+        //
+
+        String[] splitpath = filename.split( "[/\\\\]" );
+        filename = splitpath[splitpath.length-1];
+
+        //
         //  Should help with IE 5.22 on OSX
         //
         filename = filename.trim();
@@ -664,14 +672,6 @@ public class AttachmentManager
         }
 
         //
-        //  Some browser send the full path info with the filename, so we need
-        //  to remove it here by simply splitting along slashes and then taking the path.
-        //
-
-        String[] splitpath = filename.split( "[/\\\\]" );
-        filename = splitpath[splitpath.length-1];
-
-        //
         //  Remove any characters that might be a problem. Most
         //  importantly - characters that might stop processing
         //  of the URL.
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
index 46a5ece..b4cd203 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
@@ -17,6 +17,7 @@ import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.ProviderException;
+import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.util.FileUtil;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
@@ -370,6 +371,21 @@ public class AttachmentManagerTest
         Assertions.assertEquals( "foo.jpg", AttachmentManager.validateFileName( "foo.jpg" ), "foo.jpg" );
 
         Assertions.assertEquals( "test.jpg", AttachmentManager.validateFileName( "C:\\Windows\\test.jpg" ), "C:\\Windows\\test.jpg" );
+
+        WikiException thrown1 =
+        Assertions.assertThrows( WikiException.class, () -> {
+            AttachmentManager.validateFileName( "C:\\Windows\\test.jsp" );
+        });
+        Assertions.assertTrue(thrown1.getMessage().contains("attach.unwanted.file"), thrown1.getMessage());
+
+        WikiException thrown2 =
+        Assertions.assertThrows( WikiException.class, () -> {
+            AttachmentManager.validateFileName( "C:\\Windows\\test.jsp\\" );
+        });
+        Assertions.assertTrue(thrown2.getMessage().contains("attach.unwanted.file"), thrown2.getMessage());
+
+        Assertions.assertEquals( "test__test.jpg", AttachmentManager.validateFileName( "C:\\Windows\\test#?test.jpg" ), "test#?test.jpg" );
+
     }
 
 }