Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty cookie names throw a ValidationException #2242

Closed
flyingfischer opened this issue Dec 7, 2024 · 6 comments
Closed

Empty cookie names throw a ValidationException #2242

flyingfischer opened this issue Dec 7, 2024 · 6 comments
Labels
bug Confirmed bug that we should fix fixed
Milestone

Comments

@flyingfischer
Copy link

I do see org.jsoup.helper.ValidationException: The 'name' parameter must not be empty since 1.18.2.

I also tried a fresh build from master which includes ed23a9a with no success.

I cannot nail it down to a certain condition, but it happens on response.parse() after using Jsoup.connect.

@jhy
Copy link
Owner

jhy commented Dec 7, 2024

Can you start by providing the stacktrace?

And can you log your input parameters and provide those for the case where you see the exception?

@flyingfischer
Copy link
Author

flyingfischer commented Dec 7, 2024

The stacktrace is:

org.jsoup.helper.ValidationException: The 'name' parameter must not be empty.
at org.jsoup.helper.HttpConnection$Base.cookie(HttpConnection.java:569)
at org.jsoup.helper.HttpConnection$Response.cookie(HttpConnection.java:797)
at org.jsoup.helper.CookieUtil.storeCookies(CookieUtil.java:109)
at org.jsoup.helper.HttpConnection$Response.(HttpConnection.java:1136)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:869)
at org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:830)
at org.jsoup.helper.HttpConnection.execute(HttpConnection.java:351)
at util.WebsiteMonitor.jsoupResponse(WebsiteMonitor.java:424)
at util.WebsiteMonitor.getJsoupDoc(WebsiteMonitor.java:110)
at util.WebsiteMonitor.getDoc(WebsiteMonitor.java:88)
at ch.sc.cronjobs.News.execute(News.java:75)

[JH- snipped 130 lines]

@flyingfischer
Copy link
Author

Calling with something like

Jsoup.connect(link).sslSocketFactory(sslContext.getSocketFactory()) .header("Accept", Constants.ACCEPT.getValue()) .header("Accept-Language", Constants.ACCEPT_LANGUAGE.getValue()) .header("DNT", "1").userAgent(Constants.USER_AGENT.getValue()).timeout(20000).execute();

Target in this case is https://shs.cairn.info/journal-a-contrario?lang=fr

The error is being thrown at response.parse()

@jhy jhy closed this as completed in 9591169 Dec 8, 2024
@jhy jhy changed the title org.jsoup.helper.ValidationException: The 'name' parameter must not be empty. Since 1.18.2 up to jsoup-1.19.1-SNAPSHOT.jar Empty cookie names throw a ValidationException Dec 8, 2024
@jhy jhy added bug Confirmed bug that we should fix fixed labels Dec 8, 2024
@jhy jhy added this to the 1.19.1 milestone Dec 8, 2024
@jhy
Copy link
Owner

jhy commented Dec 8, 2024

Thanks -- fixed. I wasn't able to directly repro on that URL as it was not sending un-named cookies when I tried, but that would be the cause. I added the missing empty name check that was used in previous versions of jsoup.

@flyingfischer
Copy link
Author

Perfect! The most recent snapshot fixes the issue here. Thanks for your great work!

@jhy
Copy link
Owner

jhy commented Dec 9, 2024

Great, thanks for confirming

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bug that we should fix fixed
Projects
None yet
Development

No branches or pull requests

2 participants