Skip to content

Issue with the cookie when cookie-value contains "=" character #36

@evgk

Description

@evgk

When cookie-value contains "=" character(in my case, session-cookies like that are generated by the Play framework, which generates session-cookies like that:
PLAY_SESSION=<<session_id>>-connected=<>&websockid=<<socket_id>>;), this code fails:

private static void setCookie(Map<String, String> cookies, String host, String path, boolean secure) {
    String url = String.format("%s://%s%s", secure ? "https" : "http", host, path);
    String cookie = CookieManager.getInstance().getCookie(url);

    if (cookie != null) {
        for (String c : cookie.split(";")) {
            String[] pair = c.split("=");

            if (pair.length == 2) {
                cookies.put(pair[0].trim(), pair[1].trim());
            }
        }
    }
}

Since pair.length won't be 2. Suggested PR:
#35
fixes it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions