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

Can't check text that contains percent characters (%) #73

Open
cabo opened this issue Jun 13, 2024 · 1 comment
Open

Can't check text that contains percent characters (%) #73

cabo opened this issue Jun 13, 2024 · 1 comment

Comments

@cabo
Copy link

cabo commented Jun 13, 2024

When checking text (langtool-check) that contains one or more percent characters (%), I get:

Error: Could not decode query. Query length: 63296 Request method: POST

Tested with languagetool-server from LanguageTool 6.0 via HTTP (obviously).
Server-side log:

2024-06-13 21:00:42.266 +0200 INFO  org.languagetool.server.LanguageToolHttpHandler Handling POST /v2/check
2024-06-13 21:00:42.278 +0200 INFO  org.languagetool.server.LanguageToolHttpHandler An error has occurred: 'Could not decode query. Query length: 63296 Request method: POST', sending HTTP code 400. Access from 127.0.0.1, HTTP user agent: null, User agent param: null, Referrer: null, language: null, h: 1, r: 77, time: 9m: ALL, l: DEFAULT, Stacktrace follows:org.languagetool.server.BadRequestException: Could not decode query. Query length: 63296 Request method: POST
	at org.languagetool.server.LanguageToolHttpHandler.getParameterMap(LanguageToolHttpHandler.java:454)
	at org.languagetool.server.LanguageToolHttpHandler.getRequestQuery(LanguageToolHttpHandler.java:401)
...

Apparently, something is amiss with percent-encoding.

langtool 20230222.326 installed

@cabo
Copy link
Author

cabo commented Jun 16, 2024

Hacking lisp/url-util.el to say


(defconst url-path-allowed-chars
  (let ((vec (copy-sequence url-host-allowed-chars)))
    (aset vec ?/ t)
    (aset vec ?: t)
    (aset vec ?@ t)
    (aset vec ?% nil)
    vec)
  "Allowed-character byte mask for the path segment of a URI.
These characters are specified in RFC 3986, Appendix A.")

(the (aset vec ?% nil) is new) fixes this for me.
Are you maybe using url-build-query-string in an unexpected way?

@cabo cabo changed the title Cant't check text that contains percent characters (%) Can't check text that contains percent characters (%) Jun 18, 2024
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

1 participant