You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ja...@apache.org on 2008/09/21 15:55:19 UTC
svn commit: r697517 - in /incubator/jspwiki/trunk: ChangeLog
src/com/ecyrd/jspwiki/Release.java src/com/ecyrd/jspwiki/WikiContext.java
src/com/ecyrd/jspwiki/tags/TranslateTag.java
Author: jalkanen
Date: Sun Sep 21 06:55:18 2008
New Revision: 697517
URL: http://svn.apache.org/viewvc?rev=697517&view=rev
Log:
[JSPWIKI-379] TranslateTag now properly does a deep clone of the WikiContext, so that you no longer can get ACLs instantiated just by previewing a page.
Modified:
incubator/jspwiki/trunk/ChangeLog
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiContext.java
incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/tags/TranslateTag.java
Modified: incubator/jspwiki/trunk/ChangeLog
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/ChangeLog?rev=697517&r1=697516&r2=697517&view=diff
==============================================================================
--- incubator/jspwiki/trunk/ChangeLog (original)
+++ incubator/jspwiki/trunk/ChangeLog Sun Sep 21 06:55:18 2008
@@ -1,3 +1,11 @@
+2008-09-21 Janne Jalkanen <ja...@apache.org>
+
+ * 2.8.0-beta-7
+
+ * [JSPWIKI-379] TranslateTag now properly does a deep
+ clone of the WikiContext, so that you no longer can get
+ ACLs instantiated just by previewing a page.
+
2008-09-20 Janne Jalkanen <ja...@apache.org>
* 2.8.0-beta-6
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java?rev=697517&r1=697516&r2=697517&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/Release.java Sun Sep 21 06:55:18 2008
@@ -77,7 +77,7 @@
* <p>
* If the build identifier is empty, it is not added.
*/
- public static final String BUILD = "6";
+ public static final String BUILD = "7";
/**
* This is the generic version string you should use
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiContext.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiContext.java?rev=697517&r1=697516&r2=697517&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiContext.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/WikiContext.java Sun Sep 21 06:55:18 2008
@@ -75,7 +75,7 @@
private WikiEngine m_engine;
private String m_template = "default";
- private Map<String,Object> m_variableMap = new HashMap<String,Object>();
+ private HashMap<String,Object> m_variableMap = new HashMap<String,Object>();
/**
* Stores the HttpServletRequest. May be null, if the request did not
@@ -654,6 +654,38 @@
}
/**
+ * Creates a deep clone of the WikiContext. This is useful when you want
+ * to be sure that you don't accidentally mess with page attributes, etc.
+ *
+ * @since 2.8.0
+ * @return A deep clone of the WikiContext.
+ */
+ public WikiContext deepClone()
+ {
+ try
+ {
+ // super.clone() must always be called to make sure that inherited objects
+ // get the right type
+ WikiContext copy = (WikiContext)super.clone();
+
+ // No need to deep clone these
+ copy.m_engine = m_engine;
+ copy.m_command = m_command; // Static structure
+
+ copy.m_template = m_template;
+ copy.m_variableMap = (HashMap<String,Object>)m_variableMap.clone();
+ copy.m_request = m_request;
+ copy.m_session = m_session;
+ copy.m_page = (WikiPage)m_page.clone();
+ copy.m_realPage = (WikiPage)m_realPage.clone();
+ return copy;
+ }
+ catch( CloneNotSupportedException e ){} // Never happens
+
+ return null;
+ }
+
+ /**
* Returns the WikiSession associated with the context.
* This method is guaranteed to always return a valid WikiSession.
* If this context was constructed without an associated
Modified: incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/tags/TranslateTag.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/tags/TranslateTag.java?rev=697517&r1=697516&r2=697517&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/tags/TranslateTag.java (original)
+++ incubator/jspwiki/trunk/src/com/ecyrd/jspwiki/tags/TranslateTag.java Sun Sep 21 06:55:18 2008
@@ -26,6 +26,7 @@
import javax.servlet.jsp.tagext.BodyTagSupport;
import com.ecyrd.jspwiki.WikiContext;
+import com.ecyrd.jspwiki.WikiPage;
import org.apache.log4j.Logger;
@@ -48,6 +49,17 @@
{
WikiContext context = (WikiContext) pageContext.getAttribute( WikiTagBase.ATTR_CONTEXT,
PageContext.REQUEST_SCOPE );
+
+ //
+ // Because the TranslateTag should not affect any of the real page attributes
+ // we have to make a clone here.
+ //
+
+ context = context.deepClone();
+
+ //
+ // Get the page data.
+ //
BodyContent bc = getBodyContent();
String wikiText = bc.getString();
bc.clearBody();