.NET Cookie Parsing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike C#

    .NET Cookie Parsing

    Is there a decent cookie parser out there somewhere? I keep running into
    cookies that .NET can't handle. I've also found a couple of other parsers
    but they're choking as well.


  • Mike C#

    #2
    Re: .NET Cookie Parsing

    As I dig a little deeper into it, it appears that .NET is parsing the
    Set-Cookie header properly. The cookies are even split up properly in the
    private members deep down. But somehow they're getting *mangled* on their
    way back up when you try to actually access them. This doesn't make a lot
    of sense to me. Anyone had any experience with this? Hints, tips? Thanks.

    "Mike C#" <xyz@xyz.comwro te in message
    news:uG22b61nIH A.4292@TK2MSFTN GP04.phx.gbl...
    Is there a decent cookie parser out there somewhere? I keep running into
    cookies that .NET can't handle. I've also found a couple of other parsers
    but they're choking as well.
    >

    Comment

    • Patrice

      #3
      Re: .NET Cookie Parsing

      Do you have a bare bone repro for this ?

      I had this once in classic ASP if you put characters that are themselves
      used to separate cookies one from the other or to separate the cookie name
      and value. Encoding those values should fix the problem.

      --
      Patrice


      "Mike C#" <xyz@xyz.coma écrit dans le message de news:
      OJz9mL3nIHA.337 6@TK2MSFTNGP05. phx.gbl...
      As I dig a little deeper into it, it appears that .NET is parsing the
      Set-Cookie header properly. The cookies are even split up properly in the
      private members deep down. But somehow they're getting *mangled* on their
      way back up when you try to actually access them. This doesn't make a lot
      of sense to me. Anyone had any experience with this? Hints, tips?
      Thanks.
      >
      "Mike C#" <xyz@xyz.comwro te in message
      news:uG22b61nIH A.4292@TK2MSFTN GP04.phx.gbl...
      >Is there a decent cookie parser out there somewhere? I keep running into
      >cookies that .NET can't handle. I've also found a couple of other
      >parsers but they're choking as well.
      >>
      >
      >

      Comment

      • Mike C#

        #4
        Re: .NET Cookie Parsing

        I did some investigation, it turns out that the CookieCollectio n uses a
        too-simple string split function instead of actually attempting to "parse"
        the cookie. So any cookies that contain commas get mangled. I then tried
        to grab the data from the Set-Cookie header, but those values get mangled in
        a similar fashion. What's really annoying is that I can see the properly
        parsed values in Visual Studio, way down in the private members of the
        headers collection, but they're not exposed anywhere except in the Visual
        Studio watch window. I ended up creating my own better parser to handle it.
        The website I was playing around with was Expedia.com, BTW. I imagine there
        are probably a lot of other websites that use commas in cookies - they
        should fix the handling behaviour in .NET.

        "Patrice" <http://www..chez.com/scribe/wrote in message
        news:4809e3d4$0 $895$ba4acef3@n ews.orange.fr.. .
        Do you have a bare bone repro for this ?
        >
        I had this once in classic ASP if you put characters that are themselves
        used to separate cookies one from the other or to separate the cookie name
        and value. Encoding those values should fix the problem.
        >
        --
        Patrice
        >
        >
        "Mike C#" <xyz@xyz.coma écrit dans le message de news:
        OJz9mL3nIHA.337 6@TK2MSFTNGP05. phx.gbl...
        >As I dig a little deeper into it, it appears that .NET is parsing the
        >Set-Cookie header properly. The cookies are even split up properly in the
        >private members deep down. But somehow they're getting *mangled* on
        >their way back up when you try to actually access them. This doesn't
        >make a lot of sense to me. Anyone had any experience with this? Hints,
        >tips? Thanks.
        >>
        >"Mike C#" <xyz@xyz.comwro te in message
        >news:uG22b61nI HA.4292@TK2MSFT NGP04.phx.gbl.. .
        >>Is there a decent cookie parser out there somewhere? I keep running
        >>into cookies that .NET can't handle. I've also found a couple of other
        >>parsers but they're choking as well.
        >>>
        >>
        >>
        >
        >

        Comment

        • Bill Woodruff

          #5
          Re: .NET Cookie Parsing

          Mike C# wrote :

          "I ended up creating my own better parser to handle it."

          Hi Mike,

          I imagine there are many people, besides myself, who would really appreciate
          a brief tutorial and your solution if you have the time, inclination, and
          freedom from contractual constraint, that would allow you to post an article
          on CodeProject or a similar venue, or share code.

          thanks, Bill


          Comment

          • Mike C#

            #6
            Re: .NET Cookie Parsing

            "Bill Woodruff" <billw@dotscien ce.comwrote in message
            news:u5cjFKpoIH A.5096@TK2MSFTN GP02.phx.gbl...
            Mike C# wrote :
            >
            "I ended up creating my own better parser to handle it."
            >
            Hi Mike,
            >
            I imagine there are many people, besides myself, who would really
            appreciate
            a brief tutorial and your solution if you have the time, inclination, and
            freedom from contractual constraint, that would allow you to post an
            article
            on CodeProject or a similar venue, or share code.
            >
            This particular piece of code was part of a work for hire, so I can't post
            it without permission. I'll discuss with the person I'm writing it for and
            see if they're willing to allow it. If not, I may write another version of
            the solution (time permitting) and post that. I really believe the absolute
            best solution would be for the .NET team to fix the problem in the
            Framework, but until then I guess we just have to make do with custom
            parsing solutions :(


            Comment

            Working...