You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by aj...@apache.org on 2010/02/20 18:21:50 UTC
svn commit: r912156 - in /incubator/jspwiki/trunk: etc/
src/java/org/apache/wiki/ src/java/org/apache/wiki/diff/
src/java/org/apache/wiki/providers/ src/java/org/apache/wiki/url/
tests/etc/ tests/java/org/apache/wiki/ tests/java/org/apache/wiki/action/
Author: ajaquith
Date: Sat Feb 20 17:21:50 2010
New Revision: 912156
URL: http://svn.apache.org/viewvc?rev=912156&view=rev
Log:
[JSPWIKI-180] Removed ISO-8859-1 support from ExternalDiffProvider, WikiEngine, AbstractFileProvider, TestEngine and a few tests.
Modified:
incubator/jspwiki/trunk/etc/jspwiki.properties
incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/diff/ExternalDiffProvider.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/providers/AbstractFileProvider.java
incubator/jspwiki/trunk/src/java/org/apache/wiki/url/URLConstructor.java
incubator/jspwiki/trunk/tests/etc/jspwiki.properties
incubator/jspwiki/trunk/tests/java/org/apache/wiki/TestEngine.java
incubator/jspwiki/trunk/tests/java/org/apache/wiki/WikiEngineTest.java
incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/ViewActionBeanTest.java
Modified: incubator/jspwiki/trunk/etc/jspwiki.properties
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/etc/jspwiki.properties?rev=912156&r1=912155&r2=912156&view=diff
==============================================================================
--- incubator/jspwiki/trunk/etc/jspwiki.properties (original)
+++ incubator/jspwiki/trunk/etc/jspwiki.properties Sat Feb 20 17:21:50 2010
@@ -145,20 +145,6 @@
#jspwiki.referenceStyle=relative
#
-# Determines which character encoding JSPWiki should use. If you want
-# to support all languages in your Wiki, you probably want to enable
-# this. From JSPWiki 2.2, it is strongly suggested that you use UTF-8.
-#
-# Note that you can't switch these in the mean time, since the way the
-# files are encoded on disk is incompatible between ISO-Latin1 and UTF-8.
-# Don't try. You'll get all sorts of interesting problems, if you do.
-#
-# Possible values are 'ISO-8859-1' (default, if none has been specified)
-# and 'UTF-8'.
-
-jspwiki.encoding = UTF-8
-
-#
# Determines whether raw HTML is allowed as Wiki input.
#
# THIS IS A DANGEROUS OPTION!
@@ -799,3 +785,7 @@
#jspwiki.approver.workflow.createUserProfile=Admin
### End of configuration file.
+
+# Properties used for testing
+admin.passwordHash={SSHA}UOYUCLnNMHsMLksaYUpBxLsgP9er7aMkGPzDCw==
+jspwiki.baseURL=http://localhost:8080/JSPWiki/
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java?rev=912156&r1=912155&r2=912156&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/WikiEngine.java Sat Feb 20 17:21:50 2010
@@ -82,7 +82,6 @@
import org.apache.wiki.ui.stripes.WikiActionBeanContext;
import org.apache.wiki.ui.stripes.WikiInterceptor;
import org.apache.wiki.url.StripesURLConstructor;
-import org.apache.wiki.url.URLConstructor;
import org.apache.wiki.util.*;
import org.apache.wiki.workflow.*;
@@ -124,9 +123,6 @@
/** If true, then the user name will be stored with the page data.*/
public static final String PROP_STOREUSERNAME= "jspwiki.storeUserName";
- /** Define the used encoding. Currently supported are ISO-8859-1 and UTF-8 */
- public static final String PROP_ENCODING = "jspwiki.encoding";
-
/** The name for the base URL to use in all references. */
public static final String PROP_BASEURL = "jspwiki.baseURL";
@@ -176,9 +172,6 @@
/** Should the user info be saved with the page data as well? */
private boolean m_saveUserInfo = true;
- /** If true, uses UTF8 encoding for all data */
- private boolean m_useUTF8 = true;
-
/** Stores the base URL. */
private String m_baseURL;
@@ -519,7 +512,6 @@
PROP_STOREUSERNAME,
m_saveUserInfo );
- m_useUTF8 = "UTF-8".equals( TextUtil.getStringProperty( props, PROP_ENCODING, "ISO-8859-1" ) );
m_baseURL = TextUtil.getStringProperty( props, PROP_BASEURL, "" );
if( !m_baseURL.endsWith( "/" ) )
{
@@ -547,11 +539,13 @@
// of a better way to do the startup-sequence.
try
{
- // Initialize the JMX timer MBean
- WikiBackgroundThread.registerTimer( this );
-
// Initialize the WikiContextFactory -- this MUST be done after setting the baseURL
+ m_urlConstructor = new StripesURLConstructor();
+ m_urlConstructor.initialize( this, props );
m_contextFactory = new WikiContextFactory( this, props );
+
+ // Initialize the JMX timer MBean
+ WikiBackgroundThread.registerTimer( this );
/**
* We treat the specialPageResolver in a slightly different way
@@ -561,11 +555,6 @@
m_nameResolvers.add( m_specialPageResolver );
m_nameResolvers.add( new EnglishPluralsPageNameResolver( this ) );
- Class<?> urlclass = ClassUtil.findClass( "org.apache.wiki.url",
- TextUtil.getStringProperty( props, PROP_URLCONSTRUCTOR, "DefaultURLConstructor" ) );
- m_urlConstructor = new StripesURLConstructor();
- m_urlConstructor.initialize( this, props );
-
m_contentManager = (ContentManager)ClassUtil.getMappedObject(ContentManager.class.getName(), this );
m_pageManager = (PageManager)ClassUtil.getMappedObject(PageManager.class.getName(), this, props );
m_pluginManager = (PluginManager)ClassUtil.getMappedObject(PluginManager.class.getName(), this, props );
@@ -635,11 +624,6 @@
log.error( "Failed to start managers, stacktrace follows: ", e );
throw new WikiException( "Failed to start managers: "+e.getMessage(), e );
}
- catch (ClassNotFoundException e)
- {
- log.error( "JSPWiki could not start, URLConstructor was not found, stacktrace follows: ", e );
- throw new WikiException( e.getMessage(), e );
- }
catch( Exception e )
{
// Final catch-all for everything
@@ -1271,7 +1255,7 @@
/**
* Turns a WikiName into something that can be
- * called through using an URL.
+ * called through using an URL, encoded in UTF-8.
*
* @since 1.4.1
* @param pagename A name. Can be actually any string.
@@ -1282,19 +1266,18 @@
{
try
{
- return URLEncoder.encode( pagename, m_useUTF8 ? "UTF-8" : "ISO-8859-1" );
+ return URLEncoder.encode( pagename, "UTF-8" );
}
catch( UnsupportedEncodingException e )
{
- throw new InternalWikiException("ISO-8859-1 not a supported encoding!?! Your platform is borked.");
+ throw new InternalWikiException("UTF-8 not a supported encoding!?! Your platform is b0rked.");
}
}
/**
- * Decodes a URL-encoded request back to regular life. This properly heeds
- * the encoding as defined in the settings file.
+ * Decodes a UTF-8 URL-encoded request back to regular life.
*
- * @param pagerequest The URL-encoded string to decode
+ * @param pagerequest The UTF-8 URLencoded string to decode
* @return A decoded string.
* @see #encodeName(String)
*/
@@ -1302,11 +1285,11 @@
{
try
{
- return URLDecoder.decode( pagerequest, m_useUTF8 ? "UTF-8" : "ISO-8859-1" );
+ return URLDecoder.decode( pagerequest, "UTF-8" );
}
catch( UnsupportedEncodingException e )
{
- throw new InternalWikiException("ISO-8859-1 not a supported encoding!?! Your platform is borked.");
+ throw new InternalWikiException("UTF-8 not a supported encoding!?! Your platform is b0rked.");
}
}
@@ -1315,14 +1298,11 @@
* supposed to be using right now.
*
* @since 1.5.3
- * @return The content encoding (either UTF-8 or ISO-8859-1).
+ * @return Always returns {@code UTF-8}
*/
public String getContentEncoding()
{
- if( m_useUTF8 )
- return "UTF-8";
-
- return "ISO-8859-1";
+ return "UTF-8";
}
/**
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/diff/ExternalDiffProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/diff/ExternalDiffProvider.java?rev=912156&r1=912155&r2=912156&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/diff/ExternalDiffProvider.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/diff/ExternalDiffProvider.java Sat Feb 20 17:21:50 2010
@@ -50,7 +50,6 @@
public static final String PROP_DIFFCOMMAND = "jspwiki.diffCommand";
private String m_diffCommand = null;
- private String m_encoding;
private static final char DIFF_ADDED_SYMBOL = '+';
private static final char DIFF_REMOVED_SYMBOL = '-';
@@ -95,8 +94,6 @@
{
throw new NoRequiredPropertyException( "ExternalDiffProvider missing required property", PROP_DIFFCOMMAND );
}
-
- m_encoding = engine.getContentEncoding();
}
@@ -112,8 +109,8 @@
try
{
- f1 = FileUtil.newTmpFile(p1, m_encoding);
- f2 = FileUtil.newTmpFile(p2, m_encoding);
+ f1 = FileUtil.newTmpFile(p1, "UTF-8");
+ f2 = FileUtil.newTmpFile(p2, "UTF-8");
String cmd = TextUtil.replaceString(m_diffCommand, "%s1", f1.getPath());
cmd = TextUtil.replaceString(cmd, "%s2", f2.getPath());
@@ -121,7 +118,7 @@
String output = FileUtil.runSimpleCommand(cmd, f1.getParent());
// FIXME: Should this rely on the system default encoding?
- String rawWikiDiff = new String(output.getBytes("ISO-8859-1"), m_encoding);
+ String rawWikiDiff = new String(output.getBytes("UTF-8"), "UTF-8");
String htmlWikiDiff = TextUtil.replaceEntities( rawWikiDiff );
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/providers/AbstractFileProvider.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/providers/AbstractFileProvider.java?rev=912156&r1=912155&r2=912156&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/providers/AbstractFileProvider.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/providers/AbstractFileProvider.java Sat Feb 20 17:21:50 2010
@@ -49,6 +49,6 @@
public static final String FILE_EXT = ".txt";
/** The default encoding. */
- public static final String DEFAULT_ENCODING = "ISO-8859-1";
+ public static final String DEFAULT_ENCODING = "UTF-8";
}
Modified: incubator/jspwiki/trunk/src/java/org/apache/wiki/url/URLConstructor.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/java/org/apache/wiki/url/URLConstructor.java?rev=912156&r1=912155&r2=912156&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/java/org/apache/wiki/url/URLConstructor.java (original)
+++ incubator/jspwiki/trunk/src/java/org/apache/wiki/url/URLConstructor.java Sat Feb 20 17:21:50 2010
@@ -76,7 +76,7 @@
* @param context In which request context the request was made (this should
* help in parsing)
* @param request The HTTP request that was used when coming here
- * @param encoding The encoding with which the request was made (UTF-8 or ISO-8859-1).
+ * @param encoding The encoding with which the request was made (e.g., UTF-8).
* @return This method must return the name of the resource.
* @throws IOException If parsing failes
*/
Modified: incubator/jspwiki/trunk/tests/etc/jspwiki.properties
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/etc/jspwiki.properties?rev=912156&r1=912155&r2=912156&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/etc/jspwiki.properties (original)
+++ incubator/jspwiki/trunk/tests/etc/jspwiki.properties Sat Feb 20 17:21:50 2010
@@ -34,8 +34,6 @@
jspwiki.translatorReader.matchEnglishPlurals = true
jspwiki.translatorReader.useOutlinkImage = false
-jspwiki.encoding = ISO-8859-1
-
jspwiki.filterConfig = build/tests/classpath/WEB-INF/filters.xml
jspwiki.baseURL = http://localhost/
Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/TestEngine.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/TestEngine.java?rev=912156&r1=912155&r2=912156&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/TestEngine.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/TestEngine.java Sat Feb 20 17:21:50 2010
@@ -53,7 +53,6 @@
import org.apache.wiki.content.inspect.Challenge;
import org.apache.wiki.log.Logger;
import org.apache.wiki.log.LoggerFactory;
-import org.apache.wiki.providers.AbstractFileProvider;
import org.apache.wiki.providers.ProviderException;
import org.apache.wiki.tags.SpamProtectTag;
import org.apache.wiki.ui.stripes.ShortUrlFilter;
@@ -287,11 +286,7 @@
protected static String mangleName( String pagename )
throws IOException
{
- Properties properties = new Properties();
- String m_encoding = properties.getProperty( WikiEngine.PROP_ENCODING,
- AbstractFileProvider.DEFAULT_ENCODING );
-
- pagename = TextUtil.urlEncode( pagename, m_encoding );
+ pagename = TextUtil.urlEncode( pagename, "UTF-8" );
pagename = TextUtil.replaceString( pagename, "/", "%2F" );
return pagename;
}
Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/WikiEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/WikiEngineTest.java?rev=912156&r1=912155&r2=912156&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/WikiEngineTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/WikiEngineTest.java Sat Feb 20 17:21:50 2010
@@ -223,20 +223,10 @@
data );
}
- public void testEncodeNameLatin1()
- {
- String name = "abc\u00e5\u00e4\u00f6";
-
- assertEquals( "abc%E5%E4%F6",
- m_engine.encodeName(name) );
- }
-
public void testEncodeNameUTF8() throws Exception
{
String name = "\u0041\u2262\u0391\u002E";
- props.setProperty( WikiEngine.PROP_ENCODING, "UTF-8" );
-
m_engine.shutdown();
m_engine = new TestEngine( props );
Modified: incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/ViewActionBeanTest.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/ViewActionBeanTest.java?rev=912156&r1=912155&r2=912156&view=diff
==============================================================================
--- incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/ViewActionBeanTest.java (original)
+++ incubator/jspwiki/trunk/tests/java/org/apache/wiki/action/ViewActionBeanTest.java Sat Feb 20 17:21:50 2010
@@ -133,6 +133,29 @@
// ...and the destination should be the Wiki template JSP
assertEquals( "/templates/default/Wiki.jsp?tab=view", trip.getDestination() );
+
+ m_engine.deletePage( pageName );
+ }
+
+ public void testViewScandic() throws Exception {
+ String pageName = "\u00c4itiSy\u00f6\u00d6ljy\u00e4";
+
+ // Save test page
+ m_engine.saveText( pageName, "This is a test." );
+ WikiPage page = m_engine.getPage( pageName );
+ assertNotNull("Did not save page " + pageName + "!", page);
+
+ // Set the 'page' request parameter to the encoded page name
+ MockRoundtrip trip = m_engine.guestTrip( "/Wiki.jsp" );
+ trip.setParameter( "page", "%C3%84itiSy%C3%B6%C3%96ljy%C3%A4" );
+ trip.execute( "view" );
+
+ // ...we should automatically see the page name decoded properly
+ ViewActionBean bean = trip.getActionBean( ViewActionBean.class );
+ assertEquals( pageName, bean.getPage().getName() );
+ assertEquals( page, bean.getPage() );
+
+ m_engine.deletePage( pageName );
}
public void testViewVersion() throws Exception {