• 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: StringIndexOutOfBoundsException and cookies
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: StringIndexOutOfBoundsException and cookies


  • Subject: Re: StringIndexOutOfBoundsException and cookies
  • From: Chuck Hill <email@hidden>
  • Date: Mon, 19 Jan 2004 14:51:40 -0800
  • Organization: Global Village Consulting, Inc.

Kaj Hejer wrote:

At 14:20 -0800 19-01-04, Chuck Hill wrote:

The easiest fix is as follows, in Application.java:

public WOResponse dispatchRequest(WORequest request) {
    String cookieHeader = request.headerForKey("cookie");
    if (cookieHeader != null && /* cookie not ok */) {
        String newCookie = /* Fix cookie here */;
        request.setHeader(URLEncoder.encode(newCookie, "cookie");
    }
    return super.dispatchRequest(request);
}


Hi!

Thanks for answering!

I saw something like that in the WO5.1 releasenotes (?).

The hard part here is to write a good /* cookie not ok */ and /* Fix cookie here */ code :)

No, it only looks difficult. :-) I'm guessing that that cookie value for tittel with the spaces in it is the problem. You could just rename this to tittel_new. Hence, anything with 'tittel=' in it is invalid. :-) Or, you could decide to quote all the values and check for tittel=<anything other than ">. Or you could find 'tittel=', then find the next ';' and finally check for any spaces (i.e. not URL encoded) between them). Or finally, you could not care at all and just URL encode it anyway. I *think* that will not make any difference if it is already URL encoded.

To fix it up you can try quoting the value with spaces, but URL encoding (URLEncode.encode(string, "UTF-8")) is better. If you URL encode the cookie values you are responsible for decoding them:
URLDencode.decode(string, "UTF-8")



Do you think setting WOAcceptMalformedCookies to true make the StringIndexOutOfBoundsException go away?

Maybe, worth a try I guess.


Chuck


-Kaj :)

--

Chuck Hill                                 email@hidden
Global Village Consulting Inc.             http://www.global-village.net

It is a funny thing about life; if you refuse to accept
anything but the best, you very often get it."
  --  W. Somerset Maugham

<shamelessPlug>
  Practical WebObjects
  http://www.amazon.com/exec/obidos/tg/detail/-/1590592964
</shamelessPlug>
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >StringIndexOutOfBoundsException and cookies (From: Kaj Hejer <email@hidden>)
 >Re: StringIndexOutOfBoundsException and cookies (From: arturo <email@hidden>)
 >Re: StringIndexOutOfBoundsException and cookies (From: Kaj Hejer <email@hidden>)
 >Re: StringIndexOutOfBoundsException and cookies (From: Chuck Hill <email@hidden>)
 >Re: StringIndexOutOfBoundsException and cookies (From: Kaj Hejer <email@hidden>)

  • Prev by Date: Re: StringIndexOutOfBoundsException and cookies
  • Next by Date: Re: Newbiw question: adding EOModel to project
  • Previous by thread: Re: StringIndexOutOfBoundsException and cookies
  • Next by thread: Re: StringIndexOutOfBoundsException and cookies
  • Index(es):
    • Date
    • Thread