You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2022/07/12 21:03:33 UTC

[jspwiki] branch master updated (5ed57bd79 -> 69a48e16f)

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

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


    from 5ed57bd79 remove extra semicolon.
     new a39e1a81a Upgrade Tika to 2.4.0
     new 1617a34ab only build & destroy one Engine for all tests in class
     new 0cbf45c78 Minor format edits
     new 3d498669c Footnote links start with #ref-, instead of #
     new 903be0fd8 format class
     new 5bb7f9734 bom must have packaging == pom
     new 7c1255e2e new jspwiki-http module
     new f2d231ba1 fix integration tests setup
     new ccaf74ad8 Session gets new antiCsrfToken method
     new 45f22ecac fix IT check
     new 84740147a format web.xml files
     new 18bb41c56 Allow TestEngine to disable properties' cleaning through jspwiki.test.disable-clean-props property
     new 63f0617b8 Use Context instead of WikiContext
     new 8365f5bee Add dependency on jspwiki-http module
     new cdfb63d26 new wiki:CsrfProtection custom tag
     new d42623bcc FormOpen generates csrf protection hidden input
     new 1f1c94e77 Use new wiki:CsrfProtection tag on JSPs
     new 25f3c707a Ensure AJAX requests send the csrf protection parameter
     new 087f90afa JSPWiki to Markdown syntax conversion tool
     new a55c6afd2 Add missing AL headers
     new c4c5f411a Dependency updates
     new 9dec27e23 Update Tomcat's binaries
     new 5afdd0cdf Update versions
     new b7cf446d8 Update mvn cheat sheet
     new 69a48e16f 2.11.3-git-09

The 25 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ChangeLog.md                                       |   28 +
 LICENSE                                            |   24 +-
 .../src/main/java/org/apache/wiki/api/Release.java |    2 +-
 .../java/org/apache/wiki/api/core/Session.java     |    6 +
 jspwiki-bom/pom.xml                                |    7 +
 {jspwiki-bootstrap => jspwiki-http}/pom.xml        |   26 +-
 .../wiki/http/filter/CsrfProtectionFilter.java     |   63 +
 .../src/main/resources/META-INF/web-fragment.xml   |   30 +-
 .../src/main/webapp/WEB-INF/web.xml                |   58 +-
 .../src/main/webapp/WEB-INF/web.xml                |   58 +-
 .../src/main/webapp/WEB-INF/web.xml                |   58 +-
 .../src/main/webapp/WEB-INF/web.xml                |   58 +-
 .../src/main/webapp/WEB-INF/web.xml                |   58 +-
 .../apache/wiki/pages/haddock/ViewWikiPage.java    |    2 +-
 jspwiki-it-tests/pom.xml                           |    2 +
 jspwiki-main/pom.xml                               |    6 +
 .../src/main/java/org/apache/wiki/WikiSession.java |    9 +
 .../main/java/org/apache/wiki/forms/FormOpen.java  |    8 +-
 .../apache/wiki/parser/JSPWikiMarkupParser.java    | 1624 +++++++-------------
 .../org/apache/wiki/plugin/TableOfContents.java    |    4 +-
 .../org/apache/wiki/tags/CsrfProtectionTag.java    |   53 +
 .../java/org/apache/wiki/ui/WikiJSPFilter.java     |   22 +-
 .../java/org/apache/wiki/ui/WikiServletFilter.java |   14 +-
 .../src/main/resources/META-INF/jspwiki.tld        |    9 +
 .../src/test/java/org/apache/wiki/TestEngine.java  |   11 +-
 .../org/apache/wiki/plugin/WeblogPluginTest.java   |    8 +-
 .../markdown/migration/WikiSyntaxConverter.java    |   74 +
 .../migration/filters/TidyMarkupFilter.java        |   24 +-
 .../parser/JSPWikiToMarkdownMarkupParser.java      |   81 +
 .../tomcat/woas.app/Contents/Java/bootstrap.jar    |  Bin 34699 -> 34699 bytes
 .../tomcat/woas.app/Contents/Java/tomcat-juli.jar  |  Bin 46897 -> 46898 bytes
 .../src/overlay/launchers/tomcat/woas.exe          |  Bin 3659368 -> 3669432 bytes
 jspwiki-war/src/main/scripts/jspwiki-common.js     |    4 +-
 jspwiki-war/src/main/scripts/jspwiki-edit.js       |    2 +-
 .../src/main/scripts/wiki-edit/Wiki.Edit.js        |    3 +-
 jspwiki-war/src/main/scripts/wiki/Category.js      |    5 +-
 jspwiki-war/src/main/scripts/wiki/Wiki.js          |    5 +-
 jspwiki-war/src/main/webapp/Captcha.jsp            |    1 +
 jspwiki-war/src/main/webapp/Install.jsp            |    2 +-
 jspwiki-war/src/main/webapp/WEB-INF/web.xml        |   24 +-
 .../main/webapp/templates/210/AttachmentTab.jsp    |   13 +-
 .../src/main/webapp/templates/210/DiffTab.jsp      |    1 +
 .../main/webapp/templates/210/EditGroupContent.jsp |    3 +-
 .../src/main/webapp/templates/210/FindContent.jsp  |    2 +-
 .../src/main/webapp/templates/210/GroupContent.jsp |    1 +
 .../src/main/webapp/templates/210/GroupTab.jsp     |    1 +
 .../src/main/webapp/templates/210/InfoContent.jsp  |    5 +-
 .../src/main/webapp/templates/210/LoginContent.jsp |    4 +-
 .../main/webapp/templates/210/NewGroupContent.jsp  |    2 +-
 .../src/main/webapp/templates/210/PageTab.jsp      |    1 +
 .../main/webapp/templates/210/PreferencesTab.jsp   |    2 +
 .../src/main/webapp/templates/210/ProfileTab.jsp   |    1 +
 .../src/main/webapp/templates/210/SearchBox.jsp    |    1 +
 .../main/webapp/templates/210/WorkflowContent.jsp  |    2 +
 .../webapp/templates/210/admin/AdminTemplate.jsp   |    2 +
 .../webapp/templates/210/admin/UserManagement.jsp  |    1 +
 .../src/main/webapp/templates/210/commonheader.jsp |    1 +
 .../main/webapp/templates/210/editors/CKeditor.jsp |    3 +-
 .../src/main/webapp/templates/210/editors/FCK.jsp  |    1 +
 .../main/webapp/templates/210/editors/TinyMCE.jsp  |    1 +
 .../main/webapp/templates/210/editors/plain.jsp    |    1 +
 .../main/webapp/templates/210/editors/preview.jsp  |    1 +
 .../main/webapp/templates/210/editors/wysiwyg.jsp  |    1 +
 .../webapp/templates/default/AttachmentTab.jsp     |    5 +-
 .../src/main/webapp/templates/default/DiffTab.jsp  |    1 +
 .../webapp/templates/default/EditGroupContent.jsp  |    1 +
 .../main/webapp/templates/default/FindContent.jsp  |    1 +
 .../src/main/webapp/templates/default/GroupTab.jsp |    2 +
 .../main/webapp/templates/default/InfoContent.jsp  |    5 +-
 .../main/webapp/templates/default/LoginContent.jsp |    4 +-
 .../src/main/webapp/templates/default/PageTab.jsp  |    1 +
 .../webapp/templates/default/PreferencesTab.jsp    |    1 +
 .../main/webapp/templates/default/ProfileTab.jsp   |    1 +
 .../main/webapp/templates/default/SearchBox.jsp    |    1 +
 .../src/main/webapp/templates/default/UserBox.jsp  |   10 +-
 .../webapp/templates/default/WorkflowContent.jsp   |    2 +
 .../templates/default/admin/AdminTemplate.jsp      |    2 +
 .../templates/default/admin/UserManagement.jsp     |    3 +-
 .../main/webapp/templates/default/commonheader.jsp |    1 +
 .../webapp/templates/default/editors/CKeditor.jsp  |    1 +
 .../webapp/templates/default/editors/TinyMCE.jsp   |    1 +
 .../webapp/templates/default/editors/plain.jsp     |    1 +
 .../webapp/templates/default/editors/preview.jsp   |    2 +-
 .../webapp/templates/default/editors/wysiwyg.jsp   |    1 +
 .../wiki/htmltowiki/syntax/MarkupHelper.java       |    2 +-
 mvn_cheat-sheet.md                                 |    2 +-
 pom.xml                                            |   21 +-
 87 files changed, 1181 insertions(+), 1415 deletions(-)
 copy {jspwiki-bootstrap => jspwiki-http}/pom.xml (89%)
 create mode 100644 jspwiki-http/src/main/java/org/apache/wiki/http/filter/CsrfProtectionFilter.java
 copy jspwiki-api/src/main/java/org/apache/wiki/api/core/package.html => jspwiki-http/src/main/resources/META-INF/web-fragment.xml (56%)
 create mode 100644 jspwiki-main/src/main/java/org/apache/wiki/tags/CsrfProtectionTag.java
 create mode 100644 jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/WikiSyntaxConverter.java
 copy jspwiki-main/src/test/java/org/apache/wiki/filters/TestFilter.java => jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/filters/TidyMarkupFilter.java (63%)
 create mode 100644 jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/parser/JSPWikiToMarkdownMarkupParser.java


[jspwiki] 05/25: format class

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 903be0fd8bbb64e83c4eec95933186848a22e42e
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue May 3 23:01:40 2022 +0200

    format class
---
 .../apache/wiki/parser/JSPWikiMarkupParser.java    | 1624 +++++++-------------
 1 file changed, 530 insertions(+), 1094 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
index e5e0b425a..75de9478a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
@@ -73,9 +73,8 @@ import java.util.ResourceBundle;
 import java.util.Stack;
 
 /**
- *  Parses JSPWiki-style markup into a WikiDocument DOM tree.  This class is the
- *  heart and soul of JSPWiki : make sure you test properly anything that is added,
- *  or else it breaks down horribly.
+ * Parses JSPWiki-style markup into a WikiDocument DOM tree.  This class is the heart and soul of JSPWiki : make
+ * sure you test properly anything that is added, or else it breaks down horribly.
  *
  *  @since  2.4
  */
@@ -104,58 +103,58 @@ public class JSPWikiMarkupParser extends MarkupParser {
     private boolean        m_isPreBlock;
 
     /** Contains style information, in multiple forms. */
-    private final Stack<Boolean> m_styleStack   = new Stack<>();
+    private final Stack< Boolean > m_styleStack = new Stack<>();
 
      // general list handling
-    private int            m_genlistlevel;
-    private final StringBuilder  m_genlistBulletBuffer = new StringBuilder(10);  // stores the # and * pattern
-    private final boolean        m_allowPHPWikiStyleLists = true;
+    private int m_genlistlevel;
+    private final StringBuilder m_genlistBulletBuffer = new StringBuilder( 10 );  // stores the # and * pattern
+    private final boolean m_allowPHPWikiStyleLists = true;
 
-    private boolean        m_isOpenParagraph;
+    private boolean m_isOpenParagraph;
 
     /** Parser for extended link functionality. */
-    private final LinkParser     m_linkParser = new LinkParser();
+    private final LinkParser m_linkParser = new LinkParser();
 
     /** Keeps track of any plain text that gets put in the Text nodes */
-    private StringBuilder  m_plainTextBuf = new StringBuilder(20);
+    private StringBuilder m_plainTextBuf = new StringBuilder( 20 );
 
-    private Element        m_currentElement;
+    private Element m_currentElement;
 
     /** Keep track of duplicate header names.  */
-    private final Map<String, Integer>   m_titleSectionCounter = new HashMap<>();
+    private final Map< String, Integer > m_titleSectionCounter = new HashMap<>();
 
     /** If true, then considers CamelCase links as well. */
-    private boolean                m_camelCaseLinks;
+    private boolean m_camelCaseLinks;
 
     /** If true, then generate special output for wysiwyg editing in certain cases */
-    private boolean                m_wysiwygEditorMode;
+    private boolean m_wysiwygEditorMode;
 
     /** If true, consider URIs that have no brackets as well. */
     // FIXME: Currently reserved, but not used.
-    private boolean                m_plainUris;
+    private boolean m_plainUris;
 
     /** If true, all outward links use a small link image. */
-    private boolean                m_useOutlinkImage     = true;
+    private boolean m_useOutlinkImage = true;
 
-    private boolean                m_useAttachmentImage  = true;
+    private boolean m_useAttachmentImage = true;
 
     /** If true, allows raw HTML. */
-    private boolean                m_allowHTML;
+    private boolean m_allowHTML;
 
-    private boolean                m_useRelNofollow;
+    private boolean m_useRelNofollow;
 
-    private final PatternCompiler        m_compiler = new Perl5Compiler();
+    private final PatternCompiler m_compiler = new Perl5Compiler();
 
     static final String WIKIWORD_REGEX = "(^|[[:^alnum:]]+)([[:upper:]]+[[:lower:]]+[[:upper:]]+[[:alnum:]]*|(http://|https://|mailto:)([A-Za-z0-9_/\\.\\+\\?\\#\\-\\@=&;~%]+))";
 
-    private final PatternMatcher         m_camelCaseMatcher = new Perl5Matcher();
-    private Pattern                m_camelCasePattern;
+    private final PatternMatcher m_camelCaseMatcher = new Perl5Matcher();
+    private Pattern m_camelCasePattern;
 
-    private int                    m_rowNum              = 1;
+    private int m_rowNum = 1;
 
-    private Heading                m_lastHeading;
+    private Heading m_lastHeading;
 
-    private static final String CAMELCASE_PATTERN     = "JSPWikiMarkupParser.camelCasePattern";
+    private static final String CAMELCASE_PATTERN = "JSPWikiMarkupParser.camelCasePattern";
 
     /**
      *  Creates a markup parser.
@@ -163,8 +162,7 @@ public class JSPWikiMarkupParser extends MarkupParser {
      *  @param context The WikiContext which controls the parsing
      *  @param in Where the data is read from.
      */
-    public JSPWikiMarkupParser( final Context context, final Reader in )
-    {
+    public JSPWikiMarkupParser( final Context context, final Reader in ) {
         super( context, in );
         initialize();
     }
@@ -236,7 +234,7 @@ public class JSPWikiMarkupParser extends MarkupParser {
      *
      * @param param A Heading object.
      */
-    protected void callHeadingListenerChain( final Heading param ) {
+    private void callHeadingListenerChain( final Heading param ) {
         for( final HeadingListener h : m_headingListenerChain ) {
             h.headingAdded( m_context, param );
         }
@@ -253,38 +251,31 @@ public class JSPWikiMarkupParser extends MarkupParser {
      *  @return An A element.
      *  @since 2.4.78
      */
-    protected Element createAnchor( final int type, final String link, String text, String section)
-    {
+    private Element createAnchor( final int type, final String link, String text, String section ) {
         text = escapeHTMLEntities( text );
         section = escapeHTMLEntities( section );
-        final Element el = new Element("a");
-        el.setAttribute("class",CLASS_TYPES[type]);
-        el.setAttribute("href",link+section);
-        el.addContent(text);
+        final Element el = new Element( "a" );
+        el.setAttribute( "class", CLASS_TYPES[ type ] );
+        el.setAttribute( "href", link + section );
+        el.addContent( text );
         return el;
     }
 
-    private Element makeLink( int type, final String link, String text, String section, final Iterator< Attribute > attributes )
-    {
+    private Element makeLink( int type, final String link, String text, String section, final Iterator< Attribute > attributes ) {
         Element el = null;
-
-        if( text == null ) text = link;
-
+        if( text == null ) {
+            text = link;
+        }
         text = callMutatorChain( m_linkMutators, text );
-
         section = (section != null) ? ("#"+section) : "";
 
-        // Make sure we make a link name that can be accepted
-        // as a valid URL.
-
-        if( link.isEmpty() )
-        {
+        // Make sure we make a link name that can be accepted  as a valid URL.
+        if( link.isEmpty() ) {
             type = EMPTY;
         }
         final ResourceBundle rb = Preferences.getBundle( m_context, InternationalizationManager.CORE_BUNDLE );
 
-        switch(type)
-        {
+        switch( type ) {
             case READ:
                 el = createAnchor( READ, m_context.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), link), text, section );
                 break;
@@ -292,60 +283,53 @@ public class JSPWikiMarkupParser extends MarkupParser {
             case EDIT:
                 el = createAnchor( EDIT, m_context.getURL( ContextEnum.PAGE_EDIT.getRequestContext(),link), text, "" );
                 el.setAttribute("title", MessageFormat.format( rb.getString( "markupparser.link.create" ), link ) );
-
                 break;
 
             case EMPTY:
                 el = new Element("u").addContent(text);
                 break;
 
-                //
-                //  These two are for local references - footnotes and
-                //  references to footnotes.
-                //  We embed the page name (or whatever WikiContext gives us)
-                //  to make sure the links are unique across Wiki.
-                //
+            // These two are for local references - footnotes and references to footnotes.
+            // We embed the page name (or whatever WikiContext gives us) to make sure the links are unique across Wiki.
             case LOCALREF:
                 el = createAnchor( LOCALREF, "#ref-"+m_context.getName()+"-"+link, "["+text+"]", "" );
                 break;
 
             case LOCAL:
-                el = new Element("a").setAttribute("class",CLASS_FOOTNOTE);
-                el.setAttribute("name", "ref-"+m_context.getName()+"-"+link.substring(1));
-                el.addContent("["+text+"]");
+                el = new Element( "a" ).setAttribute( "class", CLASS_FOOTNOTE );
+                el.setAttribute( "name", "ref-" + m_context.getName() + "-" + link.substring( 1 ) );
+                el.addContent( "[" + text + "]" );
                 break;
 
-                //
-                //  With the image, external and interwiki types we need to
-                //  make sure nobody can put in Javascript or something else
-                //  annoying into the links themselves.  We do this by preventing
-                //  a haxor from stopping the link name short with quotes in
-                //  fillBuffer().
-                //
+                //  With the image, external and interwiki types we need to make sure nobody can put in Javascript or
+                //  something else annoying into the links themselves.  We do this by preventing a haxor from stopping
+                //  the link name short with quotes in fillBuffer().
             case IMAGE:
-                el = new Element("img").setAttribute("class","inline");
-                el.setAttribute("src",link);
-                el.setAttribute("alt",text);
+                el = new Element( "img" ).setAttribute( "class", "inline" );
+                el.setAttribute( "src", link );
+                el.setAttribute( "alt", text );
                 break;
 
             case IMAGELINK:
-                el = new Element("img").setAttribute("class","inline");
-                el.setAttribute("src",link);
-                el.setAttribute("alt",text);
-                el = createAnchor(IMAGELINK,text,"","").addContent(el);
+                el = new Element( "img" ).setAttribute( "class", "inline" );
+                el.setAttribute( "src", link );
+                el.setAttribute( "alt", text );
+                el = createAnchor( IMAGELINK, text, "", "" ).addContent( el );
                 break;
 
             case IMAGEWIKILINK:
                 final String pagelink = m_context.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), text );
-                el = new Element("img").setAttribute("class","inline");
-                el.setAttribute("src",link);
-                el.setAttribute("alt",text);
-                el = createAnchor(IMAGEWIKILINK,pagelink,"","").addContent(el);
+                el = new Element( "img" ).setAttribute( "class", "inline" );
+                el.setAttribute( "src", link );
+                el.setAttribute( "alt", text );
+                el = createAnchor( IMAGEWIKILINK, pagelink, "", "" ).addContent( el );
                 break;
 
             case EXTERNAL:
                 el = createAnchor( EXTERNAL, link, text, section );
-                if( m_useRelNofollow ) el.setAttribute("rel","nofollow");
+                if( m_useRelNofollow ) {
+                    el.setAttribute( "rel", "nofollow" );
+                }
                 break;
 
             case INTERWIKI:
@@ -357,25 +341,21 @@ public class JSPWikiMarkupParser extends MarkupParser {
                 final String infolink = m_context.getURL( ContextEnum.PAGE_INFO.getRequestContext(), link );
                 final String imglink = m_context.getURL( ContextEnum.PAGE_NONE.getRequestContext(), "images/attachment_small.png" );
                 el = createAnchor( ATTACHMENT, attlink, text, "" );
-
                 if(  m_engine.getManager( AttachmentManager.class ).forceDownload( attlink ) ) {
                     el.setAttribute("download", "");
                 }
 
-                pushElement(el);
-                popElement(el.getName());
+                pushElement( el );
+                popElement( el.getName() );
 
-                if( m_useAttachmentImage )
-                {
-                    el = new Element("img").setAttribute("src",imglink);
-                    el.setAttribute("border","0");
-                    el.setAttribute("alt","(info)");
+                if( m_useAttachmentImage ) {
+                    el = new Element( "img" ).setAttribute( "src", imglink );
+                    el.setAttribute( "border", "0" );
+                    el.setAttribute( "alt", "(info)" );
 
-                    el = new Element("a").setAttribute("href",infolink).addContent(el);
-                    el.setAttribute("class","infolink");
-                }
-                else
-                {
+                    el = new Element( "a" ).setAttribute( "href", infolink ).addContent( el );
+                    el.setAttribute( "class", "infolink" );
+                } else {
                     el = null;
                 }
                 break;
@@ -384,20 +364,16 @@ public class JSPWikiMarkupParser extends MarkupParser {
                 break;
         }
 
-        if( el != null && attributes != null )
-        {
-            while( attributes.hasNext() )
-            {
+        if( el != null && attributes != null ) {
+            while( attributes.hasNext() ) {
                 final Attribute attr = attributes.next();
-                if( attr != null )
-                {
-                    el.setAttribute(attr);
+                if( attr != null ) {
+                    el.setAttribute( attr );
                 }
             }
         }
 
-        if( el != null )
-        {
+        if( el != null ) {
             flushPlainText();
             m_currentElement.addContent( el );
         }
@@ -405,7 +381,7 @@ public class JSPWikiMarkupParser extends MarkupParser {
     }
 
     /**
-     *  These are all of the HTML 4.01 block-level elements.
+     *  These are all the HTML 4.01 block-level elements.
      */
     private static final String[] BLOCK_ELEMENTS = {
         "address", "blockquote", "div", "dl", "fieldset", "form",
@@ -413,87 +389,54 @@ public class JSPWikiMarkupParser extends MarkupParser {
         "hr", "noscript", "ol", "p", "pre", "table", "ul"
     };
 
-    private static boolean isBlockLevel( final String name )
-    {
+    private static boolean isBlockLevel( final String name ) {
         return Arrays.binarySearch( BLOCK_ELEMENTS, name ) >= 0;
     }
 
     /**
-     *  This method peeks ahead in the stream until EOL and returns the result.
-     *  It will keep the buffers untouched.
+     *  This method peeks ahead in the stream until EOL and returns the result. It will keep the buffers untouched.
      *
      *  @return The string from the current position to the end of line.
      */
-
     // FIXME: Always returns an empty line, even if the stream is full.
-    private String peekAheadLine()
-        throws IOException
-    {
+    private String peekAheadLine() throws IOException {
         final String s = readUntilEOL().toString();
-
-        if( s.length() > PUSHBACK_BUFFER_SIZE )
-        {
-            log.warn("Line is longer than maximum allowed size ("+PUSHBACK_BUFFER_SIZE+" characters.  Attempting to recover...");
-            pushBack( s.substring(0,PUSHBACK_BUFFER_SIZE-1) );
-        }
-        else
-        {
-            try
-            {
+        if( s.length() > PUSHBACK_BUFFER_SIZE ) {
+            log.warn( "Line is longer than maximum allowed size (" + PUSHBACK_BUFFER_SIZE + " characters.  Attempting to recover..." );
+            pushBack( s.substring( 0, PUSHBACK_BUFFER_SIZE - 1 ) );
+        } else {
+            try {
                 pushBack( s );
-            }
-            catch( final IOException e )
-            {
-                log.warn("Pushback failed: the line is probably too long.  Attempting to recover.");
+            } catch( final IOException e ) {
+                log.warn( "Pushback failed: the line is probably too long.  Attempting to recover." );
             }
         }
         return s;
     }
 
-    private int flushPlainText()
-    {
+    private int flushPlainText() {
         final int numChars = m_plainTextBuf.length();
-
-        if( numChars > 0 )
-        {
+        if( numChars > 0 ) {
             String buf;
 
-            if( !m_allowHTML )
-            {
+            if( !m_allowHTML ) {
                 buf = escapeHTMLEntities(m_plainTextBuf.toString());
-            }
-            else
-            {
+            } else {
                 buf = m_plainTextBuf.toString();
             }
-            //
-            //  We must first empty the buffer because the side effect of
-            //  calling makeCamelCaseLink() is to call this routine.
-            //
-
+            //  We must first empty the buffer because the side effect of calling makeCamelCaseLink() is to call this routine.
             m_plainTextBuf = new StringBuilder(20);
-
-            try
-            {
-                //
-                //  This is the heaviest part of parsing, and therefore we can
-                //  do some optimization here.
-                //
-                //  1) Only when the length of the buffer is big enough, we try to do the match
-                //
-
-                if( m_camelCaseLinks && !m_isEscaping && buf.length() > 3 )
-                {
-                    // System.out.println("Buffer="+buf);
-
-                    while( m_camelCaseMatcher.contains( buf, m_camelCasePattern ) )
-                    {
+            try {
+                // This is the heaviest part of parsing, and therefore we can do some optimization here.
+                // 1) Only when the length of the buffer is big enough, we try to do the match
+                if( m_camelCaseLinks && !m_isEscaping && buf.length() > 3 ) {
+                    while( m_camelCaseMatcher.contains( buf, m_camelCasePattern ) ) {
                         final MatchResult result = m_camelCaseMatcher.getMatch();
-
-                        final String firstPart = buf.substring(0,result.beginOffset(0));
-                        String prefix = result.group(1);
-
-                        if( prefix == null ) prefix = "";
+                        final String firstPart = buf.substring( 0, result.beginOffset( 0 ) );
+                        String prefix = result.group( 1 );
+                        if( prefix == null ) {
+                            prefix = "";
+                        }
 
                         final String camelCase = result.group(2);
                         final String protocol  = result.group(3);
@@ -501,74 +444,47 @@ public class JSPWikiMarkupParser extends MarkupParser {
                         buf              = buf.substring(result.endOffset(0));
 
                         m_currentElement.addContent( firstPart );
-
-                        //
                         //  Check if the user does not wish to do URL or WikiWord expansion
-                        //
-                        if( prefix.endsWith("~") || prefix.indexOf('[') != -1 )
-                        {
-                            if( prefix.endsWith("~") )
-                            {
-                                if( m_wysiwygEditorMode )
-                                {
+                        if( prefix.endsWith( "~" ) || prefix.indexOf( '[' ) != -1 ) {
+                            if( prefix.endsWith( "~" ) ) {
+                                if( m_wysiwygEditorMode ) {
                                     m_currentElement.addContent( "~" );
                                 }
-                                prefix = prefix.substring(0,prefix.length()-1);
-                            }
-                            if( camelCase != null )
-                            {
-                                m_currentElement.addContent( prefix+camelCase );
+                                prefix = prefix.substring( 0, prefix.length() - 1 );
                             }
-                            else if( protocol != null )
-                            {
-                                m_currentElement.addContent( prefix+uri );
+                            if( camelCase != null ) {
+                                m_currentElement.addContent( prefix + camelCase );
+                            } else if( protocol != null ) {
+                                m_currentElement.addContent( prefix + uri );
                             }
                             continue;
                         }
 
-                        //
-                        //  Fine, then let's check what kind of a link this was
-                        //  and emit the proper elements
-                        //
-                        if( protocol != null )
-                        {
-                            final char c = uri.charAt(uri.length()-1);
-                            if( c == '.' || c == ',' )
-                            {
-                                uri = uri.substring(0,uri.length()-1);
+                        // Fine, then let's check what kind of link this was and emit the proper elements
+                        if( protocol != null ) {
+                            final char c = uri.charAt( uri.length() - 1 );
+                            if( c == '.' || c == ',' ) {
+                                uri = uri.substring( 0, uri.length() - 1 );
                                 buf = c + buf;
                             }
                             // System.out.println("URI match "+uri);
                             m_currentElement.addContent( prefix );
                             makeDirectURILink( uri );
-                        }
-                        else
-                        {
+                        } else {
                             // System.out.println("Matched: '"+camelCase+"'");
                             // System.out.println("Split to '"+firstPart+"', and '"+buf+"'");
                             // System.out.println("prefix="+prefix);
                             m_currentElement.addContent( prefix );
-
                             makeCamelCaseLink( camelCase );
                         }
                     }
-
                     m_currentElement.addContent( buf );
-                }
-                else
-                {
-                    //
+                } else {
                     //  No camelcase asked for, just add the elements
-                    //
                     m_currentElement.addContent( buf );
                 }
-            }
-            catch( final IllegalDataException e )
-            {
-                //
-                // Sometimes it's possible that illegal XML chars is added to the data.
-                // Here we make sure it does not stop parsing.
-                //
+            } catch( final IllegalDataException e ) {
+                // Sometimes it's possible that illegal XML chars is added to the data. Here we make sure it does not stop parsing.
                 m_currentElement.addContent( makeError(cleanupSuspectData( e.getMessage() )) );
             }
         }
@@ -577,78 +493,48 @@ public class JSPWikiMarkupParser extends MarkupParser {
     }
 
     /**
-     *  Escapes XML entities in a HTML-compatible way (i.e. does not escape
-     *  entities that are already escaped).
+     *  Escapes XML entities in a HTML-compatible way (i.e. does not escape entities that are already escaped).
      *
      *  @param buf
      *  @return An escaped string.
      */
-    private String escapeHTMLEntities( final String buf)
-    {
+    private String escapeHTMLEntities( final String buf ) {
         final StringBuilder tmpBuf = new StringBuilder( buf.length() + 20 );
-
-        for( int i = 0; i < buf.length(); i++ )
-        {
+        for( int i = 0; i < buf.length(); i++ ) {
             final char ch = buf.charAt(i);
-
-            if( ch == '<' )
-            {
+            if( ch == '<' ) {
                 tmpBuf.append("&lt;");
-            }
-            else if( ch == '>' )
-            {
+            } else if( ch == '>' ) {
                 tmpBuf.append("&gt;");
-            }
-            else if( ch == '\"' )
-            {
+            } else if( ch == '\"' ) {
                 tmpBuf.append("&quot;");
-            }
-            else if( ch == '&' )
-            {
-                //
-                //  If the following is an XML entity reference (&#.*;) we'll
-                //  leave it as it is; otherwise we'll replace it with an &amp;
-                //
-
+            } else if( ch == '&' ) {
+                // If the following is an XML entity reference (&#.*;) we'll leave it as it is; otherwise we'll replace it with an &amp;
                 boolean isEntity = false;
                 final StringBuilder entityBuf = new StringBuilder();
-
-                if( i < buf.length() -1 )
-                {
-                    for( int j = i; j < buf.length(); j++ )
-                    {
-                        final char ch2 = buf.charAt(j);
-
-                        if( Character.isLetterOrDigit( ch2 ) || (ch2 == '#' && j == i+1) || ch2 == ';' || ch2 == '&' )
-                        {
+                if( i < buf.length() -1 ) {
+                    for( int j = i; j < buf.length(); j++ ) {
+                        final char ch2 = buf.charAt( j );
+                        if( Character.isLetterOrDigit( ch2 ) || (ch2 == '#' && j == i+1) || ch2 == ';' || ch2 == '&' ) {
                             entityBuf.append(ch2);
-
-                            if( ch2 == ';' )
-                            {
+                            if( ch2 == ';' ) {
                                 isEntity = true;
                                 break;
                             }
-                        }
-                        else
-                        {
+                        } else {
                             break;
                         }
                     }
                 }
 
-                if( isEntity )
-                {
+                if( isEntity ) {
                     tmpBuf.append( entityBuf );
                     i = i + entityBuf.length() - 1;
-                }
-                else
-                {
-                    tmpBuf.append("&amp;");
+                } else {
+                    tmpBuf.append( "&amp;" );
                 }
 
-            }
-            else
-            {
+            } else {
                 tmpBuf.append( ch );
             }
         }
@@ -656,8 +542,7 @@ public class JSPWikiMarkupParser extends MarkupParser {
         return tmpBuf.toString();
     }
 
-    private Element pushElement( final Element e )
-    {
+    private Element pushElement( final Element e ) {
         flushPlainText();
         m_currentElement.addContent( e );
         m_currentElement = e;
@@ -665,10 +550,8 @@ public class JSPWikiMarkupParser extends MarkupParser {
         return e;
     }
 
-    private Element addElement( final Content e )
-    {
-        if( e != null )
-        {
+    private Element addElement( final Content e ) {
+        if( e != null ) {
             flushPlainText();
             m_currentElement.addContent( e );
         }
@@ -687,73 +570,51 @@ public class JSPWikiMarkupParser extends MarkupParser {
      *  Goes through the current element stack and pops all elements until this
      *  element is found - this essentially "closes" and element.
      *
-     *  @param s
+     *  @param s element to be found.
      *  @return The new current element, or null, if there was no such element in the entire stack.
      */
-    private Element popElement( final String s )
-    {
+    private Element popElement( final String s ) {
         final int flushedBytes = flushPlainText();
-
         Element currEl = m_currentElement;
-
-        while( currEl.getParentElement() != null )
-        {
-            if( currEl.getName().equals(s) && !currEl.isRootElement() )
-            {
+        while( currEl.getParentElement() != null ) {
+            if( currEl.getName().equals( s ) && !currEl.isRootElement() ) {
                 m_currentElement = currEl.getParentElement();
 
-                //
                 //  Check if it's okay for this element to be empty.  Then we will
                 //  trick the JDOM generator into not generating an empty element,
                 //  by putting an empty string between the tags.  Yes, it's a kludge
                 //  but what'cha gonna do about it. :-)
-                //
-
-                if( flushedBytes == 0 && Arrays.binarySearch( EMPTY_ELEMENTS, s ) < 0 )
-                {
-                    currEl.addContent("");
+                if( flushedBytes == 0 && Arrays.binarySearch( EMPTY_ELEMENTS, s ) < 0 ) {
+                    currEl.addContent( "" );
                 }
-
                 return m_currentElement;
             }
-
             currEl = currEl.getParentElement();
         }
-
         return null;
     }
 
 
     /**
-     *  Reads the stream until it meets one of the specified
-     *  ending characters, or stream end.  The ending character will be left
-     *  in the stream.
+     * Reads the stream until it meets one of the specified ending characters, or stream end. The ending
+     * character will be left in the stream.
      */
-    private String readUntil( final String endChars )
-        throws IOException
-    {
+    private String readUntil( final String endChars ) throws IOException {
         final StringBuilder sb = new StringBuilder( 80 );
         int ch = nextToken();
-
-        while( ch != -1 )
-        {
-            if( ch == '\\' )
-            {
+        while( ch != -1 ) {
+            if( ch == '\\' ) {
                 ch = nextToken();
-                if( ch == -1 )
-                {
+                if( ch == -1 ) {
                     break;
                 }
-            }
-            else
-            {
-                if( endChars.indexOf((char)ch) != -1 )
-                {
+            } else {
+                if( endChars.indexOf( ( char )ch ) != -1 ) {
                     pushBack( ch );
                     break;
                 }
             }
-            sb.append( (char) ch );
+            sb.append( ( char )ch );
             ch = nextToken();
         }
 
@@ -764,21 +625,15 @@ public class JSPWikiMarkupParser extends MarkupParser {
      *  Reads the stream while the characters that have been specified are
      *  in the stream, returning then the result as a String.
      */
-    private String readWhile( final String endChars )
-        throws IOException
-    {
+    private String readWhile( final String endChars ) throws IOException {
         final StringBuilder sb = new StringBuilder( 80 );
         int ch = nextToken();
-
-        while( ch != -1 )
-        {
-            if( endChars.indexOf((char)ch) == -1 )
-            {
+        while( ch != -1 ) {
+            if( endChars.indexOf( ( char ) ch ) == -1 ) {
                 pushBack( ch );
                 break;
             }
-
-            sb.append( (char) ch );
+            sb.append( ( char ) ch );
             ch = nextToken();
         }
 
@@ -800,6 +655,7 @@ public class JSPWikiMarkupParser extends MarkupParser {
 
         return m_cleanTranslator;
     }
+
     /**
      *  Modifies the "hd" parameter to contain proper values.  Because
      *  an "id" tag may only contain [a-zA-Z0-9:_-], we'll replace the
@@ -808,11 +664,10 @@ public class JSPWikiMarkupParser extends MarkupParser {
      *  Counts also duplicate headings (= headings with similar name), and
      *  attaches a counter.
      */
-    private String makeHeadingAnchor( final String baseName, String title, final Heading hd ) {
+    protected String makeHeadingAnchor( final String baseName, String title, final Heading hd ) {
         hd.m_titleText = title;
         title = MarkupParser.wikifyLink( title );
         hd.m_titleSection = m_engine.encodeName(title);
-
         if( m_titleSectionCounter.containsKey( hd.m_titleSection ) ) {
             final Integer count = m_titleSectionCounter.get( hd.m_titleSection ) + 1;
             m_titleSectionCounter.put( hd.m_titleSection, count );
@@ -878,16 +733,12 @@ public class JSPWikiMarkupParser extends MarkupParser {
     }
 
     /**
-     *  When given a link to a WikiName, we just return
-     *  a proper HTML link for it.  The local link mutator
+     *  When given a link to a WikiName, we just return a proper HTML link for it.  The local link mutator
      *  chain is also called.
      */
-    private Element makeCamelCaseLink( final String wikiname )
-    {
+    private Element makeCamelCaseLink( final String wikiname ) {
         final String matchedLink = m_linkParsingOperations.linkIfExists( wikiname );
-
         callMutatorChain( m_localLinkMutatorChain, wikiname );
-
         if( matchedLink != null ) {
             makeLink( READ, matchedLink, wikiname, null, null );
         } else {
@@ -901,21 +752,16 @@ public class JSPWikiMarkupParser extends MarkupParser {
     private String m_outlinkImageURL;
 
     /**
-     *  Returns an element for the external link image (out.png).  However,
-     *  this method caches the URL for the lifetime of this MarkupParser,
-     *  because it's commonly used, and we'll end up with possibly hundreds
-     *  our thousands of references to it...  It's a lot faster, too.
+     * Returns an element for the external link image (out.png).  However, this method caches the URL for the lifetime
+     * of this MarkupParser, because it's commonly used, and we'll end up with possibly hundreds our thousands of
+     * references to it...  It's a lot faster, too.
      *
-     *  @return  An element containing the HTML for the outlink image.
+     * @return  An element containing the HTML for the outlink image.
      */
-    private Element outlinkImage()
-    {
+    private Element outlinkImage() {
         Element el = null;
-
-        if( m_useOutlinkImage )
-        {
-            if( m_outlinkImageURL == null )
-            {
+        if( m_useOutlinkImage ) {
+            if( m_outlinkImageURL == null ) {
                 m_outlinkImageURL = m_context.getURL( ContextEnum.PAGE_NONE.getRequestContext(), OUTLINK_IMAGE );
             }
 
@@ -928,14 +774,13 @@ public class JSPWikiMarkupParser extends MarkupParser {
     }
 
     /**
-     *  Takes an URL and turns it into a regular wiki link.  Unfortunately,
-     *  because of the way that flushPlainText() works, it already encodes
-     *  all of the XML entities.  But so does WikiContext.getURL(), so we
+     *  Takes a URL and turns it into a regular wiki link. Unfortunately, because of the way that flushPlainText()
+     *  works, it already encodes all the XML entities. But so does WikiContext.getURL(), so we
      *  have to do a reverse-replace here, so that it can again be replaced in makeLink.
      *  <p>
      *  What a crappy problem.
      *
-     * @param url
+     * @param url provided url.
      * @return An anchor Element containing the link.
      */
     private Element makeDirectURILink( String url ) {
@@ -965,10 +810,9 @@ public class JSPWikiMarkupParser extends MarkupParser {
 
     /**
      *  Image links are handled differently:
-     *  1. If the text is a WikiName of an existing page,
-     *     it gets linked.
+     *  1. If the text is a WikiName of an existing page, it gets linked.
      *  2. If the text is an external link, then it is inlined.
-     *  3. Otherwise it becomes an ALT text.
+     *  3. Otherwise, it becomes an ALT text.
      *
      *  @param reallink The link to the image.
      *  @param link     Link text portion, may be a link to somewhere else.
@@ -976,25 +820,14 @@ public class JSPWikiMarkupParser extends MarkupParser {
      *                  This means that the link text may be a link to a wiki page,
      *                  or an external resource.
      */
-
-    // FIXME: isExternalLink() is called twice.
-    private Element handleImageLink( final String reallink, final String link, final boolean hasLinkText )
-    {
+    private Element handleImageLink( final String reallink, final String link, final boolean hasLinkText ) {
         final String possiblePage = MarkupParser.cleanLink( link );
-
-        if( m_linkParsingOperations.isExternalLink( link ) && hasLinkText )
-        {
+        if( m_linkParsingOperations.isExternalLink( link ) && hasLinkText ) {
             return makeLink( IMAGELINK, reallink, link, null, null );
-        }
-        else if( m_linkParsingOperations.linkExists( possiblePage ) && hasLinkText )
-        {
-            // System.out.println("Orig="+link+", Matched: "+matchedLink);
+        } else if( m_linkParsingOperations.linkExists( possiblePage ) && hasLinkText ) {
             callMutatorChain( m_localLinkMutatorChain, possiblePage );
-
             return makeLink( IMAGEWIKILINK, reallink, link, null, null );
-        }
-        else
-        {
+        } else {
             return makeLink( IMAGE, reallink, link, null, null );
         }
     }
@@ -1003,7 +836,6 @@ public class JSPWikiMarkupParser extends MarkupParser {
         if( m_wysiwygEditorMode ) {
             m_currentElement.addContent( "[" + ruleLine + "]" );
         }
-
         if( !m_parseAccessRules ) {
             return m_currentElement;
         }
@@ -1068,7 +900,6 @@ public class JSPWikiMarkupParser extends MarkupParser {
     /**
      *  Emits a processing instruction that will disable markup escaping. This is
      *  very useful if you want to emit HTML directly into the stream.
-     *
      */
     private void disableOutputEscaping() {
         addElement( new ProcessingInstruction( Result.PI_DISABLE_OUTPUT_ESCAPING, "" ) );
@@ -1109,7 +940,6 @@ public class JSPWikiMarkupParser extends MarkupParser {
                     		                                            e.getMessage() ) ) );
                 }
             }
-
             return m_currentElement;
         }
 
@@ -1117,23 +947,16 @@ public class JSPWikiMarkupParser extends MarkupParser {
             final LinkParser.Link link = m_linkParser.parse( linktext );
             linktext = link.getText();
             String linkref = link.getReference();
-
-            //
             //  Yes, we now have the components separated.
             //  linktext = the text the link should have
             //  linkref  = the url or page name.
-            //
             //  In many cases these are the same.  [linktext|linkref].
-            //
             if( m_linkParsingOperations.isVariableLink( linktext ) ) {
                 final Content el = new VariableContent( linktext );
-
                 addElement( el );
             } else if( m_linkParsingOperations.isExternalLink( linkref ) ) {
                 // It's an external link, out of this Wiki
-
                 callMutatorChain( m_externalLinkMutatorChain, linkref );
-
                 if( m_linkParsingOperations.isImageLink( linkref, isImageInlining(), getInlineImagePatterns() ) ) {
                     handleImageLink( linkref, linktext, link.hasReference() );
                 } else {
@@ -1152,12 +975,10 @@ public class JSPWikiMarkupParser extends MarkupParser {
 
                 final String extWiki = link.getExternalWiki();
                 final String wikiPage = link.getExternalWikiPage();
-
                 if( m_wysiwygEditorMode ) {
                     makeLink( INTERWIKI, extWiki + ":" + wikiPage, linktext, null, link.getAttributes() );
                 } else {
                     String urlReference = m_engine.getInterWikiURL( extWiki );
-
                     if( urlReference != null ) {
                         urlReference = TextUtil.replaceString( urlReference, "%s", wikiPage );
                         urlReference = callMutatorChain( m_externalLinkMutatorChain, urlReference );
@@ -1167,13 +988,11 @@ public class JSPWikiMarkupParser extends MarkupParser {
                         } else {
                             makeLink( INTERWIKI, urlReference, linktext, null, link.getAttributes() );
                         }
-
                         if( m_linkParsingOperations.isExternalLink( urlReference ) ) {
                             addElement( outlinkImage() );
                         }
                     } else {
                         final Object[] args = { escapeHTMLEntities( extWiki ) };
-
                         addElement( makeError( MessageFormat.format( rb.getString( "markupparser.error.nointerwikiref" ), args ) ) );
                     }
                 }
@@ -1190,7 +1009,6 @@ public class JSPWikiMarkupParser extends MarkupParser {
                 String attachment = m_engine.getManager( AttachmentManager.class ).getAttachmentInfoName( m_context, linkref );
                 if( attachment != null ) {
                     callMutatorChain( m_attachmentLinkMutatorChain, attachment );
-
                     if( m_linkParsingOperations.isImageLink( linkref, isImageInlining(), getInlineImagePatterns() ) ) {
                         attachment = m_context.getURL( ContextEnum.PAGE_ATTACH.getRequestContext(), attachment );
                         sb.append( handleImageLink( attachment, linktext, link.hasReference() ) );
@@ -1199,14 +1017,10 @@ public class JSPWikiMarkupParser extends MarkupParser {
                     }
                 } else if( ( hashMark = linkref.indexOf( '#' ) ) != -1 ) {
                     // It's an internal Wiki link, but to a named section
-
                     final String namedSection = linkref.substring( hashMark + 1 );
                     linkref = linkref.substring( 0, hashMark );
-
                     linkref = MarkupParser.cleanLink( linkref );
-
                     callMutatorChain( m_localLinkMutatorChain, linkref );
-
                     final String matchedLink = m_linkParsingOperations.linkIfExists( linkref );
                     if( matchedLink != null ) {
                         String sectref = "section-" + m_engine.encodeName( matchedLink + "-" + wikifyLink( namedSection ) );
@@ -1218,9 +1032,7 @@ public class JSPWikiMarkupParser extends MarkupParser {
                 } else {
                     // It's an internal Wiki link
                     linkref = MarkupParser.cleanLink( linkref );
-
                     callMutatorChain( m_localLinkMutatorChain, linkref );
-
                     final String matchedLink = m_linkParsingOperations.linkIfExists( linkref );
                     if( matchedLink != null ) {
                         makeLink( READ, matchedLink, linktext, null, link.getAttributes() );
@@ -1230,75 +1042,52 @@ public class JSPWikiMarkupParser extends MarkupParser {
                 }
             }
 
-    } catch( final ParseException e ) {
-        log.info( "Parser failure: ", e );
-        final Object[] args = { e.getMessage() };
-        addElement( makeError( MessageFormat.format( rb.getString( "markupparser.error.parserfailure" ), args ) ) );
-    }
+        } catch( final ParseException e ) {
+            log.info( "Parser failure: ", e );
+            final Object[] args = { e.getMessage() };
+            addElement( makeError( MessageFormat.format( rb.getString( "markupparser.error.parserfailure" ), args ) ) );
+        }
         return m_currentElement;
     }
 
     /**
-     *  Pushes back any string that has been read.  It will obviously
-     *  be pushed back in a reverse order.
+     *  Pushes back any string that has been read.  It will obviously be pushed back in a reverse order.
      *
      *  @since 2.1.77
      */
-    private void pushBack( final String s )
-        throws IOException
-    {
-        for( int i = s.length()-1; i >= 0; i-- )
-        {
+    private void pushBack( final String s ) throws IOException {
+        for( int i = s.length()-1; i >= 0; i-- ) {
             pushBack( s.charAt(i) );
         }
     }
 
-    private Element handleBackslash()
-        throws IOException
-    {
+    private Element handleBackslash() throws IOException {
         final int ch = nextToken();
-
-        if( ch == '\\' )
-        {
+        if( ch == '\\' ) {
             final int ch2 = nextToken();
-
-            if( ch2 == '\\' )
-            {
-                pushElement( new Element("br").setAttribute("clear","all"));
-                return popElement("br");
+            if( ch2 == '\\' ) {
+                pushElement( new Element( "br" ).setAttribute( "clear", "all" ) );
+                return popElement( "br" );
             }
-
             pushBack( ch2 );
-
-            pushElement( new Element("br") );
-            return popElement("br");
+            pushElement( new Element( "br" ) );
+            return popElement( "br" );
         }
-
         pushBack( ch );
-
         return null;
     }
 
-    private Element handleUnderscore()
-        throws IOException
-    {
+    private Element handleUnderscore() throws IOException {
         final int ch = nextToken();
         Element el = null;
-
-        if( ch == '_' )
-        {
-            if( m_isbold )
-            {
-                el = popElement("b");
-            }
-            else
-            {
-                el = pushElement( new Element("b") );
+        if( ch == '_' ) {
+            if( m_isbold ) {
+                el = popElement( "b" );
+            } else {
+                el = pushElement( new Element( "b" ) );
             }
             m_isbold = !m_isbold;
-        }
-        else
-        {
+        } else {
             pushBack( ch );
         }
 
@@ -1309,215 +1098,145 @@ public class JSPWikiMarkupParser extends MarkupParser {
     /**
      *  For example: italics.
      */
-    private Element handleApostrophe()
-        throws IOException
-    {
+    private Element handleApostrophe() throws IOException {
         final int ch = nextToken();
         Element el = null;
 
-        if( ch == '\'' )
-        {
-            if( m_isitalic )
-            {
-                el = popElement("i");
-            }
-            else
-            {
-                el = pushElement( new Element("i") );
+        if( ch == '\'' ) {
+            if( m_isitalic ) {
+                el = popElement( "i" );
+            } else {
+                el = pushElement( new Element( "i" ) );
             }
             m_isitalic = !m_isitalic;
-        }
-        else
-        {
+        } else {
             pushBack( ch );
         }
 
         return el;
     }
 
-    private Element handleOpenbrace( final boolean isBlock )
-        throws IOException
-    {
+    private Element handleOpenbrace( final boolean isBlock ) throws IOException {
         final int ch = nextToken();
-
-        if( ch == '{' )
-        {
+        if( ch == '{' ) {
             final int ch2 = nextToken();
-
-            if( ch2 == '{' )
-            {
+            if( ch2 == '{' ) {
                 m_isPre = true;
                 m_isEscaping = true;
                 m_isPreBlock = isBlock;
-
-                if( isBlock )
-                {
+                if( isBlock ) {
                     startBlockLevel();
-                    return pushElement( new Element("pre") );
+                    return pushElement( new Element( "pre" ) );
                 }
 
-                return pushElement( new Element("span").setAttribute("class","inline-code") );
+                return pushElement( new Element( "span" ).setAttribute( "class", "inline-code" ) );
             }
-
             pushBack( ch2 );
-
-            return pushElement( new Element("tt") );
+            return pushElement( new Element( "tt" ) );
         }
-
         pushBack( ch );
-
         return null;
     }
 
     /**
      *  Handles both }} and }}}
      */
-    private Element handleClosebrace()
-        throws IOException
-    {
+    private Element handleClosebrace() throws IOException {
         final int ch2 = nextToken();
-
-        if( ch2 == '}' )
-        {
+        if( ch2 == '}' ) {
             final int ch3 = nextToken();
-
-            if( ch3 == '}' )
-            {
-                if( m_isPre )
-                {
-                    if( m_isPreBlock )
-                    {
+            if( ch3 == '}' ) {
+                if( m_isPre ) {
+                    if( m_isPreBlock ) {
                         popElement( "pre" );
-                    }
-                    else
-                    {
+                    } else {
                         popElement( "span" );
                     }
-
                     m_isPre = false;
                     m_isEscaping = false;
                     return m_currentElement;
                 }
-
-                m_plainTextBuf.append("}}}");
+                m_plainTextBuf.append( "}}}" );
                 return m_currentElement;
             }
-
             pushBack( ch3 );
-
-            if( !m_isEscaping )
-            {
-                return popElement("tt");
+            if( !m_isEscaping ) {
+                return popElement( "tt" );
             }
         }
-
         pushBack( ch2 );
-
         return null;
     }
 
-    private Element handleDash()
-        throws IOException
-    {
+    private Element handleDash() throws IOException {
         int ch = nextToken();
-
-        if( ch == '-' )
-        {
+        if( ch == '-' ) {
             final int ch2 = nextToken();
-
-            if( ch2 == '-' )
-            {
+            if( ch2 == '-' ) {
                 final int ch3 = nextToken();
-
-                if( ch3 == '-' )
-                {
+                if( ch3 == '-' ) {
                     // Empty away all the rest of the dashes.
                     // Do not forget to return the first non-match back.
-                    do
-                    {
+                    do {
                         ch = nextToken();
-                    }
-                    while ( ch == '-' );
+                    } while ( ch == '-' );
 
-                    pushBack(ch);
+                    pushBack( ch );
                     startBlockLevel();
-                    pushElement( new Element("hr") );
+                    pushElement( new Element( "hr" ) );
                     return popElement( "hr" );
                 }
-
                 pushBack( ch3 );
             }
             pushBack( ch2 );
         }
-
         pushBack( ch );
-
         return null;
     }
 
-    private Element handleHeading()
-        throws IOException
-    {
-        Element el;
-
+    private Element handleHeading() throws IOException {
+        final Element el;
         final int ch  = nextToken();
-
         final Heading hd = new Heading();
-
-        if( ch == '!' )
-        {
+        if( ch == '!' ) {
             final int ch2 = nextToken();
-
-            if( ch2 == '!' )
-            {
+            if( ch2 == '!' ) {
                 final String title = peekAheadLine();
-
-                el = makeHeading( Heading.HEADING_LARGE, title, hd);
-            }
-            else
-            {
+                el = makeHeading( Heading.HEADING_LARGE, title, hd );
+            } else {
                 pushBack( ch2 );
                 final String title = peekAheadLine();
                 el = makeHeading( Heading.HEADING_MEDIUM, title, hd );
             }
-        }
-        else
-        {
+        } else {
             pushBack( ch );
             final String title = peekAheadLine();
             el = makeHeading( Heading.HEADING_SMALL, title, hd );
         }
 
         callHeadingListenerChain( hd );
-
         m_lastHeading = hd;
-
-        if( el != null ) pushElement(el);
-
+        if( el != null ) {
+            pushElement( el );
+        }
         return el;
     }
 
     /**
-     *  Reads the stream until the next EOL or EOF.  Note that it will also read the
-     *  EOL from the stream.
+     * Reads the stream until the next EOL or EOF.  Note that it will also read the EOL from the stream.
      */
-    private StringBuilder readUntilEOL()
-        throws IOException
-    {
+    private StringBuilder readUntilEOL() throws IOException {
         int ch;
         final StringBuilder buf = new StringBuilder( 256 );
-
-        while( true )
-        {
+        while( true ) {
             ch = nextToken();
-
-            if( ch == -1 )
+            if( ch == -1 ) {
                 break;
-
+            }
             buf.append( (char) ch );
-
-            if( ch == '\n' )
+            if( ch == '\n' ) {
                 break;
+            }
         }
         return buf;
     }
@@ -1530,279 +1249,191 @@ public class JSPWikiMarkupParser extends MarkupParser {
     private boolean m_newLine;
 
     /**
-     *  Starts a block level element, therefore closing
-     *  a potential open paragraph tag.
+     * Starts a block level element, therefore closing a potential open paragraph tag.
      */
-    private void startBlockLevel()
-    {
+    private void startBlockLevel() {
         // These may not continue over block level limits in XHTML
-
-        popElement("i");
-        popElement("b");
-        popElement("tt");
-
-        if( m_isOpenParagraph )
-        {
+        popElement( "i" );
+        popElement( "b" );
+        popElement( "tt" );
+        if( m_isOpenParagraph ) {
             m_isOpenParagraph = false;
-            popElement("p");
-            m_plainTextBuf.append("\n"); // Just small beautification
+            popElement( "p" );
+            m_plainTextBuf.append( "\n" ); // Just small beautification
         }
-
         m_restartitalic = m_isitalic;
         m_restartbold   = m_isbold;
-
         m_isitalic = false;
         m_isbold   = false;
     }
 
-    private static String getListType( final char c )
-    {
-        if( c == '*' )
-        {
+    private static String getListType( final char c ) {
+        if( c == '*' ) {
             return "ul";
-        }
-        else if( c == '#' )
-        {
+        } else if( c == '#' ) {
             return "ol";
         }
-        throw new InternalWikiException("Parser got faulty list type: "+c);
+        throw new InternalWikiException( "Parser got faulty list type: " + c );
     }
     /**
-     *  Like original handleOrderedList() and handleUnorderedList()
-     *  however handles both ordered ('#') and unordered ('*') mixed together.
+     * Like original handleOrderedList() and handleUnorderedList(),
+     * however handles both ordered ('#') and unordered ('*') mixed together.
      */
-
     // FIXME: Refactor this; it's a bit messy.
-
-    private Element handleGeneralList()
-        throws IOException
-    {
+    private Element handleGeneralList() throws IOException {
          startBlockLevel();
-
          String strBullets = readWhile( "*#" );
          // String strBulletsRaw = strBullets;      // to know what was original before phpwiki style substitution
          final int numBullets = strBullets.length();
 
-         // override the beginning portion of bullet pattern to be like the previous
-         // to simulate PHPWiki style lists
-
-         if(m_allowPHPWikiStyleLists)
-         {
-             // only substitute if different
-             if(!( strBullets.substring(0,Math.min(numBullets,m_genlistlevel)).equals
-                   (m_genlistBulletBuffer.substring(0,Math.min(numBullets,m_genlistlevel)) ) ) )
-             {
-                 if(numBullets <= m_genlistlevel)
-                 {
-                     // Substitute all but the last character (keep the expressed bullet preference)
-                     strBullets  = (numBullets > 1 ? m_genlistBulletBuffer.substring(0, numBullets-1) : "")
-                                   + strBullets.charAt( numBullets-1 );
-                 }
-                 else
-                 {
-                     strBullets = m_genlistBulletBuffer + strBullets.substring(m_genlistlevel, numBullets);
-                 }
-             }
-         }
-
-         //
+         // override the beginning portion of bullet pattern to be like the previous to simulate PHPWiki style lists
+
+        if( m_allowPHPWikiStyleLists ) {
+            // only substitute if different
+            if( !( strBullets.substring( 0, Math.min( numBullets, m_genlistlevel ) ).equals( m_genlistBulletBuffer.substring( 0, Math.min( numBullets, m_genlistlevel ) ) ) ) ) {
+                if( numBullets <= m_genlistlevel ) {
+                    // Substitute all but the last character (keep the expressed bullet preference)
+                    strBullets = ( numBullets > 1 ? m_genlistBulletBuffer.substring( 0, numBullets - 1 ) : "" ) +
+                                 strBullets.charAt( numBullets - 1 );
+                } else {
+                    strBullets = m_genlistBulletBuffer + strBullets.substring( m_genlistlevel, numBullets );
+                }
+            }
+        }
+
          //  Check if this is still of the same type
-         //
-         if( strBullets.substring(0,Math.min(numBullets,m_genlistlevel)).equals
-            (m_genlistBulletBuffer.substring(0,Math.min(numBullets,m_genlistlevel)) ) )
-         {
-             if( numBullets > m_genlistlevel )
-             {
-                 pushElement( new Element( getListType(strBullets.charAt(m_genlistlevel++) ) ) );
-
-                 for( ; m_genlistlevel < numBullets; m_genlistlevel++ )
-                 {
-                     // bullets are growing, get from new bullet list
-                     pushElement( new Element("li") );
-                     pushElement( new Element( getListType(strBullets.charAt(m_genlistlevel)) ));
-                 }
-             }
-             else if( numBullets < m_genlistlevel )
-             {
-                 //  Close the previous list item.
-                 // buf.append( m_renderer.closeListItem() );
-                 popElement( "li" );
-
-                 for( ; m_genlistlevel > numBullets; m_genlistlevel-- )
-                 {
-                     // bullets are shrinking, get from old bullet list
-
-                     popElement( getListType(m_genlistBulletBuffer.charAt(m_genlistlevel-1)) );
-                     if( m_genlistlevel > 0 )
-                     {
-                         popElement( "li" );
-                     }
-
-                 }
-             }
-             else
-             {
-                 if( m_genlistlevel > 0 )
-                 {
-                     popElement( "li" );
-                 }
-             }
-         }
-         else
-         {
-             //
-             //  The pattern has changed, unwind and restart
-             //
-             int  numEqualBullets;
-             final int  numCheckBullets;
-
-             // find out how much is the same
-             numEqualBullets = 0;
-             numCheckBullets = Math.min(numBullets,m_genlistlevel);
-
-             while( numEqualBullets < numCheckBullets )
-             {
-                 // if the bullets are equal so far, keep going
-                 if( strBullets.charAt(numEqualBullets) == m_genlistBulletBuffer.charAt(numEqualBullets))
-                     numEqualBullets++;
-                 // otherwise giveup, we have found how many are equal
-                 else
-                     break;
-             }
-
-             //unwind
-             for( ; m_genlistlevel > numEqualBullets; m_genlistlevel-- )
-             {
-                 popElement( getListType( m_genlistBulletBuffer.charAt(m_genlistlevel-1) ) );
-                 if( m_genlistlevel > numBullets )
-                 {
-                     popElement("li");
-                 }
-             }
-
-             //rewind
-
-             pushElement( new Element(getListType( strBullets.charAt(numEqualBullets++) ) ) );
-             for(int i = numEqualBullets; i < numBullets; i++)
-             {
-                 pushElement( new Element("li") );
-                 pushElement( new Element( getListType( strBullets.charAt(i) ) ) );
-             }
-             m_genlistlevel = numBullets;
-         }
-
-         //
-         //  Push a new list item, and eat away any extra whitespace
-         //
-         pushElement( new Element("li") );
-         readWhile(" ");
-
-         // work done, remember the new bullet list (in place of old one)
-         m_genlistBulletBuffer.setLength(0);
-         m_genlistBulletBuffer.append(strBullets);
-
-         return m_currentElement;
-    }
+        if( strBullets.substring( 0, Math.min( numBullets, m_genlistlevel ) ).equals( m_genlistBulletBuffer.substring( 0, Math.min( numBullets, m_genlistlevel ) ) ) ) {
+            if( numBullets > m_genlistlevel ) {
+                pushElement( new Element( getListType( strBullets.charAt( m_genlistlevel++ ) ) ) );
+                for( ; m_genlistlevel < numBullets; m_genlistlevel++ ) {
+                    // bullets are growing, get from new bullet list
+                    pushElement( new Element( "li" ) );
+                    pushElement( new Element( getListType( strBullets.charAt( m_genlistlevel ) ) ) );
+                }
+            } else if( numBullets < m_genlistlevel ) {
+                //  Close the previous list item.
+                popElement( "li" );
+                for( ; m_genlistlevel > numBullets; m_genlistlevel-- ) {
+                    // bullets are shrinking, get from old bullet list
+                    popElement( getListType( m_genlistBulletBuffer.charAt( m_genlistlevel - 1 ) ) );
+                    if( m_genlistlevel > 0 ) {
+                        popElement( "li" );
+                    }
+                }
+            } else {
+                if( m_genlistlevel > 0 ) {
+                    popElement( "li" );
+                }
+            }
+        } else {
+            //  The pattern has changed, unwind and restart
+            int numEqualBullets;
+            final int numCheckBullets;
+
+            // find out how much is the same
+            numEqualBullets = 0;
+            numCheckBullets = Math.min( numBullets, m_genlistlevel );
+
+            while( numEqualBullets < numCheckBullets ) {
+                // if the bullets are equal so far, keep going
+                if( strBullets.charAt( numEqualBullets ) == m_genlistBulletBuffer.charAt( numEqualBullets ) )
+                    numEqualBullets++;
+                    // otherwise giveup, we have found how many are equal
+                else
+                    break;
+            }
 
-    private Element unwindGeneralList()
-    {
-        //unwind
-        for( ; m_genlistlevel > 0; m_genlistlevel-- )
-        {
-            popElement( "li" );
-            popElement( getListType(m_genlistBulletBuffer.charAt(m_genlistlevel-1)) );
+            //unwind
+            for( ; m_genlistlevel > numEqualBullets; m_genlistlevel-- ) {
+                popElement( getListType( m_genlistBulletBuffer.charAt( m_genlistlevel - 1 ) ) );
+                if( m_genlistlevel > numBullets ) {
+                    popElement( "li" );
+                }
+            }
+
+            //rewind
+            pushElement( new Element( getListType( strBullets.charAt( numEqualBullets++ ) ) ) );
+            for( int i = numEqualBullets; i < numBullets; i++ ) {
+                pushElement( new Element( "li" ) );
+                pushElement( new Element( getListType( strBullets.charAt( i ) ) ) );
+            }
+            m_genlistlevel = numBullets;
         }
 
-        m_genlistBulletBuffer.setLength(0);
+         // Push a new list item, and eat away any extra whitespace
+        pushElement( new Element( "li" ) );
+        readWhile( " " );
+
+        // work done, remember the new bullet list (in place of old one)
+        m_genlistBulletBuffer.setLength( 0 );
+        m_genlistBulletBuffer.append( strBullets );
+        return m_currentElement;
+    }
 
+    private Element unwindGeneralList() {
+        // unwind
+        for( ; m_genlistlevel > 0; m_genlistlevel-- ) {
+            popElement( "li" );
+            popElement( getListType( m_genlistBulletBuffer.charAt( m_genlistlevel - 1 ) ) );
+        }
+        m_genlistBulletBuffer.setLength( 0 );
         return null;
     }
 
 
-    private Element handleDefinitionList()
-        throws IOException
-    {
-        if( !m_isdefinition )
-        {
+    private Element handleDefinitionList() {
+        if( !m_isdefinition ) {
             m_isdefinition = true;
-
             startBlockLevel();
-
-            pushElement( new Element("dl") );
-            return pushElement( new Element("dt") );
+            pushElement( new Element( "dl" ) );
+            return pushElement( new Element( "dt" ) );
         }
-
         return null;
     }
 
-    private Element handleOpenbracket()
-        throws IOException
-    {
-        final StringBuilder sb = new StringBuilder(40);
+    private Element handleOpenbracket() throws IOException {
+        final StringBuilder sb = new StringBuilder( 40 );
         final int pos = getPosition();
         int ch = nextToken();
         boolean isPlugin = false;
-
-        if( ch == '[' )
-        {
-            if( m_wysiwygEditorMode )
-            {
+        if( ch == '[' ) {
+            if( m_wysiwygEditorMode ) {
                 sb.append( '[' );
             }
-
-            sb.append( (char)ch );
-
-            while( (ch = nextToken()) == '[' )
-            {
-                sb.append( (char)ch );
+            sb.append( ( char )ch );
+            while( ( ch = nextToken() ) == '[' ) {
+                sb.append( ( char )ch );
             }
         }
 
-
-        if( ch == '{' )
-        {
+        if( ch == '{' ) {
             isPlugin = true;
         }
 
         pushBack( ch );
 
-        if( sb.length() > 0 )
-        {
+        if( sb.length() > 0 ) {
             m_plainTextBuf.append( sb );
             return m_currentElement;
         }
 
-        //
         //  Find end of hyperlink
-        //
-
         ch = nextToken();
-        int nesting = 1;    // Check for nested plugins
-
-        while( ch != -1 )
-        {
-            final int ch2 = nextToken(); pushBack(ch2);
-
-            if( isPlugin )
-            {
-                if( ch == '[' && ch2 == '{' )
-                {
+        int nesting = 1; // Check for nested plugins
+        while( ch != -1 ) {
+            final int ch2 = nextToken();
+            pushBack( ch2 );
+            if( isPlugin ) {
+                if( ch == '[' && ch2 == '{' ) {
                     nesting++;
-                }
-                else if( nesting == 0 && ch == ']' && sb.charAt(sb.length()-1) == '}' )
-                {
+                } else if( nesting == 0 && ch == ']' && sb.charAt(sb.length()-1) == '}' ) {
                     break;
-                }
-                else if( ch == '}' && ch2 == ']' )
-                {
+                } else if( ch == '}' && ch2 == ']' ) {
                     // NB: This will be decremented once at the end
                     nesting--;
                 }
-            }
-            else
-            {
-                if( ch == ']' )
-                {
+            } else {
+                if( ch == ']' ) {
                     break;
                 }
             }
@@ -1812,13 +1443,9 @@ public class JSPWikiMarkupParser extends MarkupParser {
             ch = nextToken();
         }
 
-        //
-        //  If the link is never finished, do some tricks to display the rest of the line
-        //  unchanged.
-        //
-        if( ch == -1 )
-        {
-            log.debug("Warning: unterminated link detected!");
+        //  If the link is never finished, do some tricks to display the rest of the line unchanged.
+        if( ch == -1 ) {
+            log.debug( "Warning: unterminated link detected!" );
             m_isEscaping = true;
             m_plainTextBuf.append( sb );
             flushPlainText();
@@ -1832,64 +1459,47 @@ public class JSPWikiMarkupParser extends MarkupParser {
     /**
      *  Reads the stream until the current brace is closed or stream end.
      */
-    private String readBraceContent( final char opening, final char closing )
-        throws IOException
-    {
-        final StringBuilder sb = new StringBuilder(40);
+    private String readBraceContent( final char opening, final char closing ) throws IOException {
+        final StringBuilder sb = new StringBuilder( 40 );
         int braceLevel = 1;
         int ch;
-        while(( ch = nextToken() ) != -1 )
-        {
-            if( ch == '\\' )
-            {
+        while( ( ch = nextToken() ) != -1 ) {
+            if( ch == '\\' ) {
                 continue;
-            }
-            else if ( ch == opening )
-            {
+            } else if( ch == opening ) {
                 braceLevel++;
-            }
-            else if ( ch == closing )
-            {
+            } else if( ch == closing ) {
                 braceLevel--;
-                if (braceLevel==0)
-                {
-                  break;
+                if( braceLevel == 0 ) {
+                    break;
                 }
             }
-            sb.append( (char)ch );
+            sb.append( ( char ) ch );
         }
         return sb.toString();
     }
 
 
     /**
-     *  Handles constructs of type %%(style) and %%class
+     * Handles constructs of type %%(style) and %%class
      * @param newLine
      * @return An Element containing the div or span, depending on the situation.
      * @throws IOException
      */
-    private Element handleDiv( final boolean newLine )
-        throws IOException
-    {
+    private Element handleDiv( final boolean newLine ) throws IOException {
         int ch = nextToken();
         Element el = null;
 
-        if( ch == '%' )
-        {
+        if( ch == '%' ) {
             String style = null;
             String clazz = null;
 
             ch = nextToken();
 
-            //
             //  Style or class?
-            //
-            if( ch == '(' )
-            {
+            if( ch == '(' ) {
                 style = readBraceContent('(',')');
-            }
-            else if( Character.isLetter( (char) ch ) )
-            {
+            } else if( Character.isLetter( (char) ch ) ) {
                 pushBack( ch );
                 clazz = readUntil( "( \t\n\r" );
                 //Note: ref.https://www.w3.org/TR/CSS21/syndata.html#characters
@@ -1899,101 +1509,61 @@ public class JSPWikiMarkupParser extends MarkupParser {
 
                 //(1) replace '.' by spaces, allowing multiple classnames on a div or span
                 //(2) remove any invalid character
-                if( clazz != null){
-
-                    clazz = clazz.replace('.', ' ')
-                                 .replaceAll("[^\\s-_\\w\\x200-\\x377]+","");
-
+                if( clazz != null ) {
+                    clazz = clazz.replace( '.', ' ' )
+                                 .replaceAll( "[^\\s-_\\w\\x200-\\x377]+", "" );
                 }
                 ch = nextToken();
 
-                //check for %%class1.class2( style information )
-                if( ch == '(' )
-                {
-                    style = readBraceContent('(',')');
-                }
-                //
-                //  Pop out only spaces, so that the upcoming EOL check does not check the
-                //  next line.
-                //
-                else if( ch == '\n' || ch == '\r' )
-                {
-                    pushBack(ch);
+                // check for %%class1.class2( style information )
+                if( ch == '(' ) {
+                    style = readBraceContent( '(', ')' );
+                //  Pop out only spaces, so that the upcoming EOL check does not check the next line.
+                } else if( ch == '\n' || ch == '\r' ) {
+                    pushBack( ch );
                 }
-            }
-            else
-            {
-                //
+            } else {
                 // Anything else stops.
-                //
-
-                pushBack(ch);
-
-                try
-                {
+                pushBack( ch );
+                try {
                     final Boolean isSpan = m_styleStack.pop();
-
-                    if( isSpan == null )
-                    {
+                    if( isSpan == null ) {
                         // Fail quietly
-                    }
-                    else if(isSpan)
-                    {
+                    } else if( isSpan ) {
                         el = popElement( "span" );
-                    }
-                    else
-                    {
+                    } else {
                         el = popElement( "div" );
                     }
-                }
-                catch( final EmptyStackException e )
-                {
-                    log.debug("Page '"+m_context.getName()+"' closes a %%-block that has not been opened.");
+                } catch( final EmptyStackException e ) {
+                    log.debug( "Page '" + m_context.getName() + "' closes a %%-block that has not been opened." );
                     return m_currentElement;
                 }
-
                 return el;
             }
 
-            //
             //  Check if there is an attempt to do something nasty
-            //
-
-            try
-            {
+            try {
                 style = StringEscapeUtils.unescapeHtml4(style);
-                if( style != null && style.contains("javascript:"))
-                {
-                    log.debug("Attempt to output javascript within CSS:"+style);
+                if( style != null && style.contains( "javascript:" ) ) {
+                    log.debug( "Attempt to output javascript within CSS: {}", style );
                     final ResourceBundle rb = Preferences.getBundle( m_context, InternationalizationManager.CORE_BUNDLE );
                     return addElement( makeError( rb.getString( "markupparser.error.javascriptattempt" ) ) );
                 }
-            }
-            catch( final NumberFormatException e )
-            {
-                //
+            } catch( final NumberFormatException e ) {
                 //  If there are unknown entities, we don't want the parser to stop.
-                //
                 final ResourceBundle rb = Preferences.getBundle( m_context, InternationalizationManager.CORE_BUNDLE );
                 final String msg = MessageFormat.format( rb.getString( "markupparser.error.parserfailure"), e.getMessage() );
                 return addElement( makeError( msg ) );
             }
 
-            //
             //  Decide if we should open a div or a span?
-            //
             final String eol = peekAheadLine();
 
-            if( !eol.trim().isEmpty() )
-            {
+            if( !eol.trim().isEmpty() ) {
                 // There is stuff after the class
-
                 el = new Element("span");
-
                 m_styleStack.push( Boolean.TRUE );
-            }
-            else
-            {
+            } else {
                 startBlockLevel();
                 el = new Element("div");
                 m_styleStack.push( Boolean.FALSE );
@@ -2001,49 +1571,31 @@ public class JSPWikiMarkupParser extends MarkupParser {
 
             if( style != null ) el.setAttribute("style", style);
             if( clazz != null ) el.setAttribute("class", clazz);
-            el = pushElement( el );
-
-            return el;
+            return pushElement( el );
         }
-
-        pushBack(ch);
-
+        pushBack( ch );
         return el;
     }
 
-    private Element handleSlash( final boolean newLine )
-        throws IOException
-    {
+    private Element handleSlash( final boolean newLine ) throws IOException {
         final int ch = nextToken();
-
-        pushBack(ch);
-        if( ch == '%' && !m_styleStack.isEmpty() )
-        {
+        pushBack( ch );
+        if( ch == '%' && !m_styleStack.isEmpty() ) {
             return handleDiv( newLine );
         }
 
         return null;
     }
 
-    private Element handleBar( final boolean newLine )
-        throws IOException
-    {
+    private Element handleBar( final boolean newLine ) throws IOException {
         Element el;
-
-        if( !m_istable && !newLine )
-        {
+        if( !m_istable && !newLine ) {
             return null;
         }
 
-        //
-        //  If the bar is in the first column, we will either start
-        //  a new table or continue the old one.
-        //
-
-        if( newLine )
-        {
-            if( !m_istable )
-            {
+        //  If the bar is in the first column, we will either start a new table or continue the old one.
+        if( newLine ) {
+            if( !m_istable ) {
                 startBlockLevel();
                 el = pushElement( new Element("table").setAttribute("class","wikitable").setAttribute("border","1") );
                 m_istable = true;
@@ -2057,49 +1609,33 @@ public class JSPWikiMarkupParser extends MarkupParser {
             el = pushElement( tr );
         }
 
-        //
-        //  Check out which table cell element to start;
-        //  a header element (th) or a regular element (td).
-        //
+        //  Check out which table cell element to start; a header element (th) or a regular element (td).
         final int ch = nextToken();
-
-        if( ch == '|' )
-        {
-            if( !newLine )
-            {
+        if( ch == '|' ) {
+            if( !newLine ) {
                 el = popElement("th");
                 if( el == null ) popElement("td");
             }
             el = pushElement( new Element("th") );
-        }
-        else
-        {
-            if( !newLine )
-            {
-                el = popElement("td");
-                if( el == null ) popElement("th");
+        } else {
+            if( !newLine ) {
+                el = popElement( "td" );
+                if( el == null ) popElement( "th" );
             }
-
             el = pushElement( new Element("td") );
-
             pushBack( ch );
         }
-
         return el;
     }
 
     /**
      *  Generic escape of next character or entity.
      */
-    private Element handleTilde()
-        throws IOException
-    {
+    private Element handleTilde() throws IOException {
         final int ch = nextToken();
 
-        if( ch == ' ' )
-        {
-            if( m_wysiwygEditorMode )
-            {
+        if( ch == ' ' ) {
+            if( m_wysiwygEditorMode ) {
                 m_plainTextBuf.append( "~ " );
             }
             return m_currentElement;
@@ -2107,138 +1643,88 @@ public class JSPWikiMarkupParser extends MarkupParser {
 
         if( ch == '|' || ch == '~' || ch == '\\' || ch == '*' || ch == '#' ||
             ch == '-' || ch == '!' || ch == '\'' || ch == '_' || ch == '[' ||
-            ch == '{' || ch == ']' || ch == '}' || ch == '%' )
-        {
-            if( m_wysiwygEditorMode )
-            {
+            ch == '{' || ch == ']' || ch == '}' || ch == '%' ) {
+            if( m_wysiwygEditorMode ) {
                 m_plainTextBuf.append( '~' );
             }
-
-            m_plainTextBuf.append( (char)ch );
-            m_plainTextBuf.append(readWhile( ""+(char)ch ));
+            m_plainTextBuf.append( ( char ) ch );
+            m_plainTextBuf.append( readWhile( "" + ( char ) ch ) );
             return m_currentElement;
         }
-
         // No escape.
         pushBack( ch );
-
         return null;
     }
 
-    private void fillBuffer( final Element startElement )
-        throws IOException
-    {
+    private void fillBuffer( final Element startElement ) throws IOException {
         m_currentElement = startElement;
-
-        boolean quitReading = false;
         m_newLine = true;
+        boolean quitReading = false;
         disableOutputEscaping();
-
-        while(!quitReading)
-        {
+        while( !quitReading ) {
             final int ch = nextToken();
+            if( ch == -1 ) {
+                break;
+            }
 
-            if( ch == -1 ) break;
-
-            //
-            //  Check if we're actually ending the preformatted mode.
-            //  We still must do an entity transformation here.
-            //
-            if( m_isEscaping )
-            {
-                if( ch == '}' )
-                {
+            //  Check if we're actually ending the preformatted mode. We still must do an entity transformation here.
+            if( m_isEscaping ) {
+                if( ch == '}' ) {
                     if( handleClosebrace() == null ) m_plainTextBuf.append( (char) ch );
-                }
-                else if( ch == -1 )
-                {
+                } else if( ch == -1 ) {
                     quitReading = true;
                 }
-                else if( ch == '\r' )
-                {
+                else if( ch == '\r' ) {
                     // DOS line feeds we ignore.
-                }
-                else if( ch == '<' )
-                {
+                } else if( ch == '<' ) {
                     m_plainTextBuf.append( "&lt;" );
-                }
-                else if( ch == '>' )
-                {
+                } else if( ch == '>' ) {
                     m_plainTextBuf.append( "&gt;" );
-                }
-                else if( ch == '&' )
-                {
+                } else if( ch == '&' ) {
                     m_plainTextBuf.append( "&amp;" );
-                }
-                else if( ch == '~' )
-                {
-                    String braces = readWhile("}");
-                    if( braces.length() >= 3 )
-                    {
-                        m_plainTextBuf.append("}}}");
-
+                } else if( ch == '~' ) {
+                    String braces = readWhile( "}" );
+                    if( braces.length() >= 3 ) {
+                        m_plainTextBuf.append( "}}}" );
                         braces = braces.substring(3);
-                    }
-                    else
-                    {
+                    } else {
                         m_plainTextBuf.append( (char) ch );
                     }
 
-                    for( int i = braces.length()-1; i >= 0; i-- )
-                    {
-                        pushBack(braces.charAt(i));
+                    for( int i = braces.length()-1; i >= 0; i-- ) {
+                        pushBack( braces.charAt( i ) );
                     }
-                }
-                else
-                {
+                } else {
                     m_plainTextBuf.append( (char) ch );
                 }
 
                 continue;
             }
 
-            //
             //  An empty line stops a list
-            //
-            if( m_newLine && ch != '*' && ch != '#' && ch != ' ' && m_genlistlevel > 0 )
-            {
+            if( m_newLine && ch != '*' && ch != '#' && ch != ' ' && m_genlistlevel > 0 ) {
                 m_plainTextBuf.append(unwindGeneralList());
             }
 
-            if( m_newLine && ch != '|' && m_istable )
-            {
-                popElement("table");
+            if( m_newLine && ch != '|' && m_istable ) {
+                popElement( "table" );
                 m_istable = false;
             }
 
             int skip = IGNORE;
-
-            //
             //  Do the actual parsing and catch any errors.
-            //
-            try
-            {
+            try {
                 skip = parseToken( ch );
-            }
-            catch( final IllegalDataException e )
-            {
-                log.info("Page "+m_context.getPage().getName()+" contains data which cannot be added to DOM tree: "+e.getMessage());
-
-                makeError("Error: "+cleanupSuspectData(e.getMessage()) );
+            } catch( final IllegalDataException e ) {
+                log.info( "Page {} contains data which cannot be added to DOM tree: {}", m_context.getPage().getName(), e.getMessage() );
+                makeError( "Error: " + cleanupSuspectData( e.getMessage() ) );
             }
 
+            // The idea is as follows:  If the handler method returns an element (el != null), it is assumed that it
+            // has been added in the stack.  Otherwise, the character is added as is to the plaintext buffer.
             //
-            //   The idea is as follows:  If the handler method returns
-            //   an element (el != null), it is assumed that it has been
-            //   added in the stack.  Otherwise the character is added
-            //   as is to the plaintext buffer.
-            //
-            //   For the transition phase, if s != null, it also gets
-            //   added in the plaintext buffer.
-            //
-
-            switch( skip )
-            {
+            // For the transition phase, if s != null, it also gets added in the plaintext buffer.
+            switch( skip ) {
                 case ELEMENT:
                     m_newLine = false;
                     break;
@@ -2255,17 +1741,13 @@ public class JSPWikiMarkupParser extends MarkupParser {
         }
 
         closeHeadings();
-        popElement("domroot");
+        popElement( "domroot" );
     }
 
-    private String cleanupSuspectData( final String s )
-    {
+    private String cleanupSuspectData( final String s ) {
         final StringBuilder sb = new StringBuilder( s.length() );
-
-        for( int i = 0; i < s.length(); i++ )
-        {
+        for( int i = 0; i < s.length(); i++ ) {
             final char c = s.charAt(i);
-
             if( Verifier.isXMLCharacter( c ) ) sb.append( c );
             else sb.append( "0x" ).append( Integer.toString( c, 16 ).toUpperCase() );
         }
@@ -2296,79 +1778,55 @@ public class JSPWikiMarkupParser extends MarkupParser {
      * @return {@link #ELEMENT}, {@link #CHARACTER} or {@link #IGNORE}.
      * @throws IOException If parsing fails.
      */
-    protected int parseToken( final int ch )
-        throws IOException
-    {
+    protected int parseToken( final int ch ) throws IOException {
         Element el = null;
-
-        //
         //  Now, check the incoming token.
-        //
-        switch( ch )
-        {
+        switch( ch ) {
           case '\r':
             // DOS linefeeds we forget
             return IGNORE;
 
           case '\n':
-            //
             //  Close things like headings, etc.
-            //
-
             // FIXME: This is not really very fast
-
             closeHeadings();
 
-            popElement("dl"); // Close definition lists.
-            if( m_istable )
-            {
+            popElement( "dl" ); // Close definition lists.
+            if( m_istable ) {
                 popElement("tr");
             }
-
             m_isdefinition = false;
-
-            if( m_newLine )
-            {
+            if( m_newLine ) {
                 // Paragraph change.
                 startBlockLevel();
-
-                //
-                //  Figure out which elements cannot be enclosed inside
-                //  a <p></p> pair according to XHTML rules.
-                //
+                //  Figure out which elements cannot be enclosed inside a <p></p> pair according to XHTML rules.
                 final String nextLine = peekAheadLine();
                 if( nextLine.isEmpty() ||
-                    (!nextLine.isEmpty() &&
-                     !nextLine.startsWith("{{{") &&
-                     !nextLine.startsWith("----") &&
-                     !nextLine.startsWith("%%") &&
-                     "*#!;".indexOf( nextLine.charAt(0) ) == -1) )
-                {
-                    pushElement( new Element("p") );
+                     ( !nextLine.isEmpty() &&
+                       !nextLine.startsWith( "{{{" ) &&
+                       !nextLine.startsWith( "----" ) &&
+                       !nextLine.startsWith( "%%" ) &&
+                       "*#!;".indexOf( nextLine.charAt( 0 ) ) == -1 ) ) {
+                    pushElement( new Element( "p" ) );
                     m_isOpenParagraph = true;
 
-                    if( m_restartitalic )
-                    {
-                        pushElement( new Element("i") );
+                    if( m_restartitalic ) {
+                        pushElement( new Element( "i" ) );
                         m_isitalic = true;
                         m_restartitalic = false;
                     }
-                    if( m_restartbold )
-                    {
-                        pushElement( new Element("b") );
+                    if( m_restartbold ) {
+                        pushElement( new Element( "b" ) );
                         m_isbold = true;
                         m_restartbold = false;
                     }
                 }
-            }
-            else
-            {
+            } else {
                 m_plainTextBuf.append("\n");
                 m_newLine = true;
             }
             return IGNORE;
 
-
           case '\\':
             el = handleBackslash();
             break;
@@ -2390,30 +1848,27 @@ public class JSPWikiMarkupParser extends MarkupParser {
             break;
 
           case '-':
-            if( m_newLine )
+            if( m_newLine ) {
                 el = handleDash();
-
+            }
             break;
 
           case '!':
-            if( m_newLine )
-            {
+            if( m_newLine ) {
                 el = handleHeading();
             }
             break;
 
           case ';':
-            if( m_newLine )
-            {
+            if( m_newLine ) {
                 el = handleDefinitionList();
             }
             break;
 
           case ':':
-            if( m_isdefinition )
-            {
-                popElement("dt");
-                el = pushElement( new Element("dd") );
+            if( m_isdefinition ) {
+                popElement( "dt" );
+                el = pushElement( new Element( "dd" ) );
                 m_isdefinition = false;
             }
             break;
@@ -2423,17 +1878,15 @@ public class JSPWikiMarkupParser extends MarkupParser {
             break;
 
           case '*':
-            if( m_newLine )
-            {
-                pushBack('*');
+            if( m_newLine ) {
+                pushBack( '*' );
                 el = handleGeneralList();
             }
             break;
 
           case '#':
-            if( m_newLine )
-            {
-                pushBack('#');
+            if( m_newLine ) {
+                pushBack( '#' );
                 el = handleGeneralList();
             }
             break;
@@ -2461,40 +1914,33 @@ public class JSPWikiMarkupParser extends MarkupParser {
         return el != null ? ELEMENT : CHARACTER;
     }
 
-    private void closeHeadings()
-    {
-        if( m_lastHeading != null && !m_wysiwygEditorMode )
-        {
+    private void closeHeadings() {
+        if( m_lastHeading != null && !m_wysiwygEditorMode ) {
             // Add the hash anchor element at the end of the heading
-            addElement( new Element("a").setAttribute( "class",HASHLINK ).setAttribute( "href","#"+m_lastHeading.m_titleAnchor ).setText( "#" ) );
+            addElement( new Element("a").setAttribute( "class",HASHLINK )
+                                              .setAttribute( "href","#" + m_lastHeading.m_titleAnchor )
+                                              .setText( "#" ) );
             m_lastHeading = null;
         }
-        popElement("h2");
-        popElement("h3");
-        popElement("h4");
+        popElement( "h2" );
+        popElement( "h3" );
+        popElement( "h4" );
     }
 
     /**
-     *  Parses the entire document from the Reader given in the constructor or
-     *  set by {@link #setInputReader(Reader)}.
+     *  Parses the entire document from the Reader given in the constructor or set by {@link #setInputReader(Reader)}.
      *
      *  @return A WikiDocument, ready to be passed to the renderer.
      *  @throws IOException If parsing cannot be accomplished.
      */
     @Override
-    public WikiDocument parse()
-        throws IOException
-    {
+    public WikiDocument parse() throws IOException {
         final WikiDocument d = new WikiDocument( m_context.getPage() );
         d.setContext( m_context );
-
-        final Element rootElement = new Element("domroot");
-
+        final Element rootElement = new Element( "domroot" );
         d.setRootElement( rootElement );
-
         fillBuffer( rootElement );
-
-        paragraphify(rootElement);
+        paragraphify( rootElement );
 
         return d;
     }
@@ -2502,55 +1948,45 @@ public class JSPWikiMarkupParser extends MarkupParser {
     /**
      *  Checks out that the first paragraph is correctly installed.
      *
-     *  @param rootElement
+     *  @param rootElement element to be checked.
      */
-    private void paragraphify( final Element rootElement)
-    {
-        //
+    private void paragraphify( final Element rootElement) {
         //  Add the paragraph tag to the first paragraph
-        //
         final List< Content > kids = rootElement.getContent();
-
-        if( rootElement.getChild("p") != null )
-        {
+        if( rootElement.getChild( "p" ) != null ) {
             final ArrayList<Content> ls = new ArrayList<>();
             int idxOfFirstContent = 0;
             int count = 0;
 
-            for( final Iterator< Content > i = kids.iterator(); i.hasNext(); count++ )
-            {
+            for( final Iterator< Content > i = kids.iterator(); i.hasNext(); count++ ) {
                 final Content c = i.next();
-                if( c instanceof Element )
-                {
+                if( c instanceof Element ) {
                     final String name = ( ( Element )c ).getName();
-                    if( isBlockLevel( name ) ) break;
+                    if( isBlockLevel( name ) ) {
+                        break;
+                    }
                 }
 
-                if( !(c instanceof ProcessingInstruction) )
-                {
+                if( !( c instanceof ProcessingInstruction ) ) {
                     ls.add( c );
-                    if( idxOfFirstContent == 0 ) idxOfFirstContent = count;
+                    if( idxOfFirstContent == 0 ) {
+                        idxOfFirstContent = count;
+                    }
                 }
             }
 
-            //
-            //  If there were any elements, then add a new <p> (unless it would
-            //  be an empty one)
-            //
-            if( ls.size() > 0 )
-            {
+            //  If there were any elements, then add a new <p> (unless it would be an empty one)
+            if( ls.size() > 0 ) {
                 final Element newel = new Element("p");
-
-                for (final Content c : ls) {
+                for( final Content c : ls ) {
                     c.detach();
-                    newel.addContent(c);
+                    newel.addContent( c );
                 }
 
-                //
                 // Make sure there are no empty <p/> tags added.
-                //
-                if( !newel.getTextTrim().isEmpty() || !newel.getChildren().isEmpty() )
-                    rootElement.addContent(idxOfFirstContent, newel);
+                if( !newel.getTextTrim().isEmpty() || !newel.getChildren().isEmpty() ) {
+                    rootElement.addContent( idxOfFirstContent, newel );
+                }
             }
         }
     }


[jspwiki] 23/25: Update versions

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 5afdd0cdf23cad13d56b78bea3b2de6f30d0bc65
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 23:02:13 2022 +0200

    Update versions
---
 LICENSE | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/LICENSE b/LICENSE
index c60d54ca2..3c8831631 100644
--- a/LICENSE
+++ b/LICENSE
@@ -257,14 +257,14 @@ log4j-1.2-api-2.17.2.jar                    LICENSE
 log4j-api-2.17.2.jar                        LICENSE
 log4j-core-2.17.2.jar                       LICENSE
 log4j-slf4j-impl-2.17.2                     LICENSE
-lucene-analyzers-common-8.11.1.jar          LICENSE
-lucene-backward-codecs-8.11.1.jar           LICENSE
-lucene-core-8.11.1.jar                      LICENSE
-lucene-highlighter-8.11.1.jar               LICENSE
-lucene-memory-8.11.1.jar                    LICENSE
-lucene-queries-8.11.1.jar                   LICENSE
-lucene-queryparser-8.11.1.jar               LICENSE
-lucene-sandbox-8.11.1.jar                   LICENSE
+lucene-analyzers-common-8.11.2.jar          LICENSE
+lucene-backward-codecs-8.11.2.jar           LICENSE
+lucene-core-8.11.2.jar                      LICENSE
+lucene-highlighter-8.11.2.jar               LICENSE
+lucene-memory-8.11.2.jar                    LICENSE
+lucene-queries-8.11.2.jar                   LICENSE
+lucene-queryparser-8.11.2.jar               LICENSE
+lucene-sandbox-8.11.2.jar                   LICENSE
 mail-1.4.7.jar                              ./jspwiki-war/src/main/config/doc/LICENSE.cddl
 nekohtml-2.0.2.jar (codelibs fork)          LICENSE
 org.suigeneris.jrcs.diff-0.4.2              LICENSE
@@ -272,8 +272,8 @@ oro-2.0.8.jar                               LICENSE
 sandler-0.5.jar                             ./jspwiki-war/src/main/config/doc/LICENSE.sandler
 slf4-api-1.7.36.jar                         ./jspwiki-war/src/main/config/doc/LICENSE.mit
 xercesImpl-2.10.0.jar                       LICENSE
-tika-core-2.4.0.jar                         LICENSE
-tika-parsers-2.4.0.jar                      LICENSE
+tika-core-2.4.1.jar                         LICENSE
+tika-parsers-2.4.1.jar                      LICENSE
 xml-apis-1.4.01                             LICENSE
 xmlrpc-2.0.1.jar                            LICENSE
 xpp3-1.1.3.4-RC3                            ./jspwiki-war/src/main/config/doc/LICENSE.cc-cod
@@ -288,7 +288,7 @@ sqltool-2.6.1.jar                           ./jspwiki-war/src/main/config/doc/LI
 jetty-all-9.4.46.v20220331.jar              LICENSE
 junit-5.8.2                                 ./jspwiki-war/src/main/config/doc/LICENSE.cpl
 mockito-core-4.5.1.jar                      ./jspwiki-war/src/main/config/doc/LICENSE.mit
-selenide-6.4.0.jar                          ./jspwiki-war/src/main/config/doc/LICENSE.mit
+selenide-6.6.6.jar                          ./jspwiki-war/src/main/config/doc/LICENSE.mit
 stripes-1.7.0-async.jar                     LICENSE
 yuicompressor-2.4.7.jar                     ./jspwiki-war/src/main/config/doc/LICENSE.yui
 
@@ -304,7 +304,7 @@ SlimBox                                     ./jspwiki-war/src/main/config/doc/LI
 
 RESOURCES                                   LICENSE FILE
 =============================================================================================================
-Apache Tomcat 9.0.62                        LICENSE
+Apache Tomcat 9.0.64                        LICENSE
 Font Awesome (CSS & LESS files)             ./jspwiki-war/src/main/config/doc/LICENSE.mit
 Font Awesome (Fonts)                        ./jspwiki-war/src/main/config/doc/LICENSE.ofl
 SilkIconSet                                 ./jspwiki-war/src/main/config/doc/LICENSE.SilkIconSet


[jspwiki] 13/25: Use Context instead of WikiContext

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 63f0617b8ddef5c25dbc70b275c98f163f49f589
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:54:29 2022 +0200

    Use Context instead of WikiContext
---
 .../java/org/apache/wiki/ui/WikiJSPFilter.java     | 22 ++++++++++++++++------
 .../java/org/apache/wiki/ui/WikiServletFilter.java | 14 +++++++++-----
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
index 6364a8822..20b303cb7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
@@ -23,18 +23,28 @@ import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.ThreadContext;
 import org.apache.wiki.WatchDog;
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.url.URLConstructor;
 import org.apache.wiki.util.TextUtil;
 
-import javax.servlet.*;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.WriteListener;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
 import java.nio.charset.Charset;
 
 
@@ -95,7 +105,7 @@ public class WikiJSPFilter extends WikiServletFilter {
 
             try {
                 w.enterState( "Delivering response", 30 );
-                final WikiContext wikiContext = getWikiContext( request );
+                final Context wikiContext = getWikiContext( request );
                 final String r = filter( wikiContext, responseWrapper );
 
                 if( useEncoding ) {
@@ -132,7 +142,7 @@ public class WikiJSPFilter extends WikiServletFilter {
      * @param response The source string
      * @return The modified string with all the insertions in place.
      */
-    private String filter( final WikiContext wikiContext, final HttpServletResponse response ) {
+    private String filter( final Context wikiContext, final HttpServletResponse response ) {
         String string = response.toString();
 
         if( wikiContext != null ) {
@@ -168,7 +178,7 @@ public class WikiJSPFilter extends WikiServletFilter {
      *  @param type Type identifier for insertion
      *  @return The filtered string.
      */
-    private String insertResources( final WikiContext wikiContext, final String string, final String type ) {
+    private String insertResources( final Context wikiContext, final String string, final String type ) {
         if( wikiContext == null ) {
             return string;
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
index 1ade49a3f..2db7487dc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
@@ -21,7 +21,6 @@ package org.apache.wiki.ui;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.ThreadContext;
-import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Session;
@@ -30,7 +29,13 @@ import org.apache.wiki.auth.AuthenticationManager;
 import org.apache.wiki.auth.SessionMonitor;
 import org.apache.wiki.auth.WikiSecurityException;
 
-import javax.servlet.*;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequestWrapper;
 import java.io.IOException;
@@ -142,7 +147,6 @@ public class WikiServletFilter implements Filter {
             ThreadContext.pop();
             ThreadContext.remove( m_engine.getApplicationName() + ":" + httpRequest.getRequestURL() );
         }
-
     }
 
     /**
@@ -151,9 +155,9 @@ public class WikiServletFilter implements Filter {
      *  @param request The request to examine
      *  @return A valid WikiContext value (or null, if the context could not be located).
      */
-    protected WikiContext getWikiContext( final ServletRequest request ) {
+    protected Context getWikiContext( final ServletRequest request ) {
         final HttpServletRequest httpRequest = (HttpServletRequest) request;
-        return ( WikiContext )httpRequest.getAttribute( Context.ATTR_CONTEXT );
+        return ( Context )httpRequest.getAttribute( Context.ATTR_CONTEXT );
     }
 
     /** 


[jspwiki] 15/25: new wiki:CsrfProtection custom tag

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit cdfb63d26e595fbddab92971bdafce23cd78c665
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:56:16 2022 +0200

    new wiki:CsrfProtection custom tag
---
 .../org/apache/wiki/tags/CsrfProtectionTag.java    | 53 ++++++++++++++++++++++
 .../src/main/resources/META-INF/jspwiki.tld        |  9 ++++
 2 files changed, 62 insertions(+)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/CsrfProtectionTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/CsrfProtectionTag.java
new file mode 100644
index 000000000..43a613aad
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/CsrfProtectionTag.java
@@ -0,0 +1,53 @@
+/*
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+ */
+package org.apache.wiki.tags;
+
+import org.apache.wiki.api.core.Session;
+import org.apache.wiki.http.filter.CsrfProtectionFilter;
+
+/**
+ * Outputs the hidden {@link CsrfProtectionFilter#ANTICSRF_PARAM}.
+ */
+public class CsrfProtectionTag extends WikiTagBase {
+
+    private boolean meta;
+
+    public void setFormat( final String format ) {
+        meta = "meta".equalsIgnoreCase( format );
+    }
+
+    /**
+     *  {@inheritDoc}
+     */
+    @Override
+    public int doWikiStartTag() throws Exception {
+        final Session session = m_wikiContext.getWikiSession();
+        final String csrfProtectionHidden;
+        if( meta ) {
+            csrfProtectionHidden = "<meta name=\"wikiCsrfProtection\" content='" + session.antiCsrfToken() + "'/>";
+        } else {
+            csrfProtectionHidden = "<input type=\"hidden\" name=\"" + CsrfProtectionFilter.ANTICSRF_PARAM + "\" " +
+                                          "id=\"" + CsrfProtectionFilter.ANTICSRF_PARAM + "\" " +
+                                          "value=\"" + session.antiCsrfToken() + "\"/>";
+        }
+        pageContext.getOut().print( csrfProtectionHidden );
+        return SKIP_BODY;
+    }
+
+}
diff --git a/jspwiki-main/src/main/resources/META-INF/jspwiki.tld b/jspwiki-main/src/main/resources/META-INF/jspwiki.tld
index 64d72b504..90ae4dbfe 100644
--- a/jspwiki-main/src/main/resources/META-INF/jspwiki.tld
+++ b/jspwiki-main/src/main/resources/META-INF/jspwiki.tld
@@ -196,6 +196,15 @@
     <body-content>empty</body-content>
   </tag>
 
+  <tag>
+    <name>CsrfProtection</name>
+    <tag-class>org.apache.wiki.tags.CsrfProtectionTag</tag-class>
+    <body-content>empty</body-content>
+    <attribute>
+      <name>format</name>
+    </attribute>
+  </tag>
+
   <tag>
     <name>DiffLink</name>
     <tag-class>org.apache.wiki.tags.DiffLinkTag</tag-class>


[jspwiki] 04/25: Footnote links start with #ref-, instead of #

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3d498669c097e884579f679d00ad9227bcdfaf85
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue May 3 23:00:49 2022 +0200

    Footnote links start with #ref-, instead of #
    
    there are other types of '# links' that can be generated, for instance, '#section-' links
---
 .../src/main/java/org/apache/wiki/htmltowiki/syntax/MarkupHelper.java   | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jspwiki-wysiwyg/src/main/java/org/apache/wiki/htmltowiki/syntax/MarkupHelper.java b/jspwiki-wysiwyg/src/main/java/org/apache/wiki/htmltowiki/syntax/MarkupHelper.java
index 0f6406eeb..4e395e395 100644
--- a/jspwiki-wysiwyg/src/main/java/org/apache/wiki/htmltowiki/syntax/MarkupHelper.java
+++ b/jspwiki-wysiwyg/src/main/java/org/apache/wiki/htmltowiki/syntax/MarkupHelper.java
@@ -41,7 +41,7 @@ public class MarkupHelper {
      * Checks if the link points to a footnote.
      */
     public static boolean isFootnoteLink( final String ref ) {
-        return ref.startsWith( "#" );
+        return ref.startsWith( "#ref-" );
     }
 
     /**


[jspwiki] 14/25: Add dependency on jspwiki-http module

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8365f5bee078e86f26290e10a99625272e30831a
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:55:11 2022 +0200

    Add dependency on jspwiki-http module
---
 jspwiki-main/pom.xml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/jspwiki-main/pom.xml b/jspwiki-main/pom.xml
index 0ee3ac591..6ae19d3aa 100644
--- a/jspwiki-main/pom.xml
+++ b/jspwiki-main/pom.xml
@@ -54,6 +54,12 @@
       <version>${project.version}</version>
     </dependency>
 
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>jspwiki-http</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>jspwiki-wysiwyg</artifactId>


[jspwiki] 12/25: Allow TestEngine to disable properties' cleaning through jspwiki.test.disable-clean-props property

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 18bb41c561778f4f6eebd2094ad06f6228daa078
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:51:54 2022 +0200

    Allow TestEngine to disable properties' cleaning through jspwiki.test.disable-clean-props property
---
 jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
index 43a225ff2..f215a5ead 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -451,10 +451,13 @@ public class TestEngine extends WikiEngine {
      */
     private static Properties cleanTestProps( final Properties props ) {
         final long millis = System.currentTimeMillis();
-        props.put( AuthenticationManager.PROP_LOGIN_THROTTLING, "false" );
-        props.setProperty( "jspwiki.fileSystemProvider.pageDir", cleanNewDirFrom( props.getProperty( "jspwiki.fileSystemProvider.pageDir" ), millis ) );
-        props.setProperty( "jspwiki.basicAttachmentProvider.storageDir", cleanNewDirFrom( props.getProperty( "jspwiki.basicAttachmentProvider.storageDir" ), millis ) );
-        props.setProperty( "jspwiki.workDir", cleanNewDirFrom( props.getProperty( "jspwiki.workDir" ), millis ) );
+        if( !"true".equalsIgnoreCase( props.getProperty( "jspwiki.test.disable-clean-props" ) ) ) {
+            props.put( AuthenticationManager.PROP_LOGIN_THROTTLING, "false" );
+            props.setProperty( "jspwiki.fileSystemProvider.pageDir", cleanNewDirFrom( props.getProperty( "jspwiki.fileSystemProvider.pageDir" ), millis ) );
+            props.setProperty( "jspwiki.basicAttachmentProvider.storageDir", cleanNewDirFrom( props.getProperty( "jspwiki.basicAttachmentProvider.storageDir" ), millis ) );
+            props.setProperty( "jspwiki.workDir", cleanNewDirFrom( props.getProperty( "jspwiki.workDir" ), millis ) );
+        }
+
         return props;
     }
 


[jspwiki] 10/25: fix IT check

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 45f22ecac7f0fe984d9fef7d787144e7454d8bca
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:50:04 2022 +0200

    fix IT check
---
 .../src/main/java/org/apache/wiki/pages/haddock/ViewWikiPage.java       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jspwiki-it-tests/jspwiki-selenide-tests/src/main/java/org/apache/wiki/pages/haddock/ViewWikiPage.java b/jspwiki-it-tests/jspwiki-selenide-tests/src/main/java/org/apache/wiki/pages/haddock/ViewWikiPage.java
index 1d2dda244..9102dc2e2 100644
--- a/jspwiki-it-tests/jspwiki-selenide-tests/src/main/java/org/apache/wiki/pages/haddock/ViewWikiPage.java
+++ b/jspwiki-it-tests/jspwiki-selenide-tests/src/main/java/org/apache/wiki/pages/haddock/ViewWikiPage.java
@@ -109,7 +109,7 @@ public class ViewWikiPage implements HaddockPage {
      * @return {@link SearchResultsPage} instance, to allow chaining of actions.
      */
     public SearchResultsPage searchFor( final String text ) {
-        Selenide.$( By.id( "searchForm" ) ).hover();
+        Selenide.$( By.className( "icon-search" ) ).hover();
         Selenide.$( By.id( "query" ) ).click();
         Selenide.$( By.id( "query" ) ).val( text );
         Selenide.$( By.id( "searchSubmit" ) ).click();


[jspwiki] 21/25: Dependency updates

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c4c5f411a734ffcfec65f9e2b81c0cba9d139e77
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 23:01:28 2022 +0200

    Dependency updates
    
    * Log4J to 2.18.0
    * Lucene to 8.11.2
    * Selenide to 6.6.6
    * Tika to 2.4.1 - closes #187
    * Tomcat to 9.0.64 - closes #189
    * Maven plugins: antrun to 3.1.0 (closes #190, thanks to dependabot), assembly to 3.4.1, enforcer to 3.1.0, surefire to 3.0.0-M7, cargo-maven3 to 1.9.13 (closes #197, thanks to dependabot)
---
 pom.xml | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/pom.xml b/pom.xml
index ba98114e2..3dc46b703 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,26 +68,26 @@
     <jetty.version>9.4.46.v20220331</jetty.version>
     <jrcs-diff.version>0.4.2</jrcs-diff.version>
     <junit.version>5.8.2</junit.version>
-    <log4j2.version>2.17.2</log4j2.version>
-    <lucene.version>8.11.1</lucene.version> <!-- 9.0.0 and above require JDK >= 11 to execute -->
+    <log4j2.version>2.18.0</log4j2.version>
+    <lucene.version>8.11.2</lucene.version> <!-- 9.0.0 and above require JDK >= 11 to execute -->
     <mockito.version>4.5.1</mockito.version>
     <nekohtml.version>2.0.2</nekohtml.version> <!-- 2.1.0 and above require JDK >= 11 to execute -->
     <oro.version>2.0.8</oro.version>
     <sandler.version>0.5</sandler.version>
-    <selenide.version>6.4.0</selenide.version>
+    <selenide.version>6.6.6</selenide.version>
     <slf4j.version>1.7.36</slf4j.version>
     <stripes.version>1.7.0-async-beta</stripes.version>
-    <tika.version>2.4.0</tika.version>
-    <tomcat.version>9.0.62</tomcat.version>
+    <tika.version>2.4.1</tika.version>
+    <tomcat.version>9.0.64</tomcat.version>
     <wro4j.version>1.8.0</wro4j.version> <!-- 1.9.0 and above require JDK >= 9 to execute -->
     <xmlrpc.version>2.0.1</xmlrpc.version>
 
-    <plugin.antrun.version>3.0.0</plugin.antrun.version>
-    <plugin.assembly.version>3.3.0</plugin.assembly.version>
+    <plugin.antrun.version>3.1.0</plugin.antrun.version>
+    <plugin.assembly.version>3.4.1</plugin.assembly.version>
     <plugin.clean.version>3.2.0</plugin.clean.version>
     <plugin.compiler.version>3.10.1</plugin.compiler.version>
     <plugin.dependency.version>3.3.0</plugin.dependency.version>
-    <plugin.enforcer.version>3.0.0</plugin.enforcer.version>
+    <plugin.enforcer.version>3.1.0</plugin.enforcer.version>
     <plugin.install.version>2.5.2</plugin.install.version>
     <plugin.jar.version>3.2.2</plugin.jar.version>
     <plugin.javadoc.version>3.4.0</plugin.javadoc.version>
@@ -96,14 +96,14 @@
     <plugin.release.version>3.0.0-M5</plugin.release.version>
     <plugin.resources.version>3.2.0</plugin.resources.version>
     <plugin.source.version>3.2.1</plugin.source.version>
-    <plugin.surefire.version>3.0.0-M6</plugin.surefire.version>
+    <plugin.surefire.version>3.0.0-M7</plugin.surefire.version>
     <plugin.surefire.junit5-tree-reporter.version>0.1.0</plugin.surefire.junit5-tree-reporter.version>
     <plugin.war.version>3.3.2</plugin.war.version>
     <plugin.inmemdb.version>1.4.3</plugin.inmemdb.version>
     <plugin.jspc.version>3.2.0</plugin.jspc.version>
     <plugin.checksum.version>1.11</plugin.checksum.version>
     <plugin.jslint.version>1.0.1</plugin.jslint.version>
-    <plugin.cargo.version>1.9.10</plugin.cargo.version>
+    <plugin.cargo.version>1.9.13</plugin.cargo.version>
     <plugin.clirr.version>2.8</plugin.clirr.version>
     <plugin.cobertura.version>2.7</plugin.cobertura.version>
     <plugin.sonar.version>3.9.1.2184</plugin.sonar.version>
@@ -128,6 +128,7 @@
     <module>jspwiki-api</module>
     <module>jspwiki-bootstrap</module>
     <module>jspwiki-cache</module>
+    <module>jspwiki-http</module>
     <module>jspwiki-wysiwyg</module>
     <module>jspwiki-main</module>
     <module>jspwiki-markdown</module>


[jspwiki] 08/25: fix integration tests setup

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f2d231ba1aec2417804c47b3a8f6913fe1a21614
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:47:32 2022 +0200

    fix integration tests setup
---
 jspwiki-it-tests/pom.xml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/jspwiki-it-tests/pom.xml b/jspwiki-it-tests/pom.xml
index 5938cf1c4..8ca5219da 100644
--- a/jspwiki-it-tests/pom.xml
+++ b/jspwiki-it-tests/pom.xml
@@ -168,6 +168,7 @@
                   <groupId>org.hsqldb</groupId>
                   <artifactId>hsqldb</artifactId>
                   <version>${hsqldb.version}</version>
+                  <classifier>jdk8</classifier>
                 </dependency>
                 <dependency>
                   <groupId>org.hsqldb</groupId>
@@ -236,6 +237,7 @@
                       <groupId>org.hsqldb</groupId>
                       <artifactId>hsqldb</artifactId>
                       <classpath>shared</classpath>
+                      <classifier>jdk8</classifier>
                     </dependency>
                   </dependencies>
                 </container>


[jspwiki] 17/25: Use new wiki:CsrfProtection tag on JSPs

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1f1c94e7776d90a816530028f5065b11cf00e1e6
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:57:46 2022 +0200

    Use new wiki:CsrfProtection tag on JSPs
---
 jspwiki-war/src/main/webapp/Captcha.jsp                     |  1 +
 jspwiki-war/src/main/webapp/Install.jsp                     |  2 +-
 jspwiki-war/src/main/webapp/templates/210/AttachmentTab.jsp | 13 +++++++------
 jspwiki-war/src/main/webapp/templates/210/DiffTab.jsp       |  1 +
 .../src/main/webapp/templates/210/EditGroupContent.jsp      |  3 ++-
 jspwiki-war/src/main/webapp/templates/210/FindContent.jsp   |  2 +-
 jspwiki-war/src/main/webapp/templates/210/GroupContent.jsp  |  1 +
 jspwiki-war/src/main/webapp/templates/210/GroupTab.jsp      |  1 +
 jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp   |  5 ++++-
 jspwiki-war/src/main/webapp/templates/210/LoginContent.jsp  |  4 ++--
 .../src/main/webapp/templates/210/NewGroupContent.jsp       |  2 +-
 jspwiki-war/src/main/webapp/templates/210/PageTab.jsp       |  1 +
 .../src/main/webapp/templates/210/PreferencesTab.jsp        |  2 ++
 jspwiki-war/src/main/webapp/templates/210/ProfileTab.jsp    |  1 +
 jspwiki-war/src/main/webapp/templates/210/SearchBox.jsp     |  1 +
 .../src/main/webapp/templates/210/WorkflowContent.jsp       |  2 ++
 .../src/main/webapp/templates/210/admin/AdminTemplate.jsp   |  2 ++
 .../src/main/webapp/templates/210/admin/UserManagement.jsp  |  1 +
 jspwiki-war/src/main/webapp/templates/210/commonheader.jsp  |  1 +
 .../src/main/webapp/templates/210/editors/CKeditor.jsp      |  3 ++-
 jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp   |  1 +
 .../src/main/webapp/templates/210/editors/TinyMCE.jsp       |  1 +
 jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp |  1 +
 .../src/main/webapp/templates/210/editors/preview.jsp       |  1 +
 .../src/main/webapp/templates/210/editors/wysiwyg.jsp       |  1 +
 .../src/main/webapp/templates/default/AttachmentTab.jsp     |  5 ++++-
 jspwiki-war/src/main/webapp/templates/default/DiffTab.jsp   |  1 +
 .../src/main/webapp/templates/default/EditGroupContent.jsp  |  1 +
 .../src/main/webapp/templates/default/FindContent.jsp       |  1 +
 jspwiki-war/src/main/webapp/templates/default/GroupTab.jsp  |  2 ++
 .../src/main/webapp/templates/default/InfoContent.jsp       |  5 ++++-
 .../src/main/webapp/templates/default/LoginContent.jsp      |  4 +++-
 jspwiki-war/src/main/webapp/templates/default/PageTab.jsp   |  1 +
 .../src/main/webapp/templates/default/PreferencesTab.jsp    |  1 +
 .../src/main/webapp/templates/default/ProfileTab.jsp        |  1 +
 jspwiki-war/src/main/webapp/templates/default/SearchBox.jsp |  1 +
 jspwiki-war/src/main/webapp/templates/default/UserBox.jsp   | 10 +++++-----
 .../src/main/webapp/templates/default/WorkflowContent.jsp   |  2 ++
 .../main/webapp/templates/default/admin/AdminTemplate.jsp   |  2 ++
 .../main/webapp/templates/default/admin/UserManagement.jsp  |  3 ++-
 .../src/main/webapp/templates/default/commonheader.jsp      |  1 +
 .../src/main/webapp/templates/default/editors/CKeditor.jsp  |  1 +
 .../src/main/webapp/templates/default/editors/TinyMCE.jsp   |  1 +
 .../src/main/webapp/templates/default/editors/plain.jsp     |  1 +
 .../src/main/webapp/templates/default/editors/preview.jsp   |  2 +-
 .../src/main/webapp/templates/default/editors/wysiwyg.jsp   |  1 +
 46 files changed, 77 insertions(+), 24 deletions(-)

diff --git a/jspwiki-war/src/main/webapp/Captcha.jsp b/jspwiki-war/src/main/webapp/Captcha.jsp
index f44d94fb0..ed33fdf10 100644
--- a/jspwiki-war/src/main/webapp/Captcha.jsp
+++ b/jspwiki-war/src/main/webapp/Captcha.jsp
@@ -110,6 +110,7 @@
    <p><fmt:message key="captcha.description" /></p>
 
    <form action="<wiki:Link jsp='Captcha.jsp' format='url'/>" method="post" id="mainForm" style="display: none;">
+      <wiki:CsrfProtection/>
       <input type="hidden" value="foo" name="text" />
       <input type="hidden" value='<%=reqPage%>' name='page'/>
       <script type="text/javascript" src="http://challenge.asirra.com/js/AsirraClientSide.js"></script>
diff --git a/jspwiki-war/src/main/webapp/Install.jsp b/jspwiki-war/src/main/webapp/Install.jsp
index 29fc2f319..6b2913914 100644
--- a/jspwiki-war/src/main/webapp/Install.jsp
+++ b/jspwiki-war/src/main/webapp/Install.jsp
@@ -109,7 +109,7 @@ if ( !installer.adminExists() )
 <div class="formcontainer">
 
 <form action="Install.jsp" method="post">
-
+  <wiki:CsrfProtection/>
   <!-- Page directory -->
   <h3><fmt:message key="install.jsp.basics.title" /></h3>
 
diff --git a/jspwiki-war/src/main/webapp/templates/210/AttachmentTab.jsp b/jspwiki-war/src/main/webapp/templates/210/AttachmentTab.jsp
index 9439e5b72..c732ca2b3 100644
--- a/jspwiki-war/src/main/webapp/templates/210/AttachmentTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/AttachmentTab.jsp
@@ -29,18 +29,19 @@
 <%
   int MAXATTACHNAMELENGTH = 30;
   Context c = Context.findContext(pageContext);
-  String progressId = c.getEngine().getManager( ProgressManager.class ).getNewProgressIdentifier();
 %>
+<c:set var="progressId" value="<%= c.getEngine().getManager( ProgressManager.class ).getNewProgressIdentifier() %>" />
+<c:set var="csrfProtection" value="<%= c.getWikiSession().antiCsrfToken() %>" />
 
 <div id="addattachment">
 <h3><fmt:message key="attach.add"/></h3>
 <wiki:Permission permission="upload">
-  <form action="<wiki:Link jsp='attach' format='url'><wiki:Param name='progressid' value='<%=progressId%>'/></wiki:Link>"
+  <form action="<wiki:Link jsp='attach' format='url'><wiki:Param name='progressid' value='${progressId}'/><wiki:Param name='X-XSRF-TOKEN' value='${csrfProtection}'/></wiki:Link>"
          class="wikiform"
             id="uploadform"
         method="post"
        enctype="multipart/form-data" accept-charset="<wiki:ContentEncoding/>"
-      onsubmit="return Wiki.submitUpload(this, '<%=progressId%>');" >
+      onsubmit="return Wiki.submitUpload(this, '${progressId}');" >
     <table>
     <tr>
       <td colspan="2"><div class="formhelp"><fmt:message key="attach.add.info" /></div></td>
@@ -55,7 +56,7 @@
     <input type="hidden" name="nextpage" value="<wiki:UploadLink format="url"/>" /></td>
     </tr>
 
-   <tr>
+    <tr>
       <td></td>
       <td>
         <input type="hidden" name="page" value="<wiki:Variable var="pagename"/>" />
@@ -66,6 +67,7 @@
     </tr>
 
     </table>
+    <wiki:CsrfProtection/>
   </form>
 
   <wiki:Messages div="error" />
@@ -89,9 +91,8 @@
               id="deleteForm" style="display:none;"
           method="post" accept-charset="<wiki:ContentEncoding />"
         onsubmit="return(confirm('<fmt:message key="attach.deleteconfirm"/>') && Wiki.submitOnce(this) );" >
-
+      <wiki:CsrfProtection/>
       <input id="delete-all" name="delete-all" type="submit" value="Delete" />
-
     </form>
   </wiki:Permission>
 
diff --git a/jspwiki-war/src/main/webapp/templates/210/DiffTab.jsp b/jspwiki-war/src/main/webapp/templates/210/DiffTab.jsp
index 85bab3a42..257bea798 100644
--- a/jspwiki-war/src/main/webapp/templates/210/DiffTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/DiffTab.jsp
@@ -38,6 +38,7 @@
 
 <wiki:PageExists>
 <form action="<wiki:Link jsp='Diff.jsp' format='url' />" method="get" accept-charset="UTF-8">
+<wiki:CsrfProtection/>
 <div class="collapsebox" id="diffcontent">
   <h4>
        <input type="hidden" name="page" value="<wiki:Variable var='pagename' />" />
diff --git a/jspwiki-war/src/main/webapp/templates/210/EditGroupContent.jsp b/jspwiki-war/src/main/webapp/templates/210/EditGroupContent.jsp
index 29d00c3b8..f448264d5 100644
--- a/jspwiki-war/src/main/webapp/templates/210/EditGroupContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/EditGroupContent.jsp
@@ -69,7 +69,7 @@
          class="wikiform"
             id="editGroup"
         method="POST" accept-charset="UTF-8">
-
+    <wiki:CsrfProtection/>
     <!-- Members -->
     <%
       StringBuffer s = new StringBuffer();
@@ -116,6 +116,7 @@
         onsubmit="return( confirm('<fmt:message key="grp.deletegroup.confirm"/>')
         && Wiki.submitOnce(this) );"
         method="POST" accept-charset="UTF-8">
+      <wiki:CsrfProtection/>
       <input type="submit" name="ok" value="<fmt:message key="actions.deletegroup"/>" />
       <input type="hidden" name="group" value="${param.group}" />
   </form>
diff --git a/jspwiki-war/src/main/webapp/templates/210/FindContent.jsp b/jspwiki-war/src/main/webapp/templates/210/FindContent.jsp
index 9ebf4ce8e..0ceebc311 100644
--- a/jspwiki-war/src/main/webapp/templates/210/FindContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/FindContent.jsp
@@ -36,7 +36,7 @@
        class="wikiform"
           id="searchform2"
          accept-charset="<wiki:ContentEncoding/>">
-
+  <wiki:CsrfProtection/>
   <h4><fmt:message key="find.input" /></h4>
   <p>
     <input type="text"
diff --git a/jspwiki-war/src/main/webapp/templates/210/GroupContent.jsp b/jspwiki-war/src/main/webapp/templates/210/GroupContent.jsp
index 1e5fd553e..1f37656b1 100644
--- a/jspwiki-war/src/main/webapp/templates/210/GroupContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/GroupContent.jsp
@@ -154,6 +154,7 @@
         onsubmit="return( confirm('<fmt:message key="grp.deletegroup.confirm"/>')
         && Wiki.submitOnce(this) );"
         method="POST" accept-charset="UTF-8">
+      <wiki:CsrfProtection/>
       <input type="submit" name="ok" value="<fmt:message key="actions.deletegroup"/>" />
       <input type="hidden" name="group" value="${param.group}" />
   </form>
diff --git a/jspwiki-war/src/main/webapp/templates/210/GroupTab.jsp b/jspwiki-war/src/main/webapp/templates/210/GroupTab.jsp
index 827e09cbe..df106512a 100644
--- a/jspwiki-war/src/main/webapp/templates/210/GroupTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/GroupTab.jsp
@@ -107,6 +107,7 @@
               id="groupForm"
           method="post" accept-charset="<wiki:ContentEncoding />" >
       <div>
+      <wiki:CsrfProtection/>
       <input type="hidden" name="group"   value="" />
       <input type="hidden" name="members" value="" />
       <input type="hidden" name="action"  value="save" />
diff --git a/jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp b/jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp
index 3942fe0e4..02b038bbe 100644
--- a/jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp
@@ -140,6 +140,7 @@
         onsubmit="return Wiki.submitOnce(this);"
           method="post" accept-charset="<wiki:ContentEncoding />" >
       <p>
+      <wiki:CsrfProtection/>
       <input type="hidden" name="page" value="<wiki:Variable var='pagename' />" />
       <input type="submit" name="rename" value="<fmt:message key='info.rename.submit' />" />
       <input type="text" name="renameto"
@@ -161,6 +162,7 @@
           method="post" accept-charset="<wiki:ContentEncoding />"
         onsubmit="return( confirm('<fmt:message key="info.confirmdelete"/>') && Wiki.submitOnce(this) );">
       <p>
+      <wiki:CsrfProtection/>
       <input type="submit" name="delete-all" id="delete-all"
             value="<fmt:message key='info.delete.submit'/>" />
       </p>
@@ -291,7 +293,7 @@
 
   <%-- Do NOT change the order of wikiname and content, otherwise the
        servlet won't find its parts. --%>
-
+  <wiki:CsrfProtection/>
   <table>
   <tr>
     <td colspan="2"><div class="formhelp"><fmt:message key="info.uploadnew.help" /></div></td>
@@ -331,6 +333,7 @@
           method="post" accept-charset="<wiki:ContentEncoding />"
         onsubmit="return( confirm('<fmt:message key="info.confirmdelete"/>') && Wiki.submitOnce(this) );" >
      <div>
+     <wiki:CsrfProtection/>
      <input type="submit" name="delete-all" id="delete-all"
            value="<fmt:message key='info.deleteattachment.submit' />" />
      </div>
diff --git a/jspwiki-war/src/main/webapp/templates/210/LoginContent.jsp b/jspwiki-war/src/main/webapp/templates/210/LoginContent.jsp
index 3a2e8fe7f..f0fd85df8 100644
--- a/jspwiki-war/src/main/webapp/templates/210/LoginContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/LoginContent.jsp
@@ -58,7 +58,7 @@
       method="post" accept-charset="<wiki:ContentEncoding />" >
 
 <div class="center">
-
+  <wiki:CsrfProtection/>
   <h3><fmt:message key="login.heading.login"><fmt:param><wiki:Variable var="applicationname" /></fmt:param></fmt:message></h3>
 
   <div class="formhelp"><fmt:message key="login.help"></fmt:message></div>
@@ -129,7 +129,7 @@
       method="post" accept-charset="<wiki:ContentEncoding />" >
 
   <h3><fmt:message key="login.lostpw.heading" /></h3>
-
+  <wiki:CsrfProtection/>
   <c:choose>
   <c:when test="${passwordreset == 'done' }">
       <wiki:Messages div="information" topic="resetpw" prefix="" />
diff --git a/jspwiki-war/src/main/webapp/templates/210/NewGroupContent.jsp b/jspwiki-war/src/main/webapp/templates/210/NewGroupContent.jsp
index 0b85b7251..15aa8263d 100644
--- a/jspwiki-war/src/main/webapp/templates/210/NewGroupContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/NewGroupContent.jsp
@@ -63,7 +63,7 @@
 
   <form id="createGroup" action="<wiki:Link format="url" jsp="NewGroup.jsp"/>"
     method="POST" accept-charset="UTF-8">
-
+  <wiki:CsrfProtection/>
   <div class="formhelp">
      <fmt:message key="newgroup.instructions.start"/>
   </div>
diff --git a/jspwiki-war/src/main/webapp/templates/210/PageTab.jsp b/jspwiki-war/src/main/webapp/templates/210/PageTab.jsp
index ac77fa7e9..ebe8ff003 100644
--- a/jspwiki-war/src/main/webapp/templates/210/PageTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/PageTab.jsp
@@ -47,6 +47,7 @@
   <form action="<wiki:Link format='url' jsp='Wiki.jsp'/>" 
         method="get"  accept-charset='UTF-8'>
 
+    <wiki:CsrfProtection/>
     <input type="hidden" name="page" value="<wiki:Variable var='pagename' />" />     
     <div class="warning">
       <fmt:message key="view.oldversion">
diff --git a/jspwiki-war/src/main/webapp/templates/210/PreferencesTab.jsp b/jspwiki-war/src/main/webapp/templates/210/PreferencesTab.jsp
index 8cb15aa68..de28e1e70 100644
--- a/jspwiki-war/src/main/webapp/templates/210/PreferencesTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/PreferencesTab.jsp
@@ -55,6 +55,7 @@
           id="setCookie"
       method="post" accept-charset="<wiki:ContentEncoding />"
     onsubmit="WikiPreferences.savePrefs(); return Wiki.submitOnce(this);" >
+    <wiki:CsrfProtection/>
 <table>
 
   <tr>
@@ -210,6 +211,7 @@
     onsubmit="Wiki.prefs.empty(); return Wiki.submitOnce( this );"
       method="post" accept-charset="<wiki:ContentEncoding />" >
   <div>
+  <wiki:CsrfProtection/>
   <input type="submit" name="ok" value="<fmt:message key='prefs.clear.submit'/>" />
   <input type="hidden" name="action" value="clearAssertedName" />
   </div>
diff --git a/jspwiki-war/src/main/webapp/templates/210/ProfileTab.jsp b/jspwiki-war/src/main/webapp/templates/210/ProfileTab.jsp
index 969734f69..2605a5913 100644
--- a/jspwiki-war/src/main/webapp/templates/210/ProfileTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/ProfileTab.jsp
@@ -43,6 +43,7 @@
      onsubmit="return Wiki.submitOnce( this );"
       method="post" accept-charset="UTF-8">
 
+      <wiki:CsrfProtection/>
       <h3>
       <wiki:UserProfile property="exists"><fmt:message key="prefs.oldprofile"/></wiki:UserProfile>
       <wiki:UserProfile property="new"><fmt:message key="prefs.newprofile"/></wiki:UserProfile>
diff --git a/jspwiki-war/src/main/webapp/templates/210/SearchBox.jsp b/jspwiki-war/src/main/webapp/templates/210/SearchBox.jsp
index 9aea7d35c..005eb8a46 100644
--- a/jspwiki-war/src/main/webapp/templates/210/SearchBox.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/SearchBox.jsp
@@ -35,6 +35,7 @@
            name="query" id="query"
            size="20" 
       accesskey="f" />
+  <wiki:CsrfProtection/>
   <button type="submit"
   		 name="searchSubmit" id="searchSubmit"
   		value="<fmt:message key='find.submit.go'/>"
diff --git a/jspwiki-war/src/main/webapp/templates/210/WorkflowContent.jsp b/jspwiki-war/src/main/webapp/templates/210/WorkflowContent.jsp
index 9bb25f979..52376524b 100644
--- a/jspwiki-war/src/main/webapp/templates/210/WorkflowContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/WorkflowContent.jsp
@@ -84,6 +84,7 @@
           <td align="left">
             <form id="<c:out value='decision.${decision.id}'/>"
               action="<wiki:Link jsp='Workflow.jsp' format='url'/>" method="POST" accept-charset="UTF-8">
+              <wiki:CsrfProtection/>
               <input type="hidden" name="action" value="decide" />
               <input type="hidden" name="id" value="<c:out value='${decision.id}' />" />
               <select name="outcome" onchange="SubmitOutcomeIfSelected(this)">
@@ -163,6 +164,7 @@
           <!-- Actions -->
           <td align="left">
             <form id="<c:out value='workflow.${workflow.id}'/>" action="<wiki:Link jsp='Workflow.jsp' format='url'/>" method="POST" accept-charset="UTF-8">
+              <wiki:CsrfProtection/>
               <input type="submit" name="submit" value="<fmt:message key="outcome.step.abort" />" />
               <input type="hidden" name="action" value="abort" />
               <input type="hidden" name="id" value="<c:out value="${workflow.id}" />" />
diff --git a/jspwiki-war/src/main/webapp/templates/210/admin/AdminTemplate.jsp b/jspwiki-war/src/main/webapp/templates/210/admin/AdminTemplate.jsp
index 536f8c4e4..b946808ed 100644
--- a/jspwiki-war/src/main/webapp/templates/210/admin/AdminTemplate.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/admin/AdminTemplate.jsp
@@ -56,6 +56,7 @@ in your <code>jspwiki.properties</code> file.</div>
 
       <div class="formcontainer">
       <form action="Admin.jsp" method="post" accept-charset="UTF-8">
+        <wiki:CsrfProtection/>
         <input type="hidden" name="tab-admin" value="core"/>
         <input type="hidden" name="tab-core" value="${ab.title}" />
         <input type="hidden" name="bean" value="${ab.id}" />
@@ -91,6 +92,7 @@ in your <code>jspwiki.properties</code> file.</div>
 
       <div class="formcontainer">
       <form action="Admin.jsp" method="post" accept-charset="UTF-8">
+         <wiki:CsrfProtection/>
          <input type="hidden" name="tab-admin" value="editors"/>
          <input type="hidden" name="tab-editors" value="${ab.title}" />
          <%
diff --git a/jspwiki-war/src/main/webapp/templates/210/admin/UserManagement.jsp b/jspwiki-war/src/main/webapp/templates/210/admin/UserManagement.jsp
index 2c681c966..8dbc8e2de 100644
--- a/jspwiki-war/src/main/webapp/templates/210/admin/UserManagement.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/admin/UserManagement.jsp
@@ -84,6 +84,7 @@ function addNew()
     onsubmit="return Wiki.submitOnce(this);"
       method="post" accept-charset="<wiki:ContentEncoding/>"
      enctype="application/x-www-form-urlencoded" >
+     <wiki:CsrfProtection/>
      <input type="hidden" name='bean' value='org.apache.wiki.ui.admin.beans.UserBean'/>
      <input type="hidden" id="loginid" name="loginid" value="" />
      <table>
diff --git a/jspwiki-war/src/main/webapp/templates/210/commonheader.jsp b/jspwiki-war/src/main/webapp/templates/210/commonheader.jsp
index 873817336..346090133 100644
--- a/jspwiki-war/src/main/webapp/templates/210/commonheader.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/commonheader.jsp
@@ -72,6 +72,7 @@
 <meta name="wikiUserName" content='<wiki:UserName />' />
 <meta name="wikiTemplateUrl" content='<wiki:Link format="url" templatefile="" />' />
 <meta name="wikiApplicationName" content='<wiki:Variable var="ApplicationName" />' />
+<wiki:CsrfProtection format="meta" />
 
 <script type="text/javascript">//<![CDATA[
 /* Localized javascript strings: LocalizedStrings[] */
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp
index aa4864f02..d4bac805b 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp
@@ -130,7 +130,8 @@
           id="editform"
      enctype="application/x-www-form-urlencoded" >
 
-    <%-- Edit.jsp relies on these being found.  So be careful, if you make changes. --%>
+  <wiki:CsrfProtection/>
+  <%-- Edit.jsp relies on these being found.  So be careful, if you make changes. --%>
   <input type="hidden" name="page" value="<wiki:Variable var='pagename' />" />
   <input type="hidden" name="action" value="save" />
   <wiki:SpamFilterInputs/>
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp
index 792fcb476..67285cc75 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp
@@ -104,6 +104,7 @@
       name="editform" id="editform"
       enctype="application/x-www-form-urlencoded">
     <p>
+        <wiki:CsrfProtection/>
         <%-- Edit.jsp relies on these being found.  So be careful, if you make changes. --%>
         <input name="page" type="hidden" value="<wiki:Variable var="pagename"/>" />
         <input name="action" type="hidden" value="save" />
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/TinyMCE.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/TinyMCE.jsp
index 8e0021c8b..008876c7e 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/TinyMCE.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/TinyMCE.jsp
@@ -126,6 +126,7 @@
           id="editform"
      enctype="application/x-www-form-urlencoded" >
 
+    <wiki:CsrfProtection/>
     <%-- Edit.jsp relies on these being found.  So be careful, if you make changes. --%>
     <input type="hidden" name="page" value="<wiki:Variable var='pagename' />" />
     <input type="hidden" name="action" value="save" />
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp
index 4f36913f6..ae0dcf5af 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp
@@ -88,6 +88,7 @@
       method="post" accept-charset="<wiki:ContentEncoding/>"
      enctype="application/x-www-form-urlencoded" >
 
+  <wiki:CsrfProtection/>
   <%-- Edit.jsp relies on these being found.  So be careful, if you make changes. --%>
   <p id="submitbuttons">
   <input name="page" type="hidden" value="<wiki:Variable var='pagename' />" />
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/preview.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/preview.jsp
index 1c0036b3f..9a2a47ed3 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/preview.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/preview.jsp
@@ -47,6 +47,7 @@
      enctype="application/x-www-form-urlencoded">
 
   <p>
+    <wiki:CsrfProtection/>
     <%-- Edit.jsp & Comment.jsp rely on these being found.  So be careful, if you make changes. --%>
     <input type="hidden" name="author" value="${author}" />
     <input type="hidden" name="link" value="${link}" />
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/wysiwyg.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/wysiwyg.jsp
index 67b304c2d..e49ec3b77 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/wysiwyg.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/wysiwyg.jsp
@@ -93,6 +93,7 @@ Falling back to the plain editor.
       method="post" accept-charset="<wiki:ContentEncoding/>"
      enctype="application/x-www-form-urlencoded" >
 
+  <wiki:CsrfProtection/>
   <%-- Edit.jsp relies on these being found.  So be careful, if you make changes. --%>
   <p id="submitbuttons">
   <input name="page" type="hidden" value="<wiki:Variable var='pagename' />" />
diff --git a/jspwiki-war/src/main/webapp/templates/default/AttachmentTab.jsp b/jspwiki-war/src/main/webapp/templates/default/AttachmentTab.jsp
index 9614286c5..29016589c 100644
--- a/jspwiki-war/src/main/webapp/templates/default/AttachmentTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/AttachmentTab.jsp
@@ -33,16 +33,18 @@
   Context c = Context.findContext(pageContext);
 %>
 <c:set var="progressId" value="<%= c.getEngine().getManager( ProgressManager.class ).getNewProgressIdentifier() %>" />
+<c:set var="csrfProtection" value="<%= c.getWikiSession().antiCsrfToken() %>" />
 <div class="page-content">
 <wiki:Permission permission="upload">
 
-  <form action="<wiki:Link jsp='attach' format='url'><wiki:Param name='progressid' value='${progressId}'/></wiki:Link>"
+  <form action="<wiki:Link jsp='attach' format='url'><wiki:Param name='progressid' value='${progressId}'/><wiki:Param name='X-XSRF-TOKEN' value='${csrfProtection}'/></wiki:Link>"
          class="accordion<wiki:HasAttachments></wiki:HasAttachments>"
             id="uploadform"
         method="post"
        enctype="multipart/form-data" accept-charset="<wiki:ContentEncoding/>" >
 
     <h4><span class="icon-paper-clip"></span> <fmt:message key="attach.add"/></h4>
+    <wiki:CsrfProtection/>
     <input type="hidden" name="nextpage" value="<wiki:Link context='upload' format='url'/>" />
     <input type="hidden" name="page" value="<wiki:Variable var="pagename"/>" />
     <input type="hidden" name="action" value="upload" />
@@ -92,6 +94,7 @@
 
       <%--TODO: "nextpage" is not yet implemented in Delete.jsp
       --%>
+      <wiki:CsrfProtection/>
       <input type="hidden" name="nextpage" value="<wiki:Link context='upload' format='url'/>" />
       <input id="delete-all" name="delete-all" type="submit"
         data-modal="+ .modal"
diff --git a/jspwiki-war/src/main/webapp/templates/default/DiffTab.jsp b/jspwiki-war/src/main/webapp/templates/default/DiffTab.jsp
index 126273ef1..15ff22357 100644
--- a/jspwiki-war/src/main/webapp/templates/default/DiffTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/DiffTab.jsp
@@ -37,6 +37,7 @@
        class="diffbody form-inline"
       method="get" accept-charset="UTF-8">
   <input type="hidden" name="page" value="<wiki:PageName />" />
+  <wiki:CsrfProtection/>
 
   <p class="btn btn-default btn-block">
        <fmt:message key="diff.difference">
diff --git a/jspwiki-war/src/main/webapp/templates/default/EditGroupContent.jsp b/jspwiki-war/src/main/webapp/templates/default/EditGroupContent.jsp
index f3465c862..0092da87f 100644
--- a/jspwiki-war/src/main/webapp/templates/default/EditGroupContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/EditGroupContent.jsp
@@ -64,6 +64,7 @@
         method="POST" accept-charset="UTF-8">
 
     <input type="hidden" name="group" value="${name}" />
+    <wiki:CsrfProtection/>
 
     <div class="form-group">
       <button class="btn btn-success" type="submit" name="action" value="save">
diff --git a/jspwiki-war/src/main/webapp/templates/default/FindContent.jsp b/jspwiki-war/src/main/webapp/templates/default/FindContent.jsp
index c85371ca6..fae834803 100644
--- a/jspwiki-war/src/main/webapp/templates/default/FindContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/FindContent.jsp
@@ -41,6 +41,7 @@
     placeholder="<fmt:message key="find.input" />"
       autofocus="autofocus"
            size="32" />
+    <wiki:CsrfProtection/>
 
     <div class="form-inline form-group">
 
diff --git a/jspwiki-war/src/main/webapp/templates/default/GroupTab.jsp b/jspwiki-war/src/main/webapp/templates/default/GroupTab.jsp
index 4d8027759..c3a521266 100644
--- a/jspwiki-war/src/main/webapp/templates/default/GroupTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/GroupTab.jsp
@@ -66,6 +66,7 @@
 
     <h4><fmt:message key="newgroup.heading.create"/></h4>
     <input type="hidden" name="action"  value="save" />
+    <wiki:CsrfProtection/>
 
     <fmt:message key='newgroup.errorprefix' var="msg"/>
     <wiki:Messages div="alert alert-danger form-col-offset-20 form-col-50" topic="group" prefix="${msg}"/>
@@ -102,6 +103,7 @@
         name="deleteGroupForm" id="deleteGroupForm"
       method="POST" accept-charset="UTF-8">
   <input type="hidden" name="group" value="${group.name}" />
+  <wiki:CsrfProtection/>
   <input type="submit" name="ok"
    data-modal="+ .modal"
         value="<fmt:message key="actions.deletegroup"/>" />
diff --git a/jspwiki-war/src/main/webapp/templates/default/InfoContent.jsp b/jspwiki-war/src/main/webapp/templates/default/InfoContent.jsp
index 744bf0c75..89c2d2e71 100644
--- a/jspwiki-war/src/main/webapp/templates/default/InfoContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/InfoContent.jsp
@@ -120,6 +120,7 @@
               id="renameform"
           method="post" accept-charset="<wiki:ContentEncoding />" >
 
+      <wiki:CsrfProtection/>
       <input type="hidden" name="page" value="<wiki:Variable var='pagename' />" />
       <input class="btn btn-success" type="submit" name="rename" value="<fmt:message key='info.rename.submit' />" />
       <input class="form-control form-col-50" type="text" name="renameto"
@@ -142,6 +143,7 @@
       <input class="btn btn-danger" type="submit" name="delete-all" id="delete-all"
         data-modal="+ .modal"
             value="<fmt:message key='info.delete.submit'/>" />
+      <wiki:CsrfProtection/>
       <div class="modal"><fmt:message key='info.confirmdelete'/></div>
     </form>
   </wiki:Permission>
@@ -262,7 +264,7 @@
 
   <%-- Do NOT change the order of wikiname and content, otherwise the
        servlet won't find its parts. --%>
-
+  <wiki:CsrfProtection/>
   <h4><span class="icon-paper-clip"></span> <fmt:message key="info.uploadnew"/></h4>
 
     <div class="form-group">
@@ -310,6 +312,7 @@
     </fmt:message>
   </a>
 --%>
+  <wiki:CsrfProtection/>
   <wiki:Permission permission="delete">
     <input class="btn btn-danger" type="submit" name="delete-all" id="delete-all"
       data-modal="+ .modal"
diff --git a/jspwiki-war/src/main/webapp/templates/default/LoginContent.jsp b/jspwiki-war/src/main/webapp/templates/default/LoginContent.jsp
index e6acc78f3..4b8cfadbe 100644
--- a/jspwiki-war/src/main/webapp/templates/default/LoginContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/LoginContent.jsp
@@ -55,7 +55,7 @@
           id="login"
        class="login-form"
       method="post" accept-charset="<wiki:ContentEncoding />" >
-
+    <wiki:CsrfProtection/>
     <p class="login-header">
       <fmt:message key="login.heading.login">
         <fmt:param><wiki:Variable var="applicationname" /></fmt:param>
@@ -122,6 +122,7 @@
        class="login-form"
       method="post" accept-charset="<wiki:ContentEncoding />" >
 
+  <wiki:CsrfProtection/>
   <p class="login-header"><fmt:message key="login.lostpw.title" /></p>
 
   <c:choose>
@@ -190,6 +191,7 @@
        class="login-form"
       method="post" accept-charset="UTF-8">
 
+  <wiki:CsrfProtection/>
   <input type="hidden" name="redirect" value="<wiki:Variable var='redirect' default='' />" />
 
   <p class="login-header"><fmt:message key="login.registernow.title" /></p>
diff --git a/jspwiki-war/src/main/webapp/templates/default/PageTab.jsp b/jspwiki-war/src/main/webapp/templates/default/PageTab.jsp
index b889a1dc1..8e7660a2b 100644
--- a/jspwiki-war/src/main/webapp/templates/default/PageTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/PageTab.jsp
@@ -48,6 +48,7 @@
         method="get"  accept-charset='UTF-8'>
 
     <input type="hidden" name="page" value="${param.page}" />
+    <wiki:CsrfProtection/>
     <div class="error center">
       <label>
       <fmt:message key="view.oldversion">
diff --git a/jspwiki-war/src/main/webapp/templates/default/PreferencesTab.jsp b/jspwiki-war/src/main/webapp/templates/default/PreferencesTab.jsp
index d1b1a4fe5..4da7bbb17 100644
--- a/jspwiki-war/src/main/webapp/templates/default/PreferencesTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/PreferencesTab.jsp
@@ -47,6 +47,7 @@
       method="post" accept-charset="<wiki:ContentEncoding />" >
 
   <input type="hidden" name="redirect" value="${redirect}" />
+  <wiki:CsrfProtection/>
 
   <div class="form-group ">
 
diff --git a/jspwiki-war/src/main/webapp/templates/default/ProfileTab.jsp b/jspwiki-war/src/main/webapp/templates/default/ProfileTab.jsp
index 36a7befbe..d58b051a3 100644
--- a/jspwiki-war/src/main/webapp/templates/default/ProfileTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/ProfileTab.jsp
@@ -43,6 +43,7 @@
           id="editProfile">
 
   <input type="hidden" name="redirect" value="<wiki:Variable var='redirect' default='' />" />
+  <wiki:CsrfProtection/>
 
   <div class="form-group">
     <span class="form-col-20 control-label"></span>
diff --git a/jspwiki-war/src/main/webapp/templates/default/SearchBox.jsp b/jspwiki-war/src/main/webapp/templates/default/SearchBox.jsp
index cf7144e32..53df644a2 100644
--- a/jspwiki-war/src/main/webapp/templates/default/SearchBox.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/SearchBox.jsp
@@ -28,6 +28,7 @@
   id="searchForm" tabindex="0" role="search"
   accept-charset="<wiki:ContentEncoding />">
 
+  <wiki:CsrfProtection/>
   <%-- FFS <div onclick="" class="btn">
     the onclick="" is needed for hover effect on ipad https://www.codehaven.co.uk/fix-css-hover-on-iphone-ipad/ --%>
   <a href="#" aria-label="<fmt:message key='sbox.search.button'/>" class="btn">
diff --git a/jspwiki-war/src/main/webapp/templates/default/UserBox.jsp b/jspwiki-war/src/main/webapp/templates/default/UserBox.jsp
index 1ce74e48d..4b7ab6c63 100644
--- a/jspwiki-war/src/main/webapp/templates/default/UserBox.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/UserBox.jsp
@@ -105,13 +105,13 @@
       --%>
       <wiki:UserCheck status="authenticated">
         <a href="<wiki:Link jsp='Logout.jsp' format='url' />"
-          class="btn btn-default btn-block logout" data-modal=".logout > .modal">
+          class="btn btn-default btn-block logout" data-modal="+ .modal">
             <span class="icon-signout"></span> <fmt:message key="actions.logout"/>
-          <div class="modal">
-            <h4><fmt:message key="actions.logout"/></h4>
-            <p><fmt:message key='actions.confirmlogout'/></p>
-          </div>
         </a>
+        <div class="modal">
+          <h4><fmt:message key="actions.logout"/></h4>
+          <p><fmt:message key='actions.confirmlogout'/></p>
+        </div>
       </wiki:UserCheck>
     </li>
   </ul>
diff --git a/jspwiki-war/src/main/webapp/templates/default/WorkflowContent.jsp b/jspwiki-war/src/main/webapp/templates/default/WorkflowContent.jsp
index a8e2b0d46..8eb39bdcb 100644
--- a/jspwiki-war/src/main/webapp/templates/default/WorkflowContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/WorkflowContent.jsp
@@ -84,6 +84,7 @@
             <form action="<wiki:Link jsp='Workflow.jsp' format='url'/>"
                       id="decision.${decision.id}"
                   method="POST" accept-charset="UTF-8">
+              <wiki:CsrfProtection/>
               <input type="hidden" name="action" value="decide" />
               <input type="hidden" name="id" value="${decision.id}" />
               <c:forEach var="outcome" items="${decision.availableOutcomes}">
@@ -163,6 +164,7 @@
             <form id="workflow.${workflow.id}"
               action="<wiki:Link jsp='Workflow.jsp' format='url'/>"
               method="POST" accept-charset="UTF-8">
+              <wiki:CsrfProtection/>
               <input class="btn btn-danger btn-xs" type="submit" name="submit" value="<fmt:message key="outcome.step.abort" />" />
               <input type="hidden" name="action" value="abort" />
               <input type="hidden" name="id" value="${workflow.id}" />
diff --git a/jspwiki-war/src/main/webapp/templates/default/admin/AdminTemplate.jsp b/jspwiki-war/src/main/webapp/templates/default/admin/AdminTemplate.jsp
index c3b4f826a..184f2e626 100644
--- a/jspwiki-war/src/main/webapp/templates/default/admin/AdminTemplate.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/admin/AdminTemplate.jsp
@@ -56,6 +56,7 @@ in your <code>jspwiki.properties</code> file.</div>
 
       <div class="formcontainer">
       <form action="Admin.jsp" method="post" accept-charset="UTF-8">
+        <wiki:CsrfProtection/>
         <input type="hidden" name="tab-admin" value="core"/>
         <input type="hidden" name="tab-core" value="${ab.title}" />
         <input type="hidden" name="bean" value="${ab.id}" />
@@ -88,6 +89,7 @@ in your <code>jspwiki.properties</code> file.</div>
 
       <div class="formcontainer">
       <form action="Admin.jsp" method="post" accept-charset="UTF-8">
+         <wiki:CsrfProtection/>
          <input type="hidden" name="tab-admin" value="editors"/>
          <input type="hidden" name="tab-editors" value="${ab.title}" />
          <%
diff --git a/jspwiki-war/src/main/webapp/templates/default/admin/UserManagement.jsp b/jspwiki-war/src/main/webapp/templates/default/admin/UserManagement.jsp
index abd32b545..30217d23c 100644
--- a/jspwiki-war/src/main/webapp/templates/default/admin/UserManagement.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/admin/UserManagement.jsp
@@ -76,6 +76,7 @@ function addNew()
           id="adminuserform"
       method="post" accept-charset="<wiki:ContentEncoding/>"
      enctype="application/x-www-form-urlencoded" >
+     <wiki:CsrfProtection/>
      <input type="hidden" name='bean' value='org.apache.wiki.ui.admin.beans.UserBean'/>
      <input type="hidden" id="loginid" name="loginid" value="" />
      <table>
@@ -131,7 +132,7 @@ function addNew()
 
      </table>
    <div id="useractions">
-     <input type="submit" name="action" value="Remove" data-modal="#useractions > .modal" />
+     <input type="submit" name="action" value="Remove" data-modal="+ .modal" />
      <div class="modal">
        <p>Are you sure you wish to remove this user?</p>
      </div>
diff --git a/jspwiki-war/src/main/webapp/templates/default/commonheader.jsp b/jspwiki-war/src/main/webapp/templates/default/commonheader.jsp
index 8aceb2298..5539cb90d 100644
--- a/jspwiki-war/src/main/webapp/templates/default/commonheader.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/commonheader.jsp
@@ -100,6 +100,7 @@ String.I18N.PREFIX = "javascript.";
 <meta name="wikiUserName" content="<wiki:UserName />" />
 <meta name="wikiTemplateUrl" content='<wiki:Link format="url" templatefile="" />' />
 <meta name="wikiApplicationName" content='<wiki:Variable var="ApplicationName" />' />
+<wiki:CsrfProtection format="meta" />
 <%--CHECKME
     <wiki:link> seems not to lookup the right jsp from the right template directory
     EG when a templatefile is not present, the generated link should point to the default template.
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp
index 0e76da44b..6a973858f 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp
@@ -134,6 +134,7 @@
           id="editform"
      enctype="application/x-www-form-urlencoded" >
 
+  <wiki:CsrfProtection/>
   <%-- Edit.jsp relies on these being found.  So be careful, if you make changes. --%>
   <input type="hidden" name="page" value="<wiki:Variable var='pagename' />" />
   <input type="hidden" name="action" value="save" />
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp
index 9fd7c8a41..ec156fa62 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp
@@ -136,6 +136,7 @@
           id="editform"
      enctype="application/x-www-form-urlencoded" >
 
+  <wiki:CsrfProtection/>
   <%-- Edit.jsp relies on these being found.  So be careful, if you make changes. --%>
   <input type="hidden" name="page" value="<wiki:Variable var='pagename' />" />
   <input type="hidden" name="action" value="save" />
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/plain.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/plain.jsp
index 7b10ced7f..0187b60db 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/plain.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/plain.jsp
@@ -84,6 +84,7 @@
           id="editform"
      enctype="application/x-www-form-urlencoded" >
 
+  <wiki:CsrfProtection/>
   <%-- Edit.jsp relies on these being found.  So be careful, if you make changes. --%>
   <input type="hidden" name="page" value="<wiki:Variable var='pagename' />" />
   <input type="hidden" name="action" value="save" />
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/preview.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/preview.jsp
index f39a0af1c..1baf06904 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/preview.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/preview.jsp
@@ -45,7 +45,7 @@
           id="editform"
      enctype="application/x-www-form-urlencoded">
 
-  
+    <wiki:CsrfProtection/>
     <%-- Edit.jsp & Comment.jsp rely on these being found.  So be careful, if you make changes. --%>
     <input type="hidden" name="author" value="${author}" />
     <input type="hidden" name="link" value="${link}" />
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/wysiwyg.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/wysiwyg.jsp
index 387bd70c0..2c4617a50 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/wysiwyg.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/wysiwyg.jsp
@@ -128,6 +128,7 @@
           id="editform"
      enctype="application/x-www-form-urlencoded" >
 
+  <wiki:CsrfProtection/>
   <%-- Edit.jsp relies on these being found.  So be careful, if you make changes. --%>
   <input type="hidden" name="page" value="<wiki:Variable var='pagename' />" />
   <input type="hidden" name="action" value="save" />


[jspwiki] 07/25: new jspwiki-http module

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 7c1255e2ec77cb000fc0abd411fc931758784abc
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:45:42 2022 +0200

    new jspwiki-http module
    
    eventually it will contain all JSPWiki servlets, filters, listeners, etc. As for now it only contains a CSRF protection filter
---
 jspwiki-bom/pom.xml                                |  6 ++
 jspwiki-http/pom.xml                               | 91 ++++++++++++++++++++++
 .../wiki/http/filter/CsrfProtectionFilter.java     | 63 +++++++++++++++
 .../src/main/resources/META-INF/web-fragment.xml   | 34 ++++++++
 4 files changed, 194 insertions(+)

diff --git a/jspwiki-bom/pom.xml b/jspwiki-bom/pom.xml
index 3b85fea19..06729610f 100644
--- a/jspwiki-bom/pom.xml
+++ b/jspwiki-bom/pom.xml
@@ -73,6 +73,12 @@
         <version>${jspwiki.version}</version>
       </dependency>
 
+      <dependency>
+        <groupId>org.apache.jspwiki</groupId>
+        <artifactId>jspwiki-http</artifactId>
+        <version>${jspwiki.version}</version>
+      </dependency>
+
       <dependency>
         <groupId>org.apache.jspwiki</groupId>
         <artifactId>jspwiki-kendra-searchprovider</artifactId>
diff --git a/jspwiki-http/pom.xml b/jspwiki-http/pom.xml
new file mode 100644
index 000000000..d3d4fd993
--- /dev/null
+++ b/jspwiki-http/pom.xml
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <parent>
+    <groupId>org.apache.jspwiki</groupId>
+    <artifactId>jspwiki-builder</artifactId>
+    <version>2.11.3-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>jspwiki-http</artifactId>
+  <name>Apache JSPWiki http servlet and filters</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>jspwiki-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+	<dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>jspwiki-util</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-1.2-api</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>javax.servlet-api</artifactId>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-params</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-engine</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-junit-jupiter</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/jspwiki-http/src/main/java/org/apache/wiki/http/filter/CsrfProtectionFilter.java b/jspwiki-http/src/main/java/org/apache/wiki/http/filter/CsrfProtectionFilter.java
new file mode 100644
index 000000000..aed2ca8e4
--- /dev/null
+++ b/jspwiki-http/src/main/java/org/apache/wiki/http/filter/CsrfProtectionFilter.java
@@ -0,0 +1,63 @@
+package org.apache.wiki.http.filter;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Session;
+import org.apache.wiki.api.spi.Wiki;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+
+/**
+ * CSRF protection Filter which uses the synchronizer token pattern – an anti-CSRF token is created and stored in the
+ * user session and in a hidden field on subsequent form submits. At every submit the server checks the token from the
+ * session matches the one submitted from the form.
+ */
+public class CsrfProtectionFilter implements Filter {
+
+    private static final Logger LOG = LogManager.getLogger( CsrfProtectionFilter.class );
+
+    public static final String ANTICSRF_PARAM = "X-XSRF-TOKEN";
+
+    /** {@inheritDoc} */
+    @Override
+    public void init( final FilterConfig filterConfig ) {
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void doFilter( final ServletRequest request, final ServletResponse response, final FilterChain chain ) throws IOException, ServletException {
+        if( "POST".equalsIgnoreCase( ( ( HttpServletRequest ) request ).getMethod() ) ) {
+            final Engine engine = Wiki.engine().find( request.getServletContext(), null );
+            final Session session = Wiki.session().find( engine, ( HttpServletRequest ) request );
+            if( !session.antiCsrfToken().equals( request.getParameter( ANTICSRF_PARAM ) ) ) {
+                LOG.error( "Incorrect {} param with value '{}' received for {}",
+                           ANTICSRF_PARAM, request.getParameter( ANTICSRF_PARAM ), ( ( HttpServletRequest ) request ).getPathInfo() );
+                final PrintWriter out = response.getWriter();
+                out.print("<!DOCTYPE html><html lang=\"en\"><head><title>Fatal problem with JSPWiki</title></head>");
+                out.print("<body>");
+                out.print("<h1>CSRF injection detected</h1>");
+                out.print("<p>A CSRF injection has been detected, so the request has been stopped</p>");
+                out.print("<p>Please check your system logs to pinpoint the request origin, someone's trying to mess with your installation.</p>");
+                out.print("</body></html>");
+                return;
+            }
+        }
+        chain.doFilter( request, response );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void destroy() {
+    }
+
+}
diff --git a/jspwiki-http/src/main/resources/META-INF/web-fragment.xml b/jspwiki-http/src/main/resources/META-INF/web-fragment.xml
new file mode 100644
index 000000000..606e68b10
--- /dev/null
+++ b/jspwiki-http/src/main/resources/META-INF/web-fragment.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+-->
+
+<web-fragment xmlns="http://java.sun.com/xml/ns/javaee"
+              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+              xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-fragment_3_0.xsd"
+              version="3.0">
+    <filter>
+      <filter-name>CsrfProtectionFilter</filter-name>
+      <filter-class>org.apache.wiki.http.filter.CsrfProtectionFilter</filter-class>
+    </filter>
+
+    <filter-mapping>
+      <filter-name>CsrfProtectionFilter</filter-name>
+      <url-pattern>/*</url-pattern>
+    </filter-mapping>
+</web-fragment>
\ No newline at end of file


[jspwiki] 18/25: Ensure AJAX requests send the csrf protection parameter

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 25f3c707a9c6c5541e389beb7a9c56acccb4b3f0
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:58:25 2022 +0200

    Ensure AJAX requests send the csrf protection parameter
---
 jspwiki-war/src/main/scripts/jspwiki-common.js      | 4 ++--
 jspwiki-war/src/main/scripts/jspwiki-edit.js        | 2 +-
 jspwiki-war/src/main/scripts/wiki-edit/Wiki.Edit.js | 3 ++-
 jspwiki-war/src/main/scripts/wiki/Category.js       | 5 ++++-
 jspwiki-war/src/main/scripts/wiki/Wiki.js           | 5 +++--
 5 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/jspwiki-war/src/main/scripts/jspwiki-common.js b/jspwiki-war/src/main/scripts/jspwiki-common.js
index 10fd693f5..aef3516cd 100644
--- a/jspwiki-war/src/main/scripts/jspwiki-common.js
+++ b/jspwiki-war/src/main/scripts/jspwiki-common.js
@@ -528,7 +528,7 @@ var Wiki = {
 		xmlHttpRequest.onreadystatechange = getReadyStateHandler(xmlHttpRequest,responseId,loading);
 		xmlHttpRequest.open('post', url, true);
 		xmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
-		xmlHttpRequest.send("params="+params);
+		xmlHttpRequest.send("X-XSRF-TOKEN=" + Wiki.CsrfProtection + "&params="+params);
 	},
 
 	ajaxJsonCall: function (url, params, callback) {
@@ -537,7 +537,7 @@ var Wiki = {
 		xmlHttpRequest.onreadystatechange = getReadyStateHandler(xmlHttpRequest,null,null,callback);
 		xmlHttpRequest.open('post', url, true);
 		xmlHttpRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
-		xmlHttpRequest.send("params="+params);
+		xmlHttpRequest.send("X-XSRF-TOKEN=" + Wiki.CsrfProtection + "&params="+params);
 	}
 }
 
diff --git a/jspwiki-war/src/main/scripts/jspwiki-edit.js b/jspwiki-war/src/main/scripts/jspwiki-edit.js
index bb975ac33..0cb72f79e 100644
--- a/jspwiki-war/src/main/scripts/jspwiki-edit.js
+++ b/jspwiki-war/src/main/scripts/jspwiki-edit.js
@@ -507,7 +507,7 @@ var EditTools =
 		$('previewSpin').show();
 		new Ajax( Wiki.TemplateUrl + "/AJAXPreview.jsp?page="+Wiki.PageName, {
 		    method:'get',   //use "get" to avoid mootools bug on XHR header "CONNECTION:CLOSE"
-			data: 'wikimarkup=' + encodeURIComponent(this.textarea.value),
+			data: 'X-XSRF-TOKEN=' + $('X-XSRF-TOKEN').get('value') + '&wikimarkup=' + encodeURIComponent(this.textarea.value),
 			update: preview,
 			onComplete: function(){
 				$('previewSpin').hide();
diff --git a/jspwiki-war/src/main/scripts/wiki-edit/Wiki.Edit.js b/jspwiki-war/src/main/scripts/wiki-edit/Wiki.Edit.js
index e6bf49b7b..9642341ca 100644
--- a/jspwiki-war/src/main/scripts/wiki-edit/Wiki.Edit.js
+++ b/jspwiki-war/src/main/scripts/wiki-edit/Wiki.Edit.js
@@ -209,7 +209,8 @@ function livepreview(content, preview, previewToggle){
             url: wiki.XHRPreview,
             data: {
                 page: wiki.PageName,
-                wikimarkup: content
+                wikimarkup: content,
+                'X-XSRF-TOKEN': wiki.CsrfProtection
             },
             update: preview,
             onRequest: renderPreview,
diff --git a/jspwiki-war/src/main/scripts/wiki/Category.js b/jspwiki-war/src/main/scripts/wiki/Category.js
index da24d8c7f..5a1c59c1d 100644
--- a/jspwiki-war/src/main/scripts/wiki/Category.js
+++ b/jspwiki-war/src/main/scripts/wiki/Category.js
@@ -59,7 +59,10 @@ Wiki.Category = function(element, pagename, xhrURL){
 
         new Request.HTML({
             url: xhrURL, //+"?page="+pagename,
-            data: { page: decodeURIComponent(pagename) },
+            data: {
+                page: decodeURIComponent(pagename),
+                'X-XSRF-TOKEN': Wiki.CsrfProtection
+            },
             update: popup,
             onSuccess: function(){
                 popup.swapClass("loading", "active");
diff --git a/jspwiki-war/src/main/scripts/wiki/Wiki.js b/jspwiki-war/src/main/scripts/wiki/Wiki.js
index dc0211ee6..6b9c432da 100644
--- a/jspwiki-war/src/main/scripts/wiki/Wiki.js
+++ b/jspwiki-war/src/main/scripts/wiki/Wiki.js
@@ -657,7 +657,8 @@ var Wiki = {
             new Request({
                 url: wiki.XHRHtml2Markup,
                 data: {
-                    htmlPageText: getContent()
+                    htmlPageText: getContent(),
+                    'X-XSRF-TOKEN': wiki.CsrfProtection
                 },
                 onSuccess: function(responseText){
                     preview( responseText.trim() );
@@ -819,7 +820,7 @@ var Wiki = {
                     throw new Error("Wiki rpc error: " + error);
                 }
 
-            }).send( "params=" + params );
+            }).send( "X-XSRF-TOKEN=" + this.CsrfProtection + "&params=" + params );
 
         }
 


[jspwiki] 03/25: Minor format edits

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 0cbf45c78bc13f8be2d0ef31807f711f4be21a7f
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue May 3 22:59:23 2022 +0200

    Minor format edits
---
 .../src/main/java/org/apache/wiki/plugin/TableOfContents.java         | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/TableOfContents.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/TableOfContents.java
index 3c6928426..a658fd935 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/TableOfContents.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/TableOfContents.java
@@ -84,7 +84,7 @@ public class TableOfContents implements Plugin, HeadingListener {
      */
     @Override
     public void headingAdded( final Context context, final Heading hd ) {
-        log.debug( "HD: " + hd.m_level + ", " + hd.m_titleText + ", " + hd.m_titleAnchor );
+        log.debug( "HD: {}, {}, {}", hd.m_level, hd.m_titleText, hd.m_titleAnchor );
 
         switch( hd.m_level ) {
           case Heading.HEADING_SMALL:
@@ -148,7 +148,7 @@ public class TableOfContents implements Plugin, HeadingListener {
      *  {@inheritDoc}
      */
     @Override
-    public String execute( final Context context, final Map<String, String> params ) throws PluginException {
+    public String execute( final Context context, final Map< String, String > params ) throws PluginException {
         final Engine engine = context.getEngine();
         final Page page = context.getPage();
         final ResourceBundle rb = Preferences.getBundle( context, Plugin.CORE_PLUGINS_RESOURCEBUNDLE );


[jspwiki] 25/25: 2.11.3-git-09

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 69a48e16f593237b20e3140d183410a7447bc259
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 23:02:49 2022 +0200

    2.11.3-git-09
---
 ChangeLog.md                                       | 28 ++++++++++++++++++++++
 .../src/main/java/org/apache/wiki/api/Release.java |  2 +-
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index f393d65aa..acda48412 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -17,6 +17,34 @@ specific language governing permissions and limitations
 under the License.
 -->
 
+**2022-07-12  Juan Pablo Santos (juanpablo AT apache DOT org)**
+
+* _2.11.3-git-09_
+
+* New `CsrfProtectionFilter` to protect POST requests from CSRF attacks
+    * `org.apache.wiki.api.core.Session` gains new `String antiCsrfToken()` method 
+
+* [`org.apache.wiki.markdown.migration.WikiSyntaxConverter`] to convert from JSPWiki syntax to markdown
+    * does not keep pages' history nor attachments (yet), but it's enough to generate the basic set of wikipages from jspwiki-wikipages artifacts
+
+* Fixed logout modal dialog not showing up
+
+* `TestEngine` is able to not clean up directories / ensure they have unique names if `jspwiki.test.disable-clean-props` wiki property is set to `true` 
+
+* Fixed integration tests
+    * Upgrade to cargo-maven3 broke the launch configuration
+    * Latest Selenide upgrades broke SearchIT, which wasn't hovering on search form
+
+* Merged PRs [#192](https://github.com/apache/jspwiki/pull/192), [#193](https://github.com/apache/jspwiki/pull/193), [#195](https://github.com/apache/jspwiki/pull/195) and [#196](https://github.com/apache/jspwiki/pull/196), provided by [Arturo Bernal](https://github.com/arturobernalg), thanks!
+
+* Dependency updates
+    * Log4J to 2.18.0
+    * Lucene to 8.11.2
+    * Selenide to 6.6.6
+    * Tika to 2.4.1 - closes [#187](https://github.com/apache/jspwiki/pull/187)
+    * Tomcat to 9.0.64 - closes [#189](https://github.com/apache/jspwiki/pull/189)
+    * Maven plugins: antrun to 3.1.0  (closes [#190](https://github.com/apache/jspwiki/pull/190), thanks to dependabot), assembly to 3.4.1, enforcer to 3.1.0, surefire to 3.0.0-M7, cargo-maven3 to 1.9.13 (closes [#197](https://github.com/apache/jspwiki/pull/197), thanks to dependabot)
+
 **2022-05-01  Juan Pablo Santos (juanpablo AT apache DOT org)**
 
 * _2.11.3-git-08_
diff --git a/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java b/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java
index 3fcfb7f55..9ef68f1fa 100644
--- a/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java
+++ b/jspwiki-api/src/main/java/org/apache/wiki/api/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         = "08";
+    public static final String     BUILD         = "09";
 
     /**
      *  This is the generic version string you should use when printing out the version.  It is of


[jspwiki] 16/25: FormOpen generates csrf protection hidden input

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d42623bcc66aaead9281de544717fe2211c4a149
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:56:59 2022 +0200

    FormOpen generates csrf protection hidden input
---
 jspwiki-main/src/main/java/org/apache/wiki/forms/FormOpen.java | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOpen.java b/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOpen.java
index 5d6bdf2b5..4e6cb1e42 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOpen.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/forms/FormOpen.java
@@ -24,6 +24,7 @@ import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.ContextEnum;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.Plugin;
+import org.apache.wiki.http.filter.CsrfProtectionFilter;
 import org.apache.wiki.preferences.Preferences;
 
 import java.text.MessageFormat;
@@ -90,7 +91,9 @@ public class FormOpen extends FormElement {
             submitServlet = ctx.getURL( ContextEnum.PAGE_VIEW.getRequestContext(), sourcePage );
 
         String method = params.get( PARAM_METHOD );
-        if( method == null ) method="post";
+        if( method == null ) {
+            method="post";
+        }
 
         if( !( method.equalsIgnoreCase( "get" ) || method.equalsIgnoreCase( "post" ) ) ) {
             throw new PluginException( rb.getString( "formopen.postorgetonly" ) );
@@ -125,7 +128,8 @@ public class FormOpen extends FormElement {
                   "<form action=\"" + submitServlet + "\" name=\"" + formName + "\" " +
                         "accept-charset=\"" + ctx.getEngine().getContentEncoding() + "\" " +
                         "method=\"" + method + "\" enctype=\"application/x-www-form-urlencoded\">\n" +
-                  "  <input type=\"hidden\" name=\"" + PARAM_FORMNAMEHIDDEN + "\" value=\"" + formName + "\"/>\n";
+                  "  <input type=\"hidden\" name=\"" + PARAM_FORMNAMEHIDDEN + "\" value=\"" + formName + "\"/>\n" +
+                  "  <input type=\"hidden\" name=\"" + CsrfProtectionFilter.ANTICSRF_PARAM + "\" value=\"" + ctx.getWikiSession().antiCsrfToken() + "\"/>\n";
     }
 
 }


[jspwiki] 01/25: Upgrade Tika to 2.4.0

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a39e1a81a7433ae472a69da8ccb0b9a7553b40a2
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue May 3 22:57:59 2022 +0200

    Upgrade Tika to 2.4.0
---
 LICENSE | 4 ++--
 pom.xml | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/LICENSE b/LICENSE
index 1a04fef83..c60d54ca2 100644
--- a/LICENSE
+++ b/LICENSE
@@ -272,8 +272,8 @@ oro-2.0.8.jar                               LICENSE
 sandler-0.5.jar                             ./jspwiki-war/src/main/config/doc/LICENSE.sandler
 slf4-api-1.7.36.jar                         ./jspwiki-war/src/main/config/doc/LICENSE.mit
 xercesImpl-2.10.0.jar                       LICENSE
-tika-core-2.3.0.jar                         LICENSE
-tika-parsers-2.3.0.jar                      LICENSE
+tika-core-2.4.0.jar                         LICENSE
+tika-parsers-2.4.0.jar                      LICENSE
 xml-apis-1.4.01                             LICENSE
 xmlrpc-2.0.1.jar                            LICENSE
 xpp3-1.1.3.4-RC3                            ./jspwiki-war/src/main/config/doc/LICENSE.cc-cod
diff --git a/pom.xml b/pom.xml
index 41dcbf063..ba98114e2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -77,7 +77,7 @@
     <selenide.version>6.4.0</selenide.version>
     <slf4j.version>1.7.36</slf4j.version>
     <stripes.version>1.7.0-async-beta</stripes.version>
-    <tika.version>2.3.0</tika.version>
+    <tika.version>2.4.0</tika.version>
     <tomcat.version>9.0.62</tomcat.version>
     <wro4j.version>1.8.0</wro4j.version> <!-- 1.9.0 and above require JDK >= 9 to execute -->
     <xmlrpc.version>2.0.1</xmlrpc.version>


[jspwiki] 24/25: Update mvn cheat sheet

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit b7cf446d85a5563f0e68ce4d7863e44741bfec0b
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 23:02:31 2022 +0200

    Update mvn cheat sheet
---
 mvn_cheat-sheet.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mvn_cheat-sheet.md b/mvn_cheat-sheet.md
index a94e25f78..4b9928bcf 100644
--- a/mvn_cheat-sheet.md
+++ b/mvn_cheat-sheet.md
@@ -53,5 +53,5 @@ under the License.
 | mvn apache-rat:check                                    | creates an Apache RAT report. See: http://creadur.apache.org/rat/apache-rat-plugin/plugin-info.html |
 | mvn cobertura:cobertura                                 | generates a cobertura maven report. See: http://mojo.codehaus.org/cobertura-maven-plugin/usage.html |
 | mvn javadoc:javadoc                                     | creates javadocs adding some UML class/package level diagrams (requires JDK<= 8)                    |
-| mvn javadoc:javadoc -Djdk.javadoc.doclet.version=2.0.16 | same as above, but with JDK >= 9                                                                    |
+| mvn javadoc:javadoc -Djdk.javadoc.doclet.version=2.0.18 | same as above, but with JDK >= 9                                                                    |
 | mvn sonar:sonar                                         | generates a Sonar report. Expects a Sonar server running at http://localhost:9000/                  |


[jspwiki] 19/25: JSPWiki to Markdown syntax conversion tool

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 087f90afab36f7962367a7dbe7dac0339e93c400
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:59:07 2022 +0200

    JSPWiki to Markdown syntax conversion tool
---
 .../markdown/migration/WikiSyntaxConverter.java    | 74 ++++++++++++++++++++++
 .../migration/filters/TidyMarkupFilter.java        | 18 ++++++
 .../parser/JSPWikiToMarkdownMarkupParser.java      | 63 ++++++++++++++++++
 3 files changed, 155 insertions(+)

diff --git a/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/WikiSyntaxConverter.java b/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/WikiSyntaxConverter.java
new file mode 100644
index 000000000..ce3856fdd
--- /dev/null
+++ b/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/WikiSyntaxConverter.java
@@ -0,0 +1,74 @@
+/*
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+ */
+package org.apache.wiki.markdown.migration;
+
+import org.apache.wiki.TestEngine;
+import org.apache.wiki.api.core.Context;
+import org.apache.wiki.api.core.ContextEnum;
+import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Page;
+import org.apache.wiki.api.spi.Wiki;
+import org.apache.wiki.htmltowiki.HtmlStringToWikiTranslator;
+import org.apache.wiki.markdown.migration.parser.JSPWikiToMarkdownMarkupParser;
+import org.apache.wiki.pages.PageManager;
+import org.apache.wiki.plugin.PluginManager;
+import org.apache.wiki.render.RenderingManager;
+import org.junit.jupiter.api.Test;
+
+import java.util.Collection;
+
+import static org.apache.wiki.TestEngine.with;
+
+
+public class WikiSyntaxConverter {
+
+    @Test
+    void jspwikiToMarkdownConverter() throws Exception {
+        final Engine jspw = buildEngine( "jspwiki", "../jspwiki-wikipages/en/src/main/resources" );
+        final Engine md = buildEngine( "markdown", "./target/pages-markdown" );
+        jspw.getManager( PluginManager.class ).enablePlugins( false );
+
+        final Collection< Page > pages = jspw.getManager( PageManager.class ).getAllPages();
+        for( final Page p : pages ) {
+            final Context context = Wiki.context().create( jspw, p );
+            context.setRequestContext( ContextEnum.PAGE_NONE.getRequestContext() );
+            context.setVariable( Context.VAR_WYSIWYG_EDITOR_MODE, Boolean.TRUE );
+            final String pagedata = jspw.getManager( PageManager.class ).getPureText( p.getName(), p.getVersion() );
+            final String html = jspw.getManager( RenderingManager.class ).textToHTML( context, pagedata, null, null, null, false, false );
+            final String syntax = new HtmlStringToWikiTranslator( md ).translate( html );
+            final Context contextMD = Wiki.context().create( md, p );
+            md.getManager( PageManager.class ).saveText( contextMD, clean( syntax ) );
+        }
+    }
+
+    Engine buildEngine( final String syntax, final String pageDir ) {
+        return TestEngine.build( with( "jspwiki.fileSystemProvider.pageDir", pageDir ),
+                                 with( RenderingManager.PROP_PARSER, JSPWikiToMarkdownMarkupParser.class.getName() ), // will be overwritten if jspwiki.syntax=markdown
+                                 with( "jspwiki.test.disable-clean-props", "true" ),
+                                 with( "jspwiki.workDir", "./target/workDir" + syntax ),
+                                 with( "appender.rolling.fileName", "./target/wiki-" + syntax + ".log" ),
+                                 with( "jspwiki.cache.enable", "false" ),
+                                 with( "jspwiki.syntax", syntax ) );
+    }
+
+    String clean( final String wikiSyntax ) {
+        return wikiSyntax;
+    }
+
+}
diff --git a/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/filters/TidyMarkupFilter.java b/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/filters/TidyMarkupFilter.java
new file mode 100644
index 000000000..eda7311d4
--- /dev/null
+++ b/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/filters/TidyMarkupFilter.java
@@ -0,0 +1,18 @@
+package org.apache.wiki.markdown.migration.filters;
+
+import org.apache.wiki.api.core.Context;
+import org.apache.wiki.api.exceptions.FilterException;
+import org.apache.wiki.api.filters.BasePageFilter;
+
+
+/**
+ * Tidy up wiki markup in order to ease html -> markdown conversion.
+ */
+public class TidyMarkupFilter extends BasePageFilter {
+
+    @Override
+    public String preTranslate( final Context context, final String content ) throws FilterException {
+        //content.replace( "", "" )
+        return super.preTranslate( context, content );
+    }
+}
diff --git a/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/parser/JSPWikiToMarkdownMarkupParser.java b/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/parser/JSPWikiToMarkdownMarkupParser.java
new file mode 100644
index 000000000..999f43609
--- /dev/null
+++ b/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/parser/JSPWikiToMarkdownMarkupParser.java
@@ -0,0 +1,63 @@
+package org.apache.wiki.markdown.migration.parser;
+
+import org.apache.wiki.api.core.Context;
+import org.apache.wiki.parser.JSPWikiMarkupParser;
+import org.apache.wiki.parser.PluginContent;
+import org.apache.wiki.parser.WikiDocument;
+import org.jdom2.Content;
+import org.jdom2.Element;
+import org.jdom2.Text;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.util.List;
+
+
+public class JSPWikiToMarkdownMarkupParser extends JSPWikiMarkupParser {
+
+    /**
+     * Creates a markup parser.
+     *
+     * @param context The WikiContext which controls the parsing
+     * @param in      Where the data is read from.
+     */
+    public JSPWikiToMarkdownMarkupParser( final Context context, final Reader in ) {
+        super( context, in );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public WikiDocument parse() throws IOException {
+        final WikiDocument doc = super.parse();
+        translatePluginACLAndVariableTextLinksToMarkdown( doc.getRootElement(), 0 );
+        return doc;
+    }
+
+    void translatePluginACLAndVariableTextLinksToMarkdown( final Content element, final int childNumber ) {
+        if( element instanceof PluginContent ) {
+            final PluginContent plugin = ( PluginContent ) element;
+            final String str = plugin.getText();
+            if( str.startsWith( "[{" ) && str.endsWith( "}]" ) ) {
+                final Element parent = plugin.getParent();
+                plugin.detach();
+                if( parent != null ) {
+                    parent.addContent( childNumber, new Text( str + "()" ) );
+                }
+            }
+        } else if( element instanceof Text ) {
+            final Text text = ( Text )element;
+            if( text.getText().startsWith( "[{" ) && text.getText().endsWith( "}]" ) ) {
+                text.append( "()" );
+            }
+        } else if( element instanceof Element ) {
+            final Element base = ( Element )element;
+            base.getContent();
+            final List< Content > content = base.getContent();
+            for( int i = 0; i < content.size(); i++ ) {
+                final Content c = content.get( i );
+                translatePluginACLAndVariableTextLinksToMarkdown( c, i );
+            }
+        }
+    }
+
+}


[jspwiki] 02/25: only build & destroy one Engine for all tests in class

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 1617a34ab6a3f3f6260eb670629fc0b6f66ffd83
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue May 3 22:58:53 2022 +0200

    only build & destroy one Engine for all tests in class
---
 .../src/test/java/org/apache/wiki/plugin/WeblogPluginTest.java    | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/WeblogPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/WeblogPluginTest.java
index 353c2a6d0..9d2aba80c 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/WeblogPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/WeblogPluginTest.java
@@ -2,17 +2,17 @@ package org.apache.wiki.plugin;
 
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.api.exceptions.WikiException;
-import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.AfterAll;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
 
 public class WeblogPluginTest {
 
-    TestEngine testEngine = TestEngine.build();
+    static TestEngine testEngine = TestEngine.build();
 
-    @AfterEach
-    public void tearDown() throws Exception {
+    @AfterAll
+    public static void tearDown() throws Exception {
         testEngine.stop();
     }
 


[jspwiki] 20/25: Add missing AL headers

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit a55c6afd217032058f1d7f701b1d1426bb635e2b
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:59:57 2022 +0200

    Add missing AL headers
---
 .../markdown/migration/filters/TidyMarkupFilter.java   | 18 ++++++++++++++++++
 .../parser/JSPWikiToMarkdownMarkupParser.java          | 18 ++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/filters/TidyMarkupFilter.java b/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/filters/TidyMarkupFilter.java
index eda7311d4..a5f1230da 100644
--- a/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/filters/TidyMarkupFilter.java
+++ b/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/filters/TidyMarkupFilter.java
@@ -1,3 +1,21 @@
+/*
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+ */
 package org.apache.wiki.markdown.migration.filters;
 
 import org.apache.wiki.api.core.Context;
diff --git a/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/parser/JSPWikiToMarkdownMarkupParser.java b/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/parser/JSPWikiToMarkdownMarkupParser.java
index 999f43609..54a8097a9 100644
--- a/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/parser/JSPWikiToMarkdownMarkupParser.java
+++ b/jspwiki-markdown/src/test/java/org/apache/wiki/markdown/migration/parser/JSPWikiToMarkdownMarkupParser.java
@@ -1,3 +1,21 @@
+/*
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+ */
 package org.apache.wiki.markdown.migration.parser;
 
 import org.apache.wiki.api.core.Context;


[jspwiki] 11/25: format web.xml files

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 84740147ab1dd72a1ca6857f35d1b4313d4fc9aa
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:50:23 2022 +0200

    format web.xml files
---
 .../src/main/webapp/WEB-INF/web.xml                | 58 ++++++++--------------
 .../src/main/webapp/WEB-INF/web.xml                | 58 ++++++++--------------
 .../src/main/webapp/WEB-INF/web.xml                | 58 ++++++++--------------
 .../src/main/webapp/WEB-INF/web.xml                | 58 ++++++++--------------
 .../src/main/webapp/WEB-INF/web.xml                | 58 ++++++++--------------
 jspwiki-war/src/main/webapp/WEB-INF/web.xml        | 24 ++++-----
 6 files changed, 117 insertions(+), 197 deletions(-)

diff --git a/jspwiki-it-tests/jspwiki-it-test-cma-jdbc/src/main/webapp/WEB-INF/web.xml b/jspwiki-it-tests/jspwiki-it-test-cma-jdbc/src/main/webapp/WEB-INF/web.xml
index 6be2a4d9f..beb8a27e2 100644
--- a/jspwiki-it-tests/jspwiki-it-test-cma-jdbc/src/main/webapp/WEB-INF/web.xml
+++ b/jspwiki-it-tests/jspwiki-it-test-cma-jdbc/src/main/webapp/WEB-INF/web.xml
@@ -55,43 +55,27 @@
       possesses the correct "assertion cookie."
    -->
 
-   <filter>
-      <filter-name>WikiServletFilter</filter-name>
-      <filter-class>org.apache.wiki.ui.WikiServletFilter</filter-class>
-   </filter>
-   <filter>
-      <filter-name>WikiJSPFilter</filter-name>
-      <filter-class>org.apache.wiki.ui.WikiJSPFilter</filter-class>
-   </filter>
-
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/attach/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/atom/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/RPCU/</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/RPC2/</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/JSON-RPC</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiJSPFilter</filter-name>
-       <url-pattern>/wiki/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiJSPFilter</filter-name>
-       <url-pattern>*.jsp</url-pattern>
-   </filter-mapping>
+    <filter>
+        <filter-name>WikiServletFilter</filter-name>
+        <filter-class>org.apache.wiki.ui.WikiServletFilter</filter-class>
+    </filter>
+    <filter>
+        <filter-name>WikiJSPFilter</filter-name>
+        <filter-class>org.apache.wiki.ui.WikiJSPFilter</filter-class>
+    </filter>
+
+    <filter-mapping>
+        <filter-name>WikiServletFilter</filter-name>
+        <url-pattern>/attach/*</url-pattern>
+        <url-pattern>/atom/*</url-pattern>
+        <url-pattern>/RPCU/</url-pattern>
+        <url-pattern>/RPC2/</url-pattern>
+    </filter-mapping>
+    <filter-mapping>
+        <filter-name>WikiJSPFilter</filter-name>
+        <url-pattern>/wiki/*</url-pattern>
+        <url-pattern>*.jsp</url-pattern>
+    </filter-mapping>
 
    <!--
        HttpSessionListener used for managing WikiSession's.
diff --git a/jspwiki-it-tests/jspwiki-it-test-cma/src/main/webapp/WEB-INF/web.xml b/jspwiki-it-tests/jspwiki-it-test-cma/src/main/webapp/WEB-INF/web.xml
index 085b383e8..393a8430e 100644
--- a/jspwiki-it-tests/jspwiki-it-test-cma/src/main/webapp/WEB-INF/web.xml
+++ b/jspwiki-it-tests/jspwiki-it-test-cma/src/main/webapp/WEB-INF/web.xml
@@ -55,43 +55,27 @@
       possesses the correct "assertion cookie."
    -->
 
-   <filter>
-      <filter-name>WikiServletFilter</filter-name>
-      <filter-class>org.apache.wiki.ui.WikiServletFilter</filter-class>
-   </filter>
-   <filter>
-      <filter-name>WikiJSPFilter</filter-name>
-      <filter-class>org.apache.wiki.ui.WikiJSPFilter</filter-class>
-   </filter>
-
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/attach/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/atom/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/RPCU/</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/RPC2/</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/JSON-RPC</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiJSPFilter</filter-name>
-       <url-pattern>/wiki/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiJSPFilter</filter-name>
-       <url-pattern>*.jsp</url-pattern>
-   </filter-mapping>
+    <filter>
+        <filter-name>WikiServletFilter</filter-name>
+        <filter-class>org.apache.wiki.ui.WikiServletFilter</filter-class>
+    </filter>
+    <filter>
+        <filter-name>WikiJSPFilter</filter-name>
+        <filter-class>org.apache.wiki.ui.WikiJSPFilter</filter-class>
+    </filter>
+
+    <filter-mapping>
+        <filter-name>WikiServletFilter</filter-name>
+        <url-pattern>/attach/*</url-pattern>
+        <url-pattern>/atom/*</url-pattern>
+        <url-pattern>/RPCU/</url-pattern>
+        <url-pattern>/RPC2/</url-pattern>
+    </filter-mapping>
+    <filter-mapping>
+        <filter-name>WikiJSPFilter</filter-name>
+        <url-pattern>/wiki/*</url-pattern>
+        <url-pattern>*.jsp</url-pattern>
+    </filter-mapping>
 
    <!--
        HttpSessionListener used for managing WikiSession's.
diff --git a/jspwiki-it-tests/jspwiki-it-test-custom-absolute-urls/src/main/webapp/WEB-INF/web.xml b/jspwiki-it-tests/jspwiki-it-test-custom-absolute-urls/src/main/webapp/WEB-INF/web.xml
index c4c37d594..9937d26bb 100644
--- a/jspwiki-it-tests/jspwiki-it-test-custom-absolute-urls/src/main/webapp/WEB-INF/web.xml
+++ b/jspwiki-it-tests/jspwiki-it-test-custom-absolute-urls/src/main/webapp/WEB-INF/web.xml
@@ -55,43 +55,27 @@
       possesses the correct "assertion cookie."
    -->
 
-   <filter>
-      <filter-name>WikiServletFilter</filter-name>
-      <filter-class>org.apache.wiki.ui.WikiServletFilter</filter-class>
-   </filter>
-   <filter>
-      <filter-name>WikiJSPFilter</filter-name>
-      <filter-class>org.apache.wiki.ui.WikiJSPFilter</filter-class>
-   </filter>
-
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/attach/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/atom/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/RPCU/</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/RPC2/</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/JSON-RPC</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiJSPFilter</filter-name>
-       <url-pattern>/wiki/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiJSPFilter</filter-name>
-       <url-pattern>*.jsp</url-pattern>
-   </filter-mapping>
+    <filter>
+        <filter-name>WikiServletFilter</filter-name>
+        <filter-class>org.apache.wiki.ui.WikiServletFilter</filter-class>
+    </filter>
+    <filter>
+        <filter-name>WikiJSPFilter</filter-name>
+        <filter-class>org.apache.wiki.ui.WikiJSPFilter</filter-class>
+    </filter>
+
+    <filter-mapping>
+        <filter-name>WikiServletFilter</filter-name>
+        <url-pattern>/attach/*</url-pattern>
+        <url-pattern>/atom/*</url-pattern>
+        <url-pattern>/RPCU/</url-pattern>
+        <url-pattern>/RPC2/</url-pattern>
+    </filter-mapping>
+    <filter-mapping>
+        <filter-name>WikiJSPFilter</filter-name>
+        <url-pattern>/wiki/*</url-pattern>
+        <url-pattern>*.jsp</url-pattern>
+    </filter-mapping>
 
    <!--
        HttpSessionListener used for managing WikiSession's.
diff --git a/jspwiki-it-tests/jspwiki-it-test-custom-jdbc/src/main/webapp/WEB-INF/web.xml b/jspwiki-it-tests/jspwiki-it-test-custom-jdbc/src/main/webapp/WEB-INF/web.xml
index c4c37d594..9937d26bb 100644
--- a/jspwiki-it-tests/jspwiki-it-test-custom-jdbc/src/main/webapp/WEB-INF/web.xml
+++ b/jspwiki-it-tests/jspwiki-it-test-custom-jdbc/src/main/webapp/WEB-INF/web.xml
@@ -55,43 +55,27 @@
       possesses the correct "assertion cookie."
    -->
 
-   <filter>
-      <filter-name>WikiServletFilter</filter-name>
-      <filter-class>org.apache.wiki.ui.WikiServletFilter</filter-class>
-   </filter>
-   <filter>
-      <filter-name>WikiJSPFilter</filter-name>
-      <filter-class>org.apache.wiki.ui.WikiJSPFilter</filter-class>
-   </filter>
-
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/attach/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/atom/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/RPCU/</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/RPC2/</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/JSON-RPC</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiJSPFilter</filter-name>
-       <url-pattern>/wiki/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiJSPFilter</filter-name>
-       <url-pattern>*.jsp</url-pattern>
-   </filter-mapping>
+    <filter>
+        <filter-name>WikiServletFilter</filter-name>
+        <filter-class>org.apache.wiki.ui.WikiServletFilter</filter-class>
+    </filter>
+    <filter>
+        <filter-name>WikiJSPFilter</filter-name>
+        <filter-class>org.apache.wiki.ui.WikiJSPFilter</filter-class>
+    </filter>
+
+    <filter-mapping>
+        <filter-name>WikiServletFilter</filter-name>
+        <url-pattern>/attach/*</url-pattern>
+        <url-pattern>/atom/*</url-pattern>
+        <url-pattern>/RPCU/</url-pattern>
+        <url-pattern>/RPC2/</url-pattern>
+    </filter-mapping>
+    <filter-mapping>
+        <filter-name>WikiJSPFilter</filter-name>
+        <url-pattern>/wiki/*</url-pattern>
+        <url-pattern>*.jsp</url-pattern>
+    </filter-mapping>
 
    <!--
        HttpSessionListener used for managing WikiSession's.
diff --git a/jspwiki-it-tests/jspwiki-it-test-custom/src/main/webapp/WEB-INF/web.xml b/jspwiki-it-tests/jspwiki-it-test-custom/src/main/webapp/WEB-INF/web.xml
index c4c37d594..9937d26bb 100644
--- a/jspwiki-it-tests/jspwiki-it-test-custom/src/main/webapp/WEB-INF/web.xml
+++ b/jspwiki-it-tests/jspwiki-it-test-custom/src/main/webapp/WEB-INF/web.xml
@@ -55,43 +55,27 @@
       possesses the correct "assertion cookie."
    -->
 
-   <filter>
-      <filter-name>WikiServletFilter</filter-name>
-      <filter-class>org.apache.wiki.ui.WikiServletFilter</filter-class>
-   </filter>
-   <filter>
-      <filter-name>WikiJSPFilter</filter-name>
-      <filter-class>org.apache.wiki.ui.WikiJSPFilter</filter-class>
-   </filter>
-
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/attach/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/atom/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/RPCU/</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/RPC2/</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/JSON-RPC</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiJSPFilter</filter-name>
-       <url-pattern>/wiki/*</url-pattern>
-   </filter-mapping>
-   <filter-mapping>
-       <filter-name>WikiJSPFilter</filter-name>
-       <url-pattern>*.jsp</url-pattern>
-   </filter-mapping>
+    <filter>
+        <filter-name>WikiServletFilter</filter-name>
+        <filter-class>org.apache.wiki.ui.WikiServletFilter</filter-class>
+    </filter>
+    <filter>
+        <filter-name>WikiJSPFilter</filter-name>
+        <filter-class>org.apache.wiki.ui.WikiJSPFilter</filter-class>
+    </filter>
+
+    <filter-mapping>
+        <filter-name>WikiServletFilter</filter-name>
+        <url-pattern>/attach/*</url-pattern>
+        <url-pattern>/atom/*</url-pattern>
+        <url-pattern>/RPCU/</url-pattern>
+        <url-pattern>/RPC2/</url-pattern>
+    </filter-mapping>
+    <filter-mapping>
+        <filter-name>WikiJSPFilter</filter-name>
+        <url-pattern>/wiki/*</url-pattern>
+        <url-pattern>*.jsp</url-pattern>
+    </filter-mapping>
 
    <!--
        HttpSessionListener used for managing WikiSession's.
diff --git a/jspwiki-war/src/main/webapp/WEB-INF/web.xml b/jspwiki-war/src/main/webapp/WEB-INF/web.xml
index ed7374354..761708dc8 100644
--- a/jspwiki-war/src/main/webapp/WEB-INF/web.xml
+++ b/jspwiki-war/src/main/webapp/WEB-INF/web.xml
@@ -66,25 +66,25 @@
    -->
 
    <filter>
-      <filter-name>WikiServletFilter</filter-name>
-      <filter-class>org.apache.wiki.ui.WikiServletFilter</filter-class>
+     <filter-name>WikiServletFilter</filter-name>
+     <filter-class>org.apache.wiki.ui.WikiServletFilter</filter-class>
    </filter>
    <filter>
-      <filter-name>WikiJSPFilter</filter-name>
-      <filter-class>org.apache.wiki.ui.WikiJSPFilter</filter-class>
+     <filter-name>WikiJSPFilter</filter-name>
+     <filter-class>org.apache.wiki.ui.WikiJSPFilter</filter-class>
    </filter>
 
    <filter-mapping>
-       <filter-name>WikiServletFilter</filter-name>
-       <url-pattern>/attach/*</url-pattern>
-       <url-pattern>/atom/*</url-pattern>
-       <url-pattern>/RPCU/</url-pattern>
-       <url-pattern>/RPC2/</url-pattern>
+     <filter-name>WikiServletFilter</filter-name>
+     <url-pattern>/attach/*</url-pattern>
+     <url-pattern>/atom/*</url-pattern>
+     <url-pattern>/RPCU/</url-pattern>
+     <url-pattern>/RPC2/</url-pattern>
    </filter-mapping>
    <filter-mapping>
-       <filter-name>WikiJSPFilter</filter-name>
-       <url-pattern>/wiki/*</url-pattern>
-       <url-pattern>*.jsp</url-pattern>
+     <filter-name>WikiJSPFilter</filter-name>
+     <url-pattern>/wiki/*</url-pattern>
+     <url-pattern>*.jsp</url-pattern>
    </filter-mapping>
 
    <!--


[jspwiki] 09/25: Session gets new antiCsrfToken method

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ccaf74ad82e94296ac2305792d8845bac887a395
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:48:43 2022 +0200

    Session gets new antiCsrfToken method
---
 jspwiki-api/src/main/java/org/apache/wiki/api/core/Session.java | 6 ++++++
 jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java     | 9 +++++++++
 2 files changed, 15 insertions(+)

diff --git a/jspwiki-api/src/main/java/org/apache/wiki/api/core/Session.java b/jspwiki-api/src/main/java/org/apache/wiki/api/core/Session.java
index 8a608609a..1a8eae6d5 100644
--- a/jspwiki-api/src/main/java/org/apache/wiki/api/core/Session.java
+++ b/jspwiki-api/src/main/java/org/apache/wiki/api/core/Session.java
@@ -123,6 +123,12 @@ public interface Session extends WikiEventListener {
      */
     Principal getUserPrincipal();
 
+    /**
+     * Returns the CSRF protection Token associated with this wiki session.
+     * @return the CSRF protection Token associated with this wiki session.
+     */
+    String antiCsrfToken();
+
     /**
      *  Returns a cached Locale object for this user.  It's better to use WikiContext's corresponding getBundle() method, since that
      *  will actually react if the user changes the locale in the middle, but if that's not available (or, for some reason, you need
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
index 5be350b19..057adab59 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
@@ -49,6 +49,7 @@ import java.util.LinkedHashSet;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Set;
+import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 
 
@@ -73,6 +74,7 @@ public class WikiSession implements Session {
     /** The Engine that created this session. */
     private Engine m_engine;
 
+    private String antiCsrfToken;
     private String m_status            = ANONYMOUS;
 
     private Principal m_userPrincipal  = WikiPrincipal.GUEST;
@@ -147,6 +149,12 @@ public class WikiSession implements Session {
         return m_userPrincipal;
     }
 
+    /** {@inheritDoc} */
+    @Override
+    public String antiCsrfToken() {
+        return antiCsrfToken;
+    }
+
     /** {@inheritDoc} */
     @Override
     public Locale getLocale() {
@@ -513,6 +521,7 @@ public class WikiSession implements Session {
         final WikiSession session = new WikiSession();
         session.m_engine = engine;
         session.invalidate();
+        session.antiCsrfToken = UUID.randomUUID().toString();
 
         // Add the session as listener for GroupManager, AuthManager, UserManager events
         final GroupManager groupMgr = engine.getManager( GroupManager.class );


[jspwiki] 22/25: Update Tomcat's binaries

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 9dec27e23e19eecfc41c09055ab77cf8e96d8e95
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 23:01:50 2022 +0200

    Update Tomcat's binaries
---
 .../tomcat/woas.app/Contents/Java/bootstrap.jar    | Bin 34699 -> 34699 bytes
 .../tomcat/woas.app/Contents/Java/tomcat-juli.jar  | Bin 46897 -> 46898 bytes
 .../src/overlay/launchers/tomcat/woas.exe          | Bin 3659368 -> 3669432 bytes
 3 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/bootstrap.jar b/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/bootstrap.jar
index 05823bf36..674f7efc4 100644
Binary files a/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/bootstrap.jar and b/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/bootstrap.jar differ
diff --git a/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/tomcat-juli.jar b/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/tomcat-juli.jar
index 8a4c0e2c9..9b39f6184 100644
Binary files a/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/tomcat-juli.jar and b/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/tomcat-juli.jar differ
diff --git a/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe b/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe
index 1834e9aa4..41789bfd6 100644
Binary files a/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe and b/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe differ


[jspwiki] 06/25: bom must have packaging == pom

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 5bb7f9734ac1656b509ede3851e082f2b2f96a3e
Author: Juan Pablo Santos Rodríguez <ju...@gmail.com>
AuthorDate: Tue Jul 12 22:44:13 2022 +0200

    bom must have packaging == pom
---
 jspwiki-bom/pom.xml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/jspwiki-bom/pom.xml b/jspwiki-bom/pom.xml
index b3e9efbc8..3b85fea19 100644
--- a/jspwiki-bom/pom.xml
+++ b/jspwiki-bom/pom.xml
@@ -28,6 +28,7 @@
   <modelVersion>4.0.0</modelVersion>
   <artifactId>jspwiki-bom</artifactId>
   <name>Apache JSPWiki bill of materials</name>
+  <packaging>pom</packaging>
 
   <properties>
     <jspwiki.version>2.11.3-SNAPSHOT</jspwiki.version>