From 50b89b9fe8c3901b132fef99f521c8b6e0817cd1 Mon Sep 17 00:00:00 2001 From: Alex O'Ree Date: Sun, 23 Aug 2026 12:17:12 -0400 Subject: [PATCH] JSPWIKI-1292 see jira for details --- .../wiki/parser/JSPWikiMarkupParser.java | 4 +-- .../org/apache/wiki/parser/PluginContent.java | 7 +++-- .../render/WysiwygEditingRendererTest.java | 26 +++++++++++++++++++ .../webapp/templates/210/editors/CKeditor.jsp | 2 +- .../webapp/templates/210/editors/TinyMCE.jsp | 2 +- .../templates/default/editors/CKeditor.jsp | 2 +- .../templates/default/editors/TinyMCE.jsp | 2 +- .../templates/default/editors/wysiwyg.jsp | 2 +- 8 files changed, 38 insertions(+), 9 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 8f901f64a3..4c600786e2 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 @@ -787,7 +787,7 @@ private Element handleImageLink( final String reallink, final String link, final private Element handleAccessRule( String ruleLine ) { if( m_wysiwygEditorMode ) { - m_currentElement.addContent( "[" + ruleLine + "]" ); + m_currentElement.addContent( "[" + TextUtil.escapeHTMLEntities( ruleLine ) + "]" ); } if( !m_parseAccessRules ) { return m_currentElement; @@ -821,7 +821,7 @@ private Element handleAccessRule( String ruleLine ) { */ private Element handleMetadata( final String link ) { if( m_wysiwygEditorMode ) { - m_currentElement.addContent( "[" + link + "]" ); + m_currentElement.addContent( "[" + TextUtil.escapeHTMLEntities( link ) + "]" ); } try { diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java index ae121de88e..63f718cf15 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/PluginContent.java @@ -32,6 +32,7 @@ Licensed to the Apache Software Foundation (ASF) under one import org.apache.wiki.api.plugin.PluginElement; import org.apache.wiki.plugin.PluginManager; import org.apache.wiki.preferences.Preferences; +import org.apache.wiki.util.TextUtil; import org.apache.wiki.variables.VariableManager; import org.jdom2.Text; @@ -147,8 +148,10 @@ public String invoke( final Context context ) { if( wysiwygEditorMode && !m_pluginName.matches( EMITTABLE_PLUGINS ) ) { result = PLUGIN_START + m_pluginName + SPACE; - // convert newlines to
in case the plugin has a body. - final String cmdLine = m_params.get( CMDLINE ).replaceAll( LINEBREAK, ELEMENT_BR ); + // escape the raw command line first: this text node is emitted with output escaping + // disabled, so unescaped markup would reach the wysiwyg editor (and its "; + + String html = render( "[{SomePlugin " + payload + "}]", true ); + Assertions.assertFalse( html.contains( payload ), html ); + + html = render( "[{SET foo='" + payload + "'}]", true ); + Assertions.assertFalse( html.contains( payload ), html ); + + html = render( "[{ALLOW edit " + payload + "}]", true ); + Assertions.assertFalse( html.contains( payload ), html ); + } + } 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 ea787af374..142aee0bec 100644 --- a/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp +++ b/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp @@ -167,7 +167,7 @@ - +