• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: WebObjects 5.3.1 Redirect bug?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: WebObjects 5.3.1 Redirect bug?


  • Subject: Re: WebObjects 5.3.1 Redirect bug?
  • From: Dev WO <email@hidden>
  • Date: Fri, 17 Feb 2006 09:46:55 +0100

(Oops, hope this time the message is sent normally. Sorry)

I've seen the same problem with WOHyperlink with a href and parameters
(name prefixed with "?") in that case all the "&" have been replaced
with "&amp;".
Just a quick note, what you are describing (& being replaced by &amp; in hyperlink) is the correct and expected behavior (web standard).

Xavier

After some investigations, it seems the problem lies in com.webobjects.appserver._private.WOURLEncoder.encodeAsCGIFormValues() which returns "&amp;" 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 = "&amp;amp;"; private static final String SIMPLE_AMPERSAND = "&amp;";


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&amp;valueTwo=Two&amp;valueOne=1
Action: {valueZero = ("Zero"); amp;valueTwo = ("Two"); amp;valueOne =

("1"); }

WO is encoding the ampersands in the url into &amp; 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


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Re: WebObjects 5.3.1 Redirect bug? (From: Daniel Muller <email@hidden>)

  • Prev by Date: Re: Problem with page encoding
  • Next by Date: Re: Practical EditingContext Design Question
  • Previous by thread: Re: WebObjects 5.3.1 Redirect bug?
  • Next by thread: Javascript focus on text field in repetition
  • Index(es):
    • Date
    • Thread