Author: rich
Date: Fri Apr 8 14:07:15 2005
New Revision: 160608
URL: http://svn.apache.org/viewcvs?view=rev&rev=160608
Log:
This is a contribution from Carlin Rogers to address
http://issues.apache.org/jira/browse/BEEHIVE-488 : encode href attributes for
NetUI tags
tests: beehive drt (WinXP)
BB: self (linux)
Added:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/Controller.jpf
(with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/beginEUCJP.jsp
(with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/beginUTF8.jsp
(with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/escaping.jsp
(with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/eucjp.jsp
(with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/index.jsp
(with props)
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/utf8.jsp
(with props)
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/TagsAndURLEscapedChars.xml
(with props)
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/TagsAndUTF8URLEncoding.xml
(with props)
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/OldURLRewriterWrapper.java
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteURL.java
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/internal/PageFlowTagUtils.java
incubator/beehive/trunk/netui/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java
incubator/beehive/trunk/netui/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/RequestData.java
incubator/beehive/trunk/netui/src/tomcat-server/5x/build.xml
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/FreezableMutableURI.java
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/FreezableMutableURITest.java
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/MutableURITest.java
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java?view=diff&r1=160607&r2=160608
==============================================================================
---
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
(original)
+++
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/PageFlowUtils.java
Fri Apr 8 14:07:15 2005
@@ -1216,7 +1216,7 @@
{
String qualifiedAction = InternalUtils.qualifyAction( servletContext,
actionName );
String actionUrl = InternalUtils.createActionURL( request,
qualifiedAction );
- FreezableMutableURI uri = new FreezableMutableURI( actionUrl );
+ FreezableMutableURI uri = new FreezableMutableURI( actionUrl, true );
uri.setEncoding( response.getCharacterEncoding() );
return uri;
@@ -1244,7 +1244,7 @@
{
String qualifiedAction = InternalUtils.qualifyAction( servletContext,
actionName );
String actionUrl = InternalUtils.createActionURL( request,
qualifiedAction );
- FreezableMutableURI uri = new FreezableMutableURI( actionUrl );
+ FreezableMutableURI uri = new FreezableMutableURI( actionUrl, true );
uri.setEncoding( response.getCharacterEncoding() );
if ( params != null )
@@ -1254,7 +1254,7 @@
if ( fragment != null )
{
- uri.setFragment( fragment );
+ uri.setFragment( uri.encode( fragment ) );
}
boolean needsToBeSecure = needsToBeSecure( servletContext, request,
actionUrl, true );
@@ -1319,7 +1319,7 @@
String fragment, boolean
forXML, URLType urlType )
throws URISyntaxException
{
- FreezableMutableURI uri = new FreezableMutableURI( path );
+ FreezableMutableURI uri = new FreezableMutableURI( path, false );
uri.setEncoding( response.getCharacterEncoding() );
if ( params != null )
@@ -1329,7 +1329,7 @@
if ( fragment != null )
{
- uri.setFragment( fragment );
+ uri.setFragment( uri.encode( fragment ) );
}
if ( uri.isAbsolute() )
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/OldURLRewriterWrapper.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/OldURLRewriterWrapper.java?view=diff&r1=160607&r2=160608
==============================================================================
---
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/OldURLRewriterWrapper.java
(original)
+++
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/OldURLRewriterWrapper.java
Fri Apr 8 14:07:15 2005
@@ -111,7 +111,7 @@
uri.getURIString(),
tempType );
try
{
- MutableURI newURI = new MutableURI( rewrittenURL );
+ MutableURI newURI = new MutableURI( rewrittenURL, true );
uri.setScheme( newURI.getScheme() );
uri.setUserInfo( newURI.getUserInfo() );
uri.setHost( newURI.getHost() );
Modified:
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java?view=diff&r1=160607&r2=160608
==============================================================================
---
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java
(original)
+++
incubator/beehive/trunk/netui/src/pageflow/org/apache/beehive/netui/pageflow/util/URLRewriterService.java
Fri Apr 8 14:07:15 2005
@@ -111,7 +111,11 @@
String rewrittenURL = null;
FreezableMutableURI mutableUri = null;
try {
- mutableUri = new FreezableMutableURI( url );
+ //
+ // ToDo: Should check for a config option in netui-config to allow
users to encode urls themselves and
+ // pass that to the FreezableMutableURI constructor.
+ //
+ mutableUri = new FreezableMutableURI( url, false );
mutableUri.setEncoding( response.getCharacterEncoding() );
org.apache.beehive.netui.core.urls.URLRewriter.URLType tempType =
org.apache.beehive.netui.core.urls.URLRewriter.URLType.RESOURCE;
Modified:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java?view=diff&r1=160607&r2=160608
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java
(original)
+++
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/Form.java
Fri Apr 8 14:07:15 2005
@@ -890,7 +890,7 @@
{
String qualifiedAction = InternalUtils.qualifyAction(servletContext,
_state.action);
String actionUrl = InternalUtils.createActionURL(request,
qualifiedAction);
- MutableURI uri = new MutableURI(actionUrl);
+ MutableURI uri = new MutableURI(actionUrl, true);
uri.setFragment(_location);
uri.setEncoding(response.getCharacterEncoding());
Modified:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteURL.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteURL.java?view=diff&r1=160607&r2=160608
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteURL.java
(original)
+++
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/html/RewriteURL.java
Fri Apr 8 14:07:15 2005
@@ -103,23 +103,32 @@
}
/**
- * Add the URL parameter to the Parameter's parent.
+ * Render the beginning of the rewriteURL tag.
* @throws JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException
{
+ // Evaluate the body of this tag
+ return EVAL_BODY_BUFFERED;
+ }
+
+ /**
+ * Render the end of the rewriteURL tag.
+ * @throws JspException if a JSP exception has occurred
+ */
+ public int doEndTag() throws JspException
+ {
HttpServletRequest request = (HttpServletRequest)
pageContext.getRequest();
HttpServletResponse response = (HttpServletResponse)
pageContext.getResponse();
ServletContext context = pageContext.getServletContext();
- FreezableMutableURI uri = null;
try {
boolean needsToBeSecure = false;
- uri = new FreezableMutableURI(url);
+ FreezableMutableURI uri = new FreezableMutableURI(url, false);
+ uri.setEncoding(response.getCharacterEncoding());
if (_params != null) {
uri.addParameters(_params, false );
}
- uri.setEncoding(response.getCharacterEncoding());
if (!uri.isAbsolute() && PageFlowUtils.needsToBeSecure(context,
request, url, true)) {
needsToBeSecure = true;
}
@@ -135,10 +144,11 @@
String s = Bundle.getString("Tags_RewriteURL_URLException",
new Object[]{url, e.getMessage()});
registerTagError(s, e);
+ reportErrors();
}
localRelease();
- return SKIP_BODY;
+ return EVAL_PAGE;
}
/**
Modified:
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/internal/PageFlowTagUtils.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/internal/PageFlowTagUtils.java?view=diff&r1=160607&r2=160608
==============================================================================
---
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/internal/PageFlowTagUtils.java
(original)
+++
incubator/beehive/trunk/netui/src/tags-html/org/apache/beehive/netui/tags/internal/PageFlowTagUtils.java
Fri Apr 8 14:07:15 2005
@@ -76,7 +76,7 @@
* @param location the location (anchor or fragment) for this url.
* @return a url that has been run through the URL rewriter service.
* @see PageFlowUtils#getRewrittenHrefURI(javax.servlet.ServletContext,
javax.servlet.http.HttpServletRequest,
- * javax.servlet.http.HttpServletResponse, String,
java.util.Map, String, boolean)
+ * javax.servlet.http.HttpServletResponse, String,
java.util.Map, String, boolean)
*/
public static String rewriteHrefURL(PageContext pageContext, String url,
Map params, String location)
throws URISyntaxException
@@ -98,7 +98,7 @@
* @param location the location (anchor or fragment) for this url.
* @return a url that has been run through the URL rewriter service.
* @see
PageFlowUtils#getRewrittenResourceURI(javax.servlet.ServletContext,
javax.servlet.http.HttpServletRequest,
- * javax.servlet.http.HttpServletResponse, String,
java.util.Map, String, boolean)
+ * javax.servlet.http.HttpServletResponse, String,
java.util.Map, String, boolean)
*/
public static String rewriteResourceURL(PageContext pageContext, String
url, Map params, String location)
throws URISyntaxException
Modified:
incubator/beehive/trunk/netui/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java?view=diff&r1=160607&r2=160608
==============================================================================
---
incubator/beehive/trunk/netui/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java
(original)
+++
incubator/beehive/trunk/netui/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/server/ResponseWrapper.java
Fri Apr 8 14:07:15 2005
@@ -26,6 +26,8 @@
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
+import java.io.BufferedWriter;
+import java.io.OutputStreamWriter;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
@@ -48,12 +50,14 @@
output = new ByteArrayOutputStream( 2048 );
}
- public PrintWriter getWriter() {
+ public PrintWriter getWriter() throws IOException {
if ( log.isDebugEnabled() ) {
log.debug( "getWriter()" );
}
if ( writer == null ) {
- writer = new PrintWriter( output );
+ String encoding = getCharacterEncoding();
+ writer = new PrintWriter( new BufferedWriter(
+ new OutputStreamWriter( getOutputStream(), encoding ) ) );
}
return writer;
}
@@ -142,7 +146,8 @@
}
output.flush();
output.close();
- outputString = output.toString();
+ String encoding = getCharacterEncoding();
+ outputString = output.toString( encoding );
}
return outputString;
}
Modified:
incubator/beehive/trunk/netui/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/RequestData.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/RequestData.java?view=diff&r1=160607&r2=160608
==============================================================================
---
incubator/beehive/trunk/netui/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/RequestData.java
(original)
+++
incubator/beehive/trunk/netui/src/testRecorder/org/apache/beehive/netui/tools/testrecorder/shared/RequestData.java
Fri Apr 8 14:07:15 2005
@@ -18,6 +18,7 @@
package org.apache.beehive.netui.tools.testrecorder.shared;
+import java.io.UnsupportedEncodingException;
import java.util.Map;
import java.util.Enumeration;
import java.util.List;
@@ -225,8 +226,23 @@
for ( int i = 0; i < list.size(); i++ ) {
String[] vals = (String[]) map.get( list.get( i ) );
for ( int j = 0; j < vals.length; j++ ) {
- pairs.add( new NVPair( (String) list.get( i ),
- vals[j] ) );
+ try {
+ byte[] bytes = vals[j].getBytes( "ISO-8859-1" );
+
+ //
+ // todo: We should try to use a field defined in the
+ // test admin page, when recording a new test, that
+ // provides the expected character set encoding to use
+ // for the bytes of the values in the query parameters.
+ // The character set encoding used in the test would be
+ // stored in the recorded XML to be used during playback.
+ //
+ String value = new String( bytes, "UTF-8" );
+
+ pairs.add( new NVPair( (String) list.get( i ), value ) );
+ } catch ( UnsupportedEncodingException uee ) {
+ // Should never hit this
+ }
}
}
return (NVPair[]) pairs.toArray( (Object[]) new NVPair[pairs.size()] );
Modified: incubator/beehive/trunk/netui/src/tomcat-server/5x/build.xml
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/tomcat-server/5x/build.xml?view=diff&r1=160607&r2=160608
==============================================================================
--- incubator/beehive/trunk/netui/src/tomcat-server/5x/build.xml (original)
+++ incubator/beehive/trunk/netui/src/tomcat-server/5x/build.xml Fri Apr 8
14:07:15 2005
@@ -15,7 +15,7 @@
</path>
<target name="build">
- <echo>dompile module: ${module.name}</echo>
+ <echo>compile module: ${module.name}</echo>
<property name="classpath" refid="module.classpath"/>
<echo>module classpath: ${classpath}</echo>
<echo>debug: ${compile.debug}</echo>
Modified:
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/FreezableMutableURI.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/FreezableMutableURI.java?view=diff&r1=160607&r2=160608
==============================================================================
---
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/FreezableMutableURI.java
(original)
+++
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/FreezableMutableURI.java
Fri Apr 8 14:07:15 2005
@@ -43,11 +43,12 @@
* Constructs a <code>FreezableMutableURI</code>.
*
* @param uriString the string to be parsed into a URI
- * @see java.net.URI#URI(String)
+ * @param encoded Flag indicating whether the string is
+ * already encoded.
*/
- public FreezableMutableURI( String uriString ) throws URISyntaxException
+ public FreezableMutableURI( String uriString, boolean encoded ) throws
URISyntaxException
{
- super( uriString );
+ super( uriString, encoded );
}
/**
@@ -127,13 +128,14 @@
* <p> This method can also be used to clear the
<code>FreezableMutableURI</code>.
*
* @param uriString the string to be parsed into a URI
- * @see java.net.URI#URI(String)
+ * @param encoded Flag indicating whether the string is
+ * already encoded.
*/
@Override
- public void setURI( String uriString ) throws URISyntaxException
+ public void setURI( String uriString, boolean encoded ) throws
URISyntaxException
{
testFrozen();
- super.setURI( uriString );
+ super.setURI( uriString, encoded );
}
/**
Modified:
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java?view=diff&r1=160607&r2=160608
==============================================================================
---
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java
(original)
+++
incubator/beehive/trunk/netui/src/util/org/apache/beehive/netui/core/urls/MutableURI.java
Fri Apr 8 14:07:15 2005
@@ -34,10 +34,10 @@
/**
* Mutable class for creating URIs.
*
- * <p> There is no checking that an instance of this class produces a legal
+ * <p> There is little checking that an instance of this class produces a legal
* URI reference as defined by <a href="http://www.ietf.org/rfc/rfc2396.txt">
* <i>RFC 2396: Uniform Resource Identifiers (URI): Generic
Syntax</i></a>.
- * The only minimal checking for syntax is on constructors that take a String
+ * The minimal checking for syntax is on constructors that take a String
* representation or the URI, a [EMAIL PROTECTED] URI}, or a [EMAIL PROTECTED]
URL}.
* To avoid the cost of continually checking the syntax, it is up to the
* user to ensure that the components are set correctly. </p>
@@ -50,11 +50,12 @@
* and [EMAIL PROTECTED] #addParameters( Map newParams, boolean encoded )}
* </p>
*
- * <p> There is static convenience method in this class so callers can
- * easily encode unencoded components before setting in this URI. </p>
+ * <p> There is a static convenience method in this class so callers can
+ * easily encode unencoded components before setting it in this object. </p>
*
* TODO... We need to implement some conditions for opaque URIs like mailto,
etc.
- * to determine what to do about values of path when (path == null) => opaque
and URI.getPath() would return "" for non-opaue URIs.
+ * to determine what to do about values of path when (path == null) => opaque
and
+ * URI.getPath() would return "" for non-opaue URIs.
*/
public class MutableURI
{
@@ -81,7 +82,7 @@
private String _host;
/** Port */
- private int _port;
+ private int _port = UNDEFINED_PORT;
/** Path */
private String _path;
@@ -112,9 +113,10 @@
* Constructs a <code>MutableURI</code>.
*
* @param uriString the string to be parsed into a URI
- * @see java.net.URI#URI(String)
+ * @param encoded Flag indicating whether the string is
+ * already encoded.
*/
- public MutableURI( String uriString ) throws URISyntaxException
+ public MutableURI( String uriString, boolean encoded ) throws
URISyntaxException
{
assert uriString != null : "The uri cannot be null.";
@@ -123,19 +125,25 @@
throw new IllegalArgumentException( "The URI cannot be null." );
}
- // Parse this string into its components using URI
- URI uri = new URI( uriString );
- setScheme( uri.getScheme() );
- setUserInfo( uri.getRawUserInfo() );
- setHost( uri.getHost() );
- setPort( uri.getPort() );
- setPath( uri.getRawPath() );
- setQuery( uri.getRawQuery() );
- setFragment( uri.getRawFragment() );
+ URI uri = null;
+
+ if ( encoded )
+ {
+ // Get (parse) the components using java.net.URI
+ uri = new URI( uriString );
+ }
+ else
+ {
+ // Parse, then encode this string into its components using URI
+ uri = encodeURI( uriString );
+ }
+
+ setURI( uri );
}
/**
- * Constructs a <code>MutableURI</code>.
+ * Constructs a <code>MutableURI</code>. Assumes the individual components
+ * are already encoded and escaped.
*
* @param scheme the name of the protocol to use
* @param userInfo the username and password
@@ -171,13 +179,7 @@
throw new IllegalArgumentException( "The URI cannot be null." );
}
- setScheme( uri.getScheme() );
- setUserInfo( uri.getRawUserInfo() );
- setHost( uri.getHost() );
- setPort( uri.getPort() );
- setPath( uri.getRawPath() );
- setQuery( uri.getRawQuery() );
- setFragment( uri.getRawFragment() );
+ setURI( uri );
}
/**
@@ -206,24 +208,19 @@
}
URI uri = url.toURI();
- setScheme( uri.getScheme() );
- setUserInfo( uri.getRawUserInfo() );
- setHost( uri.getHost() );
- setPort( uri.getPort() );
- setPath( uri.getRawPath() );
- setQuery( uri.getRawQuery() );
- setFragment( uri.getRawFragment() );
+ setURI( uri );
}
/**
- * Reset the value of the <code>MutableURI</code>.
+ * Set the value of the <code>MutableURI</code>.
*
* <p> This method can also be used to clear the <code>MutableURI</code>.
</p>
*
* @param uriString the string to be parsed into a URI
- * @see java.net.URI#URI(String)
+ * @param encoded Flag indicating whether the string is
+ * already encoded.
*/
- public void setURI( String uriString ) throws URISyntaxException
+ public void setURI( String uriString, boolean encoded ) throws
URISyntaxException
{
if ( uriString == null || uriString.trim().length() == 0 )
{
@@ -237,19 +234,42 @@
}
else
{
- // Parse this string into its components using URI
- URI uri = new URI( uriString );
- setScheme( uri.getScheme() );
- setUserInfo( uri.getRawUserInfo() );
- setHost( uri.getHost() );
- setPort( uri.getPort() );
- setPath( uri.getRawPath() );
- setQuery( uri.getRawQuery() );
- setFragment( uri.getRawFragment() );
+ URI uri = null;
+
+ if ( encoded )
+ {
+ // Get (parse) the components using java.net.URI
+ uri = new URI( uriString );
+ }
+ else
+ {
+ // Parse, then encode this string into its components using URI
+ uri = encodeURI( uriString );
+ }
+
+ setURI( uri );
}
}
/**
+ * Set the value of the <code>MutableURI</code>.
+ *
+ * <p> This method can also be used to clear the <code>MutableURI</code>.
</p>
+ *
+ * @param uri the URI
+ */
+ public void setURI( URI uri )
+ {
+ setScheme( uri.getScheme() );
+ setUserInfo( uri.getRawUserInfo() );
+ setHost( uri.getHost() );
+ setPort( uri.getPort() );
+ setPath( uri.getRawPath() );
+ setQuery( uri.getRawQuery() );
+ setFragment( uri.getRawFragment() );
+ }
+
+ /**
* Set the encoding used when adding unencoded parameters.
*
* @param encoding
@@ -260,7 +280,7 @@
}
/**
- * Returns the encoding that is used when adding unencoded parameters.
+ * Returns the character encoding that is used when adding unencoded
parameters.
*
* @return encoding
*/
@@ -295,7 +315,7 @@
}
/**
- * Sets the userInfo.
+ * Sets the userInfo. Assumes this component is already escaped.
*
* @param userInfo userInfo
*/
@@ -397,7 +417,7 @@
}
/**
- * Sets the path.
+ * Sets the path. Assumes this component is already escaped.
*
* @param path path
*/
@@ -468,7 +488,8 @@
/**
* Sets (and resets) the query string.
* This method assumes that the query is already encoded and
- * the parameter delimiter is the '&' character.
+ * escaped and where the parameter delimiter is the '&'
+ * character.
*
* @param query Query string
*/
@@ -494,7 +515,7 @@
}
/**
- * Returns the query string (encoded).
+ * Returns the query string (encoded/escaped).
*
* <p> This uses a default delimiter to separate the parameters, usually
* the "&" character unless the instance has been set to
@@ -580,8 +601,8 @@
if ( !encoded )
{
- name = encode( name, _encoding );
- value = encode( value, _encoding );
+ name = encode( name );
+ value = encode( value );
}
if ( _params == null )
@@ -635,7 +656,7 @@
String name = ( String ) keys.next();
String encodedName = name;
- if ( !encoded ) { encodedName = encode( name, _encoding ); }
+ if ( !encoded ) { encodedName = encode( name ); }
List< String > values = _params.get( encodedName );
if ( values == null )
@@ -680,7 +701,7 @@
{
if ( !encoded )
{
- value = encode( value, _encoding );
+ value = encode( value );
}
list.add( value );
@@ -899,8 +920,6 @@
}
}
- // @struts : from org.apache.struts.util.RequestUtils RC 1.1
- // This has been modified to assume 1.4
/**
* Convenience method to encode unencoded components of a URI.
*
@@ -930,6 +949,19 @@
}
/**
+ * Convenience method to encode unencoded components of a URI.
+ * This implementation uses the value of the character encoding
+ * field of this instance.
+ *
+ * @param url the string to be encoded by [EMAIL PROTECTED] URLCodec}
+ * @return the encoded string
+ */
+ public String encode( String url )
+ {
+ return encode( url, _encoding );
+ }
+
+ /**
* Determines if the passed-in Object is equivalent to this MutableURI.
*
* @param object the Object to test for equality.
@@ -988,5 +1020,173 @@
{
return 0;
}
-}
+ /**
+ * Parse a URI reference, as a <code>String</code>, into its
+ * components and use [EMAIL PROTECTED] java.net.URI} to encode the
+ * components correctly. This comes from the parsing
+ * algorithm of the Apache Commons HttpClient code for
+ * its URI class.
+ *
+ * @param original the original character sequence
+ * @throws URISyntaxException If an error occurs.
+ */
+ protected static URI encodeURI( String original ) throws URISyntaxException
+ {
+ if ( original == null )
+ {
+ throw new IllegalArgumentException( "URI-Reference required" );
+ }
+
+ String scheme = null;
+ String authority = null;
+ String path = null;
+ String query = null;
+ String fragment = null;
+ String tmp = original.trim();
+ int length = tmp.length();
+ int from = 0;
+
+ // The test flag whether the URI is started from the path component.
+ boolean isStartedFromPath = false;
+ int atColon = tmp.indexOf( ':' );
+ int atSlash = tmp.indexOf( '/' );
+
+ if ( atColon < 0 || ( atSlash >= 0 && atSlash < atColon ) )
+ {
+ isStartedFromPath = true;
+ }
+
+ int at = indexFirstOf( tmp, isStartedFromPath ? "/?#" : ":/?#", from );
+
+ if ( at == -1 )
+ {
+ at = 0;
+ }
+
+ // Parse the scheme.
+ if ( at < length && tmp.charAt( at ) == ':' )
+ {
+ scheme = tmp.substring( 0, at ).toLowerCase();
+ from = ++at;
+ }
+
+ // Parse the authority component.
+ if ( 0 <= at && at < length )
+ {
+ if ( tmp.charAt( at ) == '/' )
+ {
+ if ( at + 2 < length && tmp.charAt( at + 1 ) == '/' )
+ {
+ // the temporary index to start the search from
+ int next = indexFirstOf( tmp, "/?#", at + 2 );
+ if ( next == -1 )
+ {
+ next = ( tmp.substring( at + 2 ).length() == 0 ) ? at
+ 2 : tmp.length();
+ }
+ authority = tmp.substring( at + 2, next );
+ from = at = next;
+ }
+ }
+ else if ( scheme != null && tmp.indexOf( '/', at + 1 ) < 0 )
+ {
+ int next = tmp.indexOf( '#', at );
+ if ( next == -1 )
+ {
+ next = length;
+ }
+ String ssp = tmp.substring( at, next );
+ if ( next != length )
+ {
+ fragment = tmp.substring( next + 1 );
+ }
+ return new URI( scheme, ssp, fragment );
+ }
+ }
+
+ // Parse the path component.
+ if ( from < length )
+ {
+ int next = indexFirstOf( tmp, "?#", from );
+ if ( next == -1 )
+ {
+ next = length;
+ }
+ path = tmp.substring( from, next );
+ at = next;
+ }
+
+ // Parse the query component.
+ if ( 0 <= at && at + 1 < length && tmp.charAt( at ) == '?' )
+ {
+ int next = tmp.indexOf( '#', at + 1 );
+ if ( next == -1 )
+ {
+ next = length;
+ }
+ query = tmp.substring( at + 1, next );
+ at = next;
+ }
+
+ // Parse the fragment component.
+ if ( 0 <= at && at + 1 <= length && tmp.charAt( at ) == '#' )
+ {
+ if ( at + 1 == length )
+ { // empty fragment
+ fragment = "";
+ }
+ else
+ {
+ fragment = tmp.substring( at + 1 );
+ }
+ }
+
+ // Use java.net.URI to encode components and return.
+ return new URI( scheme, authority, path, query, fragment );
+ }
+
+ /**
+ * Get the earliest index, searching for the first occurrance of
+ * any one of the given delimiters.
+ *
+ * @param s the string to be indexed
+ * @param delims the delimiters used to index
+ * @param offset the from index
+ * @return the earlier index if there are delimiters
+ */
+ protected static int indexFirstOf( String s, String delims, int offset )
+ {
+ if ( s == null || s.length() == 0 )
+ {
+ return -1;
+ }
+ if ( delims == null || delims.length() == 0 )
+ {
+ return -1;
+ }
+
+ // check boundaries
+ if ( offset < 0 )
+ {
+ offset = 0;
+ }
+ else if ( offset > s.length() )
+ {
+ return -1;
+ }
+
+ // s is never null
+ int min = s.length();
+ char[] delim = delims.toCharArray();
+ for ( int i = 0; i < delim.length; i++ )
+ {
+ int at = s.indexOf( delim[i], offset );
+ if ( at >= 0 && at < min )
+ {
+ min = at;
+ }
+ }
+
+ return ( min == s.length() ) ? -1 : min;
+ }
+}
Modified:
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/FreezableMutableURITest.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/FreezableMutableURITest.java?view=diff&r1=160607&r2=160608
==============================================================================
---
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/FreezableMutableURITest.java
(original)
+++
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/FreezableMutableURITest.java
Fri Apr 8 14:07:15 2005
@@ -35,7 +35,8 @@
{
//
// Strings for tests. Elements are...
- // encoding, scheme, user info, host, port, path, query, fragment, result
+ // scheme, user info, host, port, path, query, fragment,
+ // and full uri
//
private String[][] _tests =
{
@@ -63,13 +64,7 @@
// instances of the same parameter name
{ "http", null, "localhost", "8080",
"/test-servlet/TestServlet", "param1¶m1=¶m2", null,
-
"http://localhost:8080/test-servlet/TestServlet?param1¶m1=¶m2" },
-
- // test for query with escaped characters
- { "http", null, "localhost", "8080",
- "/test-servlet/TestServlet",
-
"textId=%C4%F3%BD%D0%BA%D1%A4%DF&spacesAmpQuotes=%22text%20space1%20%26%20space2%22&tags=%3CsomeTag%3E&percent=100%25tilda=%7Etilda",
null,
-
"http://localhost:8080/test-servlet/TestServlet?textId=%C4%F3%BD%D0%BA%D1%A4%DF&spacesAmpQuotes=%22text%20space1%20%26%20space2%22&tags=%3CsomeTag%3E&percent=100%25tilda=%7Etilda"
}
+
"http://localhost:8080/test-servlet/TestServlet?param1¶m1=¶m2" }
};
public FreezableMutableURITest( String name )
@@ -118,7 +113,7 @@
FreezableMutableURI uri = new FreezableMutableURI( scheme,
userInfo, host, port,
path, query, fragment );
assertEquals( uriString, uri.getURIString() );
- FreezableMutableURI other = new FreezableMutableURI( uriString
);
+ FreezableMutableURI other = new FreezableMutableURI(
uriString, false );
assertEquals( uri, other );
other = new FreezableMutableURI( new URI( uriString ) );
assertEquals( uri, other );
@@ -160,7 +155,7 @@
uri.setFragment( fragment );
assertEquals( uriString, uri.getURIString() );
- FreezableMutableURI other = new FreezableMutableURI( uriString
);
+ FreezableMutableURI other = new FreezableMutableURI(
uriString, false );
assertEquals( uri, other );
}
catch ( URISyntaxException e )
@@ -176,7 +171,7 @@
FreezableMutableURI uri = null;
try
{
- uri = new FreezableMutableURI( uriString );
+ uri = new FreezableMutableURI( uriString, true );
}
catch ( URISyntaxException e )
{
@@ -320,7 +315,7 @@
try
{
- FreezableMutableURI uri = new FreezableMutableURI( uriString );
+ FreezableMutableURI uri = new FreezableMutableURI( uriString,
false );
assertFalse( uri.isFrozen() );
uri.setFrozen( true );
assertTrue( uri.isFrozen() );
@@ -372,7 +367,7 @@
uriA.setPath( "/test" );
uriA.setQuery( "param1¶m2¶m1=¶m3=true¶m1=true" );
- FreezableMutableURI uriB = new FreezableMutableURI( uriString );
+ FreezableMutableURI uriB = new FreezableMutableURI( uriString,
true );
assertEquals( uriA.getURIString(), uriString );
assertEquals( uriA.getURIString(), uriB.getURIString() );
Modified:
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/MutableURITest.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/MutableURITest.java?view=diff&r1=160607&r2=160608
==============================================================================
---
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/MutableURITest.java
(original)
+++
incubator/beehive/trunk/netui/test/src/junitTests/org/apache/beehive/netui/test/core/urls/MutableURITest.java
Fri Apr 8 14:07:15 2005
@@ -38,7 +38,8 @@
//
// Strings for tests. Elements are...
- // encoding, scheme, user info, host, port, path, query, fragment, result
+ // scheme, user info, host, port, path, query, fragment,
+ // and full uri
//
private String[][] _tests =
{
@@ -95,13 +96,7 @@
{ "http", null, "localhost", "8080",
"/Web/d/newAction1.do;jsessionid=F0C07D10C0E8CD22618ED1178F0F62C8",
null, null,
-
"http://localhost:8080/Web/d/newAction1.do;jsessionid=F0C07D10C0E8CD22618ED1178F0F62C8"
},
-
- // test for query with escaped characters
- { "http", null, "localhost", "8080",
- "/test-servlet/TestServlet",
-
"textId=%C4%F3%BD%D0%BA%D1%A4%DF&spacesAmpQuotes=%22text%20space1%20%26%20space2%22&tags=%3CsomeTag%3E&percent=100%25tilda=%7Etilda",
null,
-
"http://localhost:8080/test-servlet/TestServlet?textId=%C4%F3%BD%D0%BA%D1%A4%DF&spacesAmpQuotes=%22text%20space1%20%26%20space2%22&tags=%3CsomeTag%3E&percent=100%25tilda=%7Etilda"
}
+
"http://localhost:8080/Web/d/newAction1.do;jsessionid=F0C07D10C0E8CD22618ED1178F0F62C8"
}
};
public MutableURITest( String name )
@@ -150,7 +145,7 @@
MutableURI uri = new MutableURI( scheme, userInfo, host, port,
path, query, fragment );
assertEquals( uriString, uri.getURIString() );
- MutableURI other = new MutableURI( uriString );
+ MutableURI other = new MutableURI( uriString, false );
assertEquals( uri, other );
other = new MutableURI( new URI( uriString ) );
assertEquals( uri, other );
@@ -192,7 +187,7 @@
uri.setFragment( fragment );
assertEquals( uriString, uri.getURIString() );
- MutableURI other = new MutableURI( uriString );
+ MutableURI other = new MutableURI( uriString, false );
assertEquals( uri, other );
}
catch ( URISyntaxException e )
@@ -222,7 +217,7 @@
try
{
- MutableURI uri = new MutableURI( uriString );
+ MutableURI uri = new MutableURI( uriString, false );
assertEquals( uriString, uri.getURIString() );
assertEquals( uri.getScheme(), scheme );
assertEquals( uri.getHost(), host );
@@ -243,9 +238,9 @@
{
try
{
- MutableURI uri = new MutableURI(
"http://localhost/test?param1=true" );
+ MutableURI uri = new MutableURI(
"http://localhost/test?param1=true", true );
assertTrue( uri.isAbsolute() );
- uri = new MutableURI( "/test?param1=true" );
+ uri = new MutableURI( "/test?param1=true", true );
assertFalse( uri.isAbsolute() );
}
catch ( URISyntaxException e )
@@ -364,13 +359,13 @@
eucJPEncodedUri.setPath( path );
// test encoding of URI reserved characters, etc.
- String reserved = "semi;slash/quest?colon:[EMAIL
PROTECTED]&equ=plus+doller$comm,";
+ String reserved = "semi;slash/colon:[EMAIL
PROTECTED]&eq=pl+doller$comm,q?end";
String mark = "hyph-un_per.ex!tilda~ast*ap'lp(rp)";
utf8EncodedUri.addParameter( reserved, mark, false );
eucJPEncodedUri.addParameter( reserved, mark, false );
assertEquals( utf8EncodedUri.getURIString(),
eucJPEncodedUri.getURIString() );
assertEquals( utf8EncodedUri.getQuery(),
-
"semi%3Bslash%2Fquest%3Fcolon%3Aat%40and%26equ%3Dplus%2Bdoller%24comm%2C"
+
"semi%3Bslash%2Fcolon%3Aat%40and%26eq%3Dpl%2Bdoller%24comm%2Cq%3Fend"
+ "=" + "hyph-un_per.ex%21tilda%7East*ap%27lp%28rp%29" );
utf8EncodedUri.setQuery( null );
@@ -385,7 +380,7 @@
"lcb%7Brcb%7Dbar%7Cbs%5Cctr%5Elb%5Brb%5Dlq%60"
+ "=" + "space+lt%3Cgt%3Elb%23perc%25%22quotes%22" );
- // test encoding of mu;tibyte characters in a URI.
+ // test encoding of multibyte characters in a URI.
utf8EncodedUri.setQuery( null );
eucJPEncodedUri.setQuery( null );
String name = "name";
@@ -397,6 +392,36 @@
name + "=" + "%E6%8F%90%E5%87%BA%E6%B8%88%E3%81%BF" );
assertEquals( eucJPEncodedUri.getQuery(),
name + "=" + "%C4%F3%BD%D0%BA%D1%A4%DF" );
+
+ // test encoding in constructor.
+ try
+ {
+ // mark characters OK unescaped in the path
+ MutableURI uri = new MutableURI( "http://localhost:80/mark/" +
mark, false );
+ assertEquals( "http://localhost:80/mark/" + mark,
+ uri.getURIString() );
+
+ // reserved characters OK unescaped in the
+ // path and the '?' indicates the start of the query
+ uri = new MutableURI( "http://localhost:80/reserved/" + reserved,
false );
+ assertEquals( "http://localhost:80/reserved/" + reserved,
+ uri.getURIString() );
+
+ // unwise
+ uri = new MutableURI( "http://localhost:80/unwise/" + unwise,
false );
+ assertEquals(
"http://localhost:80/unwise/lcb%7Brcb%7Dbar%7Cbs%5Cctr%5Elb%5Brb%5Dlq%60",
+ uri.getURIString() );
+
+ // excluded. note that '#' is interpreted as fragment
+ // and should not be escaped in this test
+ uri = new MutableURI( "http://localhost:80/excluded/" + excluded,
false );
+ assertEquals(
"http://localhost:80/excluded/space%20lt%3Cgt%3Elb#perc%25%22quotes%22",
+ uri.getURIString() );
+ }
+ catch ( URISyntaxException e )
+ {
+ fail( "Test failed with a URISyntaxException: " + e.getMessage() );
+ }
}
public void testgetURIStringForXML()
@@ -431,7 +456,7 @@
uriA.setPath( "/test" );
uriA.setQuery( "param1¶m2¶m1=¶m3=true¶m1=true" );
- MutableURI uriB = new MutableURI( uriString );
+ MutableURI uriB = new MutableURI( uriString, true );
assertEquals( uriA.getURIString(), uriString );
assertEquals( uriA.getURIString(), uriB.getURIString() );
@@ -475,6 +500,9 @@
AnotherMutableURI another = new AnotherMutableURI( new URI(
uriString ) );
assertFalse( uriA.equals( another ) );
+ // also, an extra test that setURI() resets the values of the
object
+ uriA.setURI( "", true );
+ assertTrue( uriA.equals( new MutableURI() ) );
}
catch ( URISyntaxException e )
{
Added:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/Controller.jpf
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/Controller.jpf?view=auto&rev=160608
==============================================================================
---
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/Controller.jpf
(added)
+++
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/Controller.jpf
Fri Apr 8 14:07:15 2005
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ *
+ * $Header:$
+ */
+package tags.encoding;
+
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+
[EMAIL PROTECTED](
+ simpleActions = {
+ @Jpf.SimpleAction( name="begin", path="index.jsp" ),
+ @Jpf.SimpleAction( name="beginUTF8", path="beginUTF8.jsp" ),
+ @Jpf.SimpleAction( name="beginEUCJP", path="beginEUCJP.jsp" ),
+ @Jpf.SimpleAction( name="escaping", path="escaping.jsp" )
+ }
+)
+public class Controller extends PageFlowController
+{
+ private final String _foo = "\u63d0\u51fa\u6e08\u307f";
+ private String _barUTF8 = "";
+ private String _barEUCJP = "";
+
+ public final String getFoo() {
+ return _foo;
+ }
+
+ public final String getBarUTF8() {
+ return _barUTF8;
+ }
+
+ public final String getBarEUCJP() {
+ return _barEUCJP;
+ }
+
+ @Jpf.Action(
+ forwards = {
+ @Jpf.Forward( name = "success", path = "uriSyntax.jsp" )
+ }
+ )
+ public Forward navigateUriSyntax()
+ {
+ return new Forward("success");
+ }
+
+ @Jpf.Action(
+ forwards = {
+ @Jpf.Forward( name = "success", path = "utf8.jsp" )
+ }
+ )
+ public Forward navigateUTF8()
+ {
+ _barUTF8 = getRoundTripData("UTF8");
+ return new Forward("success");
+ }
+
+ @Jpf.Action(
+ forwards = {
+ @Jpf.Forward( name = "success", path = "eucjp.jsp" )
+ }
+ )
+ public Forward navigateEUCJP()
+ {
+ _barEUCJP = getRoundTripData("EUC_JP");
+ return new Forward("success");
+ }
+
+ private String getRoundTripData(String encoding)
+ {
+ StringBuilder result = new StringBuilder();
+ String name = "foo";
+ String value = getRequest().getParameter(name);
+ if (value == null) return result.toString();
+ try {
+ //
+ // encode the bytes correctly for a Java unicode String
+ // ...depends on the environment.
+ //
+ byte[] bytes = value.getBytes("ISO-8859-1");
+ result.append("\nRequest parameter " + name + " encoded using "
+ + encoding + ": " + new String(bytes, encoding));
+ } catch (Exception e) {
+ result.append("\nException: " + e.getMessage());
+ }
+
+ return result.toString();
+ }
+
+
+}
+
Propchange:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/Controller.jpf
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/beginEUCJP.jsp
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/beginEUCJP.jsp?view=auto&rev=160608
==============================================================================
---
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/beginEUCJP.jsp
(added)
+++
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/beginEUCJP.jsp
Fri Apr 8 14:07:15 2005
@@ -0,0 +1,34 @@
+<%@ page language="java" contentType="text/html;charset=EUC_JP"%>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"
%>
+<html>
+<head>
+<title>Test EUC_JP Multibyte Characters and Tags</title>
+<netui:base />
+</head>
+<body>
+<h4>Anchor Tests</h4>
+<p style="color:green">
+This is a set of tests of anchors. The following anchors will navigate to a
target page using support for <b>action</b> and <b>href</b> as the primary
means of navigation.
+</p>
+<p>Multibyte Text</p>
+<netui:span value="${pageFlow.foo}"/>
+
+<h2>Navigate To EUC_JP Through...</h2>
+<ul>
+<li><netui:anchor action="navigateEUCJP">an action
+ <netui:parameter name="foo" value="${pageFlow.foo}"/>
+ </netui:anchor>
+</li>
+<li><netui:anchor href="navigateEUCJP.do">an href to the action
+ <netui:parameter name="foo" value="${pageFlow.foo}"/>
+ </netui:anchor>
+</li>
+<li><netui:anchor href="eucjp.jsp">an href directly to the JSP
+ <netui:parameter name="foo" value="${pageFlow.foo}"/>
+ </netui:anchor>
+</li>
+</ul>
+
+</p>
+</body>
+</html>
Propchange:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/beginEUCJP.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/beginUTF8.jsp
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/beginUTF8.jsp?view=auto&rev=160608
==============================================================================
---
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/beginUTF8.jsp
(added)
+++
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/beginUTF8.jsp
Fri Apr 8 14:07:15 2005
@@ -0,0 +1,34 @@
+<%@ page language="java" contentType="text/html;charset=UTF-8" %>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"
%>
+<html>
+<head>
+<title>Test UTF-8 Multibyte Characters and Tags</title>
+<netui:base />
+</head>
+<body>
+<h4>Anchor Tests</h4>
+<p style="color:green">
+This is a set of tests of anchors. The following anchors will navigate to a
target page using support for <b>action</b> and <b>href</b> as the primary
means of navigation.
+</p>
+<p>Multibyte Text</p>
+<netui:span value="${pageFlow.foo}"/>
+
+<h2>Navigate To UTF-8 Through...</h2>
+<ul>
+<li><netui:anchor action="navigateUTF8">an action
+ <netui:parameter name="foo" value="${pageFlow.foo}"/>
+ </netui:anchor>
+</li>
+<li><netui:anchor href="navigateUTF8.do">an href to the action
+ <netui:parameter name="foo" value="${pageFlow.foo}"/>
+ </netui:anchor>
+</li>
+<li><netui:anchor href="utf8.jsp">an href directly to the JSP
+ <netui:parameter name="foo" value="${pageFlow.foo}"/>
+ </netui:anchor>
+</li>
+</ul>
+
+</p>
+</body>
+</html>
Propchange:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/beginUTF8.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/escaping.jsp
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/escaping.jsp?view=auto&rev=160608
==============================================================================
---
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/escaping.jsp
(added)
+++
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/escaping.jsp
Fri Apr 8 14:07:15 2005
@@ -0,0 +1,99 @@
+<%@ page language="java" contentType="text/html;charset=UTF-8" %>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"
%>
+<html>
+<head>
+<title>Other Escaped Character Test</title>
+<netui:base />
+</head>
+<body>
+<h1>Other Escaped Character Test</h1>
+
+<h3>anchor tag</h3>
+<pre>
+mark = '-' | '_' | '.' | '!' | '~' | '*' | "'" | '(' | ')'
+</pre>
+<netui:anchor
href="a-b_c.d!e~f*g'h(i)j.html?mark=a-b_c.d!e~f*g'h(i)j#a-b_c.d!e~f*g'h(i)j">
+ mark - test href
+</netui:anchor>
+<br>
+<netui:anchor href="a-b_c.d!e~f*g'h(i)j.html" location="a-b_c.d!e~f*g'h(i)j">
+ mark - test href and parameter
+ <netui:parameter name="mark" value="a-b_c.d!e~f*g'h(i)j"/>
+</netui:anchor>
+<br>
+
+<pre>
+reserved = ';' | '/' | '?' | ':' | '@' | '&' | '=' | '+' | '$' | ','
+note: path also has ';' | '/' | '='| '?' reserved
+</pre>
+<netui:anchor href="b/d:[EMAIL PROTECTED]&h+i$j,k.html?reserved=a;b/c?d:[EMAIL
PROTECTED]&g=h+i$j,k#a;b/c?d:[EMAIL PROTECTED]&g=h+i$j,k">
+ reserved - test href
+</netui:anchor>
+<br>
+<netui:anchor href="b/d:[EMAIL PROTECTED]&h+i$j,k.html"
location="a;b/c?d:[EMAIL PROTECTED]&g=h+i$j,k">
+ reserved - test href and parameter
+ <netui:parameter name="reserved" value="a;b/c?d:[EMAIL
PROTECTED]&g=h+i$j,k"/>
+</netui:anchor>
+<br>
+
+<pre>
+unwise = '{' | '}' | '|' | '\' | '^' | '[' | ']' | "`"
+</pre>
+<netui:anchor
href="a{b}c|d\e^f[g]h`i.html?unwise=a{b}c|d\e^f[g]h`i#a{b}c|d\e^f[g]h`i">
+ unwise - test href
+</netui:anchor>
+<br>
+<netui:anchor href="a{b}c|d\e^f[g]h`i.html" location="a{b}c|d\e^f[g]h`i">
+ unwise - test href and parameter
+ <netui:parameter name="unwise" value="a{b}c|d\e^f[g]h`i"/>
+</netui:anchor>
+<br>
+
+<pre>
+delim = '<' | '>' | '#' | '%' | '"'
+</pre>
+<netui:anchor href="a<b>d%e\"f.html?delim=a<b>d%e\"f#a<b>c#d%e\"f">
+ delim - test href
+</netui:anchor>
+<br>
+<netui:anchor href="a<b>d%e\"f.html" location="a<b>c#d%e\"f">
+ delim - test href and parameter
+ <netui:parameter name="delim" value="a<b>d%e\"f"/>
+</netui:anchor>
+<br>
+
+<pre>
+space = ' '
+</pre>
+<netui:anchor href="a b.html?spaces=a b#a b">
+ spaces - test href
+</netui:anchor>
+<br>
+<netui:anchor href="a b.html" location="a b">
+ spaces - test href and parameter
+ <netui:parameter name="spaces" value="a b"/>
+</netui:anchor>
+<br>
+
+<h3>rewriteURL tag</h3>
+<netui:rewriteURL URL="b/d:[EMAIL
PROTECTED]&h+i$j,k.html?reserved=a;b/c?d:[EMAIL
PROTECTED]&g=h+i$j,k#a;b/c?d:[EMAIL PROTECTED]&g=h+i$j,k"/>
+<br>
+<netui:rewriteURL
URL="a{b}c|d\e^f[g]h`i.html?unwise=a{b}c|d\e^f[g]h`i#a{b}c|d\e^f[g]h`i"/>
+<br>
+<netui:rewriteURL URL="space test.html">
+ <netui:parameter name="excluded" value="space a<b>d%e\"f"/>
+</netui:rewriteURL>
+<br>
+
+<h3>imageAnchor tag</h3>
+<netui:imageAnchor href="space test.gif" alt="space test">
+ <netui:parameter name="excluded" value="space a<b>d%e\"f"/>
+</netui:imageAnchor>
+
+<p>
+Return <netui:anchor action="begin">home</netui:anchor>
+</p>
+
+</body>
+</html>
+
Propchange:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/escaping.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/eucjp.jsp
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/eucjp.jsp?view=auto&rev=160608
==============================================================================
---
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/eucjp.jsp
(added)
+++
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/eucjp.jsp
Fri Apr 8 14:07:15 2005
@@ -0,0 +1,52 @@
+<%@ page language="java" contentType="text/html;charset=EUC_JP" %>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"
%>
+<html>
+<head>
+<title>EUC_JP Multibyte Test</title>
+<netui:base />
+</head>
+<body>
+<h1>EUC_JP Multibyte Test</h1>
+<p>
+Request Character Encoding: <%= request.getCharacterEncoding() %>
+<br>
+Response Character Encoding: <%= response.getCharacterEncoding() %>
+</p>
+
+<br>
+pageFlow.foo...
+<netui:span value="${pageFlow.foo}"/>
+<br>
+Page Flow processing...
+<netui:span value="${pageFlow.barEUCJP}"/>
+
+<br>
+JSP processing...
+<%
+ StringBuilder result = new StringBuilder(256);
+ String name = "foo";
+ String value = request.getParameter(name);
+ if (value != null) {
+ try {
+ //
+ // encode the bytes correctly for a Java unicode String
+ // ...depends on the environment.
+ //
+ byte[] bytes = value.getBytes("ISO-8859-1");
+ result.append("\n<br>Request parameter " + name + " encoded using "
+ + "EUC_JP: " + new String(bytes, "EUC_JP"));
+ } catch (Exception e) {
+ result.append("\nException: " + e.getMessage());
+ }
+ }
+%>
+<%= result.toString() %>
+
+<p>
+Return <netui:anchor action="begin">home</netui:anchor> or back to the
+<netui:anchor action="beginEUCJP">EUC_JP tests</netui:anchor>.
+</p>
+
+</body>
+</html>
+
Propchange:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/eucjp.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/index.jsp
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/index.jsp?view=auto&rev=160608
==============================================================================
---
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/index.jsp
(added)
+++
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/index.jsp
Fri Apr 8 14:07:15 2005
@@ -0,0 +1,25 @@
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"
%>
+<html>
+<head>
+<title>Test Multibyte Characters and Tags</title>
+<netui:base />
+</head>
+<body>
+
+<p>Test NetUI tag support of multibyte characters and escaped characters for
proper URI syntax...</p>
+<ul>
+<li>
+ <netui:anchor action="beginUTF8">Test escaping UTF-8 character set
+ </netui:anchor>
+</li>
+<li>
+ <netui:anchor action="beginEUCJP">Test escaping EUC_JP character set
+ </netui:anchor>
+</li>
+<li>
+ <netui:anchor action="escaping">Test other escaped characters
+ </netui:anchor>
+</li>
+</ul>
+</body>
+</html>
Propchange:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/index.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/utf8.jsp
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/utf8.jsp?view=auto&rev=160608
==============================================================================
---
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/utf8.jsp
(added)
+++
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/utf8.jsp
Fri Apr 8 14:07:15 2005
@@ -0,0 +1,52 @@
+<%@ page language="java" contentType="text/html;charset=UTF-8" %>
+<%@ taglib uri="http://beehive.apache.org/netui/tags-html-1.0" prefix="netui"
%>
+<html>
+<head>
+<title>UTF-8 Multibyte Test</title>
+<netui:base />
+</head>
+<body>
+<h1>UTF-8 Multibyte Test</h1>
+<p>
+Request Character Encoding: <%= request.getCharacterEncoding() %>
+<br>
+Response Character Encoding: <%= response.getCharacterEncoding() %>
+</p>
+
+<br>
+pageFlow.foo...
+<netui:span value="${pageFlow.foo}"/>
+<br>
+Page Flow processing...
+<netui:span value="${pageFlow.barUTF8}"/>
+
+<br>
+JSP processing...
+<%
+ StringBuilder result = new StringBuilder(256);
+ String name = "foo";
+ String value = request.getParameter(name);
+ if (value != null) {
+ try {
+ //
+ // encode the bytes correctly for a Java unicode String
+ // ...depends on the environment.
+ //
+ byte[] bytes = value.getBytes("ISO-8859-1");
+ result.append("\n<br>Request parameter " + name + " encoded using "
+ + "UTF8: " + new String(bytes, "UTF8"));
+ } catch (Exception e) {
+ result.append("\nException: " + e.getMessage());
+ }
+ }
+%>
+<%= result.toString() %>
+
+<p>
+Return <netui:anchor action="begin">home</netui:anchor> or back to the
+<netui:anchor action="beginUTF8">UTF-8 tests</netui:anchor>.
+</p>
+
+</body>
+</html>
+
Propchange:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tags/encoding/utf8.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml?view=diff&r1=160607&r2=160608
==============================================================================
---
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
(original)
+++
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
Fri Apr 8 14:07:15 2005
@@ -6784,6 +6784,34 @@
</features>
</test>
<test>
+ <name>TagsAndURLEscapedChars</name>
+ <description>Test tags with URLs that require encoding with escaped
characters</description>
+ <webapp>coreWeb</webapp>
+ <categories>
+ <category>bvt</category>
+ <category>bvt.struts11</category>
+ <category>tags</category>
+ </categories>
+ <features>
+ <feature>Anchor</feature>
+ <feature>URLRewriter</feature>
+ </features>
+ </test>
+ <test>
+ <name>TagsAndUTF8URLEncoding</name>
+ <description>Test tags with URL encoding of multibyte characters in
UTF-8</description>
+ <webapp>coreWeb</webapp>
+ <categories>
+ <category>bvt</category>
+ <category>bvt.struts11</category>
+ <category>tags</category>
+ </categories>
+ <features>
+ <feature>Anchor</feature>
+ <feature>URLRewriter</feature>
+ </features>
+ </test>
+ <test>
<name>TagSizeBinding</name>
<description>Binding to the size attributes on the tags</description>
<webapp>coreWeb</webapp>
Added:
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/TagsAndURLEscapedChars.xml
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/TagsAndURLEscapedChars.xml?view=auto&rev=160608
==============================================================================
---
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/TagsAndURLEscapedChars.xml
(added)
+++
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/TagsAndURLEscapedChars.xml
Fri Apr 8 14:07:15 2005
@@ -0,0 +1,138 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ses:recorderSession
xmlns:ses="http://beehive.apache.org/netui/tools/testrecorder/2004/session">
+ <ses:sessionName>TagsAndURLEscapedChars</ses:sessionName>
+ <ses:tester>crogers</ses:tester>
+ <ses:startDate>04 Apr 2005, 04:33:17.624 PM MDT</ses:startDate>
+ <ses:description>Test tags with URLs that require encoding with escaped
characters</ses:description>
+ <ses:tests>
+ <ses:test>
+ <ses:testNumber>1</ses:testNumber>
+ <ses:request>
+ <ses:protocol>HTTP</ses:protocol>
+ <ses:protocolVersion>1.1</ses:protocolVersion>
+ <ses:host>localhost</ses:host>
+ <ses:port>8080</ses:port>
+ <ses:uri>/coreWeb/tags/encoding/escaping.jsp</ses:uri>
+ <ses:method>GET</ses:method>
+ <ses:parameters/>
+ <ses:cookies>
+ <ses:cookie>
+ <ses:name>JSESSIONID</ses:name>
+ <ses:value>B08BC9A7E63682DB397EC264113D482F</ses:value>
+ </ses:cookie>
+ </ses:cookies>
+ <ses:headers>
+ <ses:header>
+ <ses:name>---------------</ses:name>
+ <ses:value>------------</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept</ses:name>
+
<ses:value>text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept-charset</ses:name>
+ <ses:value>UTF-8,*</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>accept-language</ses:name>
+ <ses:value>en-us,en;q=0.5</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>connection</ses:name>
+ <ses:value>keep-alive</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>cookie</ses:name>
+
<ses:value>JSESSIONID=B08BC9A7E63682DB397EC264113D482F</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>host</ses:name>
+ <ses:value>localhost:8080</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>keep-alive</ses:name>
+ <ses:value>300</ses:value>
+ </ses:header>
+ <ses:header>
+ <ses:name>user-agent</ses:name>
+ <ses:value>Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.7) Gecko/20040803 Firefox/0.9.3</ses:value>
+ </ses:header>
+ </ses:headers>
+ </ses:request>
+ <ses:response>
+ <ses:statusCode>200</ses:statusCode>
+ <ses:reason/>
+ <ses:responseBody><![CDATA[<html>
+<head>
+<title>Other Escaped Character Test</title>
+<base href="http://localhost:8080/coreWeb/tags/encoding/escaping.jsp">
+</head>
+<body>
+<h1>Other Escaped Character Test</h1>
+
+<h3>anchor tag</h3>
+<pre>
+mark = '-' | '_' | '.' | '!' | '~' | '*' | "'" | '(' | ')'
+</pre>
+<a
href="/coreWeb/tags/encoding/a-b_c.d!e~f*g'h(i)j.html?mark=a-b_c.d!e~f*g'h(i)j#a-b_c.d!e~f*g'h(i)j">mark
- test href</a>
+<br>
+<a
href="/coreWeb/tags/encoding/a-b_c.d!e~f*g'h(i)j.html?mark=a-b_c.d%21e%7Ef*g%27h%28i%29j#a-b_c.d%21e%7Ef*g%27h%28i%29j">mark
- test href and parameter</a>
+<br>
+
+<pre>
+reserved = ';' | '/' | '?' | ':' | '@' | '&' | '=' | '+' | '$' | ','
+note: path also has ';' | '/' | '='| '?' reserved
+</pre>
+<a href="/coreWeb/tags/encoding/b/d:[EMAIL
PROTECTED]&h+i$j,k.html?reserved=a;b/c?d:[EMAIL
PROTECTED]&g=h+i$j,k#a;b/c?d:[EMAIL PROTECTED]&g=h+i$j,k">reserved - test
href</a>
+<br>
+<a href="/coreWeb/tags/encoding/b/d:[EMAIL
PROTECTED]&h+i$j,k.html?reserved=a%3Bb%2Fc%3Fd%3Ae%40f%26g%3Dh%2Bi%24j%2Ck#a%3Bb%2Fc%3Fd%3Ae%40f%26g%3Dh%2Bi%24j%2Ck">reserved
- test href and parameter</a>
+<br>
+
+<pre>
+unwise = '{' | '}' | '|' | '\' | '^' | '[' | ']' | "`"
+</pre>
+<a
href="/coreWeb/tags/encoding/a%7Bb%7Dc%7Cd%5Ce%5Ef%5Bg%5Dh%60i.html?unwise=a%7Bb%7Dc%7Cd%5Ce%5Ef[g]h%60i#a%7Bb%7Dc%7Cd%5Ce%5Ef[g]h%60i">unwise
- test href</a>
+<br>
+<a
href="/coreWeb/tags/encoding/a%7Bb%7Dc%7Cd%5Ce%5Ef%5Bg%5Dh%60i.html?unwise=a%7Bb%7Dc%7Cd%5Ce%5Ef%5Bg%5Dh%60i#a%7Bb%7Dc%7Cd%5Ce%5Ef%5Bg%5Dh%60i">unwise
- test href and parameter</a>
+<br>
+
+<pre>
+delim = '<' | '>' | '#' | '%' | '"'
+</pre>
+<a
href="/coreWeb/tags/encoding/a%3Cb%3Ed%25e%22f.html?delim=a%3Cb%3Ed%25e%22f#a%3Cb%3Ec%23d%25e%22f">delim
- test href</a>
+<br>
+<a
href="/coreWeb/tags/encoding/a%3Cb%3Ed%25e%22f.html?delim=a%3Cb%3Ed%25e%22f#a%3Cb%3Ec%23d%25e%22f">delim
- test href and parameter</a>
+<br>
+
+<pre>
+space = ' '
+</pre>
+<a href="/coreWeb/tags/encoding/a%20b.html?spaces=a%20b#a%20b">spaces - test
href</a>
+<br>
+<a href="/coreWeb/tags/encoding/a%20b.html?spaces=a+b#a+b">spaces - test href
and parameter</a>
+<br>
+
+<h3>rewriteURL tag</h3>
+b/d:[EMAIL PROTECTED]&h+i$j,k.html?reserved=a;b/c?d:[EMAIL
PROTECTED]&g=h+i$j,k#a;b/c?d:[EMAIL PROTECTED]&g=h+i$j,k
+<br>
+a%7Bb%7Dc%7Cd%5Ce%5Ef%5Bg%5Dh%60i.html?unwise=a%7Bb%7Dc%7Cd%5Ce%5Ef[g]h%60i#a%7Bb%7Dc%7Cd%5Ce%5Ef[g]h%60i
+<br>
+space%20test.html?excluded=space+a%3Cb%3Ed%25e%22f
+<br>
+
+<h3>imageAnchor tag</h3>
+<a
href="/coreWeb/tags/encoding/space%20test.gif?excluded=space+a%3Cb%3Ed%25e%22f"><img
alt="space test"></a>
+
+<p>
+Return <a href="/coreWeb/tags/encoding/begin.do">home</a>
+</p>
+
+</body>
+</html>]]></ses:responseBody>
+ </ses:response>
+ </ses:test>
+ </ses:tests>
+ <ses:endDate>04 Apr 2005, 04:33:26.828 PM MDT</ses:endDate>
+ <ses:testCount>1</ses:testCount>
+</ses:recorderSession>
\ No newline at end of file
Propchange:
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/TagsAndURLEscapedChars.xml
------------------------------------------------------------------------------
svn:eol-style = native