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

Add support for skipping some cookies from saving in JwikiCookieJar #42

Closed
kb0 opened this issue Jun 27, 2022 · 5 comments
Closed

Add support for skipping some cookies from saving in JwikiCookieJar #42

kb0 opened this issue Jun 27, 2022 · 5 comments

Comments

@kb0
Copy link

kb0 commented Jun 27, 2022

JwikiCookieJar save all new cookies without any filtering, but after each page edit - there is a new cookie like "mediawikiPostEditRevision98996=saved" (MediaWiki send post-edit cookie indicating the user just saved a particular revision).

After several calls of wiki.edit() - there are a lot of cookies "mediawikiPostEditRevision=saved" in each new http-request, so web server start to return - "400 Bad Request - request header or cookie too large".

it would be great if JwikiCookieJar skip such cookies from saving

@fastily
Copy link
Owner

fastily commented Jun 28, 2022

Hi @kb0,

I'm not able to reproduce. Could you please share some sample code that demonstrates this bug?

@kb0
Copy link
Author

kb0 commented Jun 28, 2022

I'm not able reproduce it on pure MediaWiki installation, but it's "works" on MediaWiki + PageForms (at least mediawiki 1.31 + pageforms 4.5.1)

https://github.com/kb0/fastily-jwiki-issues-42 - sample with MediaWiki docker container (1.31 + PageForms)
Errors starts at ~227 - ERROR: [Mediawiki @ localhost]: Could not edit 'Page 227', aborting.

fastily added a commit that referenced this issue Jun 28, 2022
Also included:
* Remove CentralAuth support, hasn't worked for several years now
@fastily
Copy link
Owner

fastily commented Jun 28, 2022

Thanks! I just pushed a commit to master that may address this issue. Could you please try it out and let me know if it works for you?

@kb0
Copy link
Author

kb0 commented Jun 29, 2022

No, the same problem. It's possible to filter out such cookies using CookiePolicy.shouldAccept:

    JavaNetCookieJar(CookieManager(null, object : CookiePolicy {
        override fun shouldAccept(uri: URI, cookie: HttpCookie): Boolean {
            if (cookie.name.startsWith("mediawikiPostEditRevision")) {
                return false;
            }

            return true;
        }
    }))

May be make optional pass of CookieJar/CookiePolicy through Wiki.Builder()

@fastily
Copy link
Owner

fastily commented Jun 30, 2022

Ah, that's unfortunate. I did a quick search on Wikimedia Phabricator and this is apparently a known issue: T69790, T112771, T211233.

May be make optional pass of CookieJar/CookiePolicy through Wiki.Builder()

Good suggestion, I'll do this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants