After some investigations, it seems the problem lies in
com.webobjects.appserver._private.WOURLEncoder.encodeAsCGIFormValues()
which returns "&" in WO 5.3.1 instead of "&" in WO 5.2.3.
As it was painful to change and replace all occurences of WOHyperlink
using prefixed parameters, I wrote a patch for WOHyerlink, as below.
Drop me a line if you want the test projet to experience the bug.
Hope this helps,
Daniel Muller
.....
package wo.patch;
import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.appserver._private.*;
public class WOHyperlinkPatch extends WOHyperlink
{
private static boolean usePatch = true;
private static final String BOZO_AMPERSAND = "&";
private static final String SIMPLE_AMPERSAND = "&";
public WOHyperlinkPatch(String arg0, NSDictionary arg1, WOElement
arg2)
{
super(arg0, arg1, arg2);
}
protected synchronized void _appendQueryStringToResponse
(WOResponse
response, WOContext context, boolean boolArg)
{
if (usePatch)
{
String initialResponse = response.contentString();
super._appendQueryStringToResponse(response, context,
boolArg);
String finalResponse = response.contentString();
int l0 = initialResponse.length();
int l1 = finalResponse.length();
if (l1 > l0)
{
String queryString = finalResponse.substring(l0);
if (finalResponse.indexOf(BOZO_AMPERSAND) > 0)
{
response.setContent(initialResponse +
queryString.replaceAll(BOZO_AMPERSAND, SIMPLE_AMPERSAND));
}
else if (finalResponse.indexOf('=') !=
finalResponse.lastIndexOf('=') &&
finalResponse.indexOf(SIMPLE_AMPERSAND) > 0)
{
usePatch = false;
}
}
}
else
{
super._appendQueryStringToResponse(response, context,
boolArg);
}
}
}
import com.webobjects.foundation.*;
import com.webobjects.appserver.*;
import com.webobjects.eocontrol.*;
import com.webobjects.appserver._private.*;
public class Application extends WOApplication {
public static void main(String argv[]) {
WOApplication.main(argv, Application.class);
}
public Application() {
super();
_NSUtilities.setClassForName(wo.patch.WOHyperlinkPatch.class,
"WOHyperlink");
}
}
--- David LeBer <email@hidden> wrote:
I'm playing with WebObjects 5.3.1 and I'm seeing an oddity in
WORedirect:
With redirect code like this:
public WOComponent createDA()
{
NSMutableDictionary dict = new NSMutableDictionary();
dict.takeValueForKey("Zero", "valueZero");
dict.takeValueForKey(String.valueOf(1), "valueOne");
dict.takeValueForKey("Two", "valueTwo");
System.out.println("Performing: " + dict);
String url = context().directActionURLForActionNamed( "default",
dict );
WORedirect redirect = new WORedirect(context());
System.out.println("Performing (URL): " + url);
redirect.setUrl(url);
return redirect;
}
And default action code like this:
public WOActionResults defaultAction() {
System.out.println("Action: " + request().formValues());
return pageWithName("Main");
}
I get these results:
Performing: {valueZero = "Zero"; valueTwo = "Two"; valueOne = "1"; }
Performing (URL): /cgi-bin/WebObjects/NewWOTest.woa/wa/default?
valueZero=Zero&valueTwo=Two&valueOne=1
Action: {valueZero = ("Zero"); amp;valueTwo = ("Two"); amp;valueOne =
("1"); }
WO is encoding the ampersands in the url into & but then it is
not respecting the encoding when it extracts the values again
(leaving the munged dictionary keys). I'm hoping there is something
stupid I am doing here and this is not a bug. If anyone can confirm
or negate my results I'd be grateful.
--
;david
--
David LeBer
"I am codeferous!"
Codeferous Software
site: http://www.codeferous.com
blog: http://david.codeferous.com
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40anazys.com
This email sent to email@hidden