Uploaded image for project: 'HttpComponents HttpClient'
  1. HttpComponents HttpClient
  2. HTTPCLIENT-2076

LaxExpiresHandler throws NullPointerException when a value is null.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 4.5.12, 5.0
    • 4.5.13, 5.0.1
    • None
    • None
    • Patch

    Description

      Hi. I'm using RFC6265LaxSpec and would like to report two issues.

      1. LaxExpiresHandler throws NullPointerException when a value is null.

      This line line is causing NPE.
      You can easily reproduce this, with the following Set-Cookie string.
      Set-Cookie: gtinfo=info; Expires; domain=.webmd.com; path=/

      I think We need to check whether value is blank just like how LaxMaxAgeHandler is doing.
      https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxMaxAgeHandler.java#L60

      2. We need to 'ignore' invalid attributes only.

      LaxExpiresHandler throws MalformedCookieException when attribute is not valid, so the cookie with invalid Expires attributes is ignored entirely. But RFC 6265 says, 'If the attribute-value failed to parse as a cookie date, ignore the cookie-av.

      I think we should not throw MalformedCookieException but just ignore invalid attributes only. LaxMaxAgeHandler is also already doing this.
      https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxMaxAgeHandler.java#L69
      https://github.com/apache/httpcomponents-client/blob/master/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxMaxAgeHandler.java#L61

      Followings are the classes needs to be considered.

      • BasicExpiresHandler
      • BasicMaxAgeHandler
      • LaxExpiresHandler

      Thanks.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Heejeong Kim Hee Jeong Kim
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m