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

Trailing Slash in LT Server URL Causes 400 #449

Open
chrillek opened this issue Jun 23, 2022 · 6 comments
Open

Trailing Slash in LT Server URL Causes 400 #449

chrillek opened this issue Jun 23, 2022 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@chrillek
Copy link

Describe the bug
The JSON POST request send to the external server causes a 400 error to be sent back

Wireshark-Log
According to Wireshark, the POST data is
language=auto
data={"annotation":[{"interpretAs":"\n\n\n\n","markup":"<link rel=\"stylesheet\" href=\"styles.css\">\n{{TOC}}\n## Why would you care about CSS?\n\n","offset":{"end":84,"start":0}},{"offset":{"end":623,"start":84},"text":"CSS stands for Cascading Style Sheets. It is a text format that allows you to describe the visual appearance of HTML documents. In DEVONthink, CSS is used to determine the visual appearance of Markdown documents when they are rendered as HTML. Whenever you select the preview mode to look at a Markdown document, you'll see it rendered as HTML in some kind of \"style\". Unless you do anything about it, this will be the style that is built into DEVONthink (and the HTML engine it uses). If you're happy with that, you can stop reading here."},{"interpretAs":"\n\n# ","markup":"\n\n## ","offset":{"end":628,"start":623}},{"offset":{"end":676,"start":628},"text":"How can you tell DEVONthink to use your own CSS?"},{"interpretAs":"\n\n","markup":"\n\n","offset":{"end":678,"start":676}},{"offset":{"end":827,"start":678},"text":"As of the time of this writing (DEVONthink Pro Version 3.8 and DEVONthink To Go 3.5.1), there are four methods to specify your own CSS in DEVONthink:"},{"interpretAs":"\n\n** ","markup":"\n\n1. ","offset":{"end":832,"start":827}},{"offset":{"end":1103,"start":832},"text":"In the global preferences. In DEVONthink, you'd provide the x-devonthink-item URL to a record stored somewhere in your database(s) and containing your CSS. In DEVONthink To Go, you do the same in the settings for Markdown documents. A globally defined CSS will influence "},{"interpretAs":"","markup":"_","offset":{"end":1104,"start":1103}},{"offset"

The server returns
Error: This is the LanguageTool API. You have not specified any parameters...

Environment & Configuration (please complete the following information):

  • OS + Version: MacOS 10.15
  • VS Code Version: 1.68.1
  • LanguageTool Linter Version: 0.19.0
  • LanguageTool Version: 5.7
  • Service Configuration: external
  • Service Classpath (if 'managed'): [e.g. /usr/local/bin/languagetool/*.jar]

Additional context
A simple example on the command line runs ok:
curl -d "language=en-US" -d "text=a simple test" http://192.168.44.5:8010/v2/check {"software":{"name":"LanguageTool","version":"5.7","buildDate":"2022-05-24 19:41:20 +0000","apiVersion":1,"premium":false,"premiumHint":"You might be missing errors only the Premium version can find. Contact us at support<at>languagetoolplus.com.","status":""},"warnings":{"incompleteResults":false},"language":{"name":"English (US)","code":"en-US","detectedLanguage":{"name":"French","code":"fr","confidence":0.815771}},"matches":[{"message":"This sentence does not start with an uppercase letter.","shortMessage":"","replacements":[{"value":"A"}],"offset":0,"length":1,"context":{"text":"a simple test","offset":0,"length":1},"sentence":"a simple test","type":{"typeName":"Other"},"rule":{"id":"UPPERCASE_SENTENCE_START","description":"Checks that a sentence starts with an uppercase letter","issueType":"typographical","category":{"id":"CASING","name":"Capitalization"}},"ignoreForIncompleteSentence":true,"contextForSureMatch":-1}]}
The MD file I used can be found here https://github.com/chrillek/CSS-for-Markdown/blob/master/Using%20CSS.md

@chrillek chrillek added the bug Something isn't working label Jun 23, 2022
@chrillek
Copy link
Author

The bug doesn't seem to be related to the MD document at all. I can trigger it with a very simple one line document like
A simple test. curl runs ok:
curl -d "language=en-US" -d 'data={"annotation":[ {"interpretAs":"", "markup":"","offset":{"end":0,"start":0}}, {"offset":{"end":12,"start":0},"text":"A simple test"},{"interpretAs":"","markup":"","offset":{"end":12,"start":12}} ]}' http://192.168.44.5:8010/v2/check {"software":{"name":"LanguageTool","version":"5.7","buildDate":"2022-05-24 19:41:20 +0000","apiVersion":1,"premium":false,"premiumHint":"You might be missing errors only the Premium version can find. Contact us at support<at>languagetoolplus.com.","status":""},"warnings":{"incompleteResults":false},"language":{"name":"English (US)","code":"en-US","detectedLanguage":{"name":"French","code":"fr","confidence":0.81886995}},"matches":[]}
whereas the extension produces the same error as above. Here's the hex and ASCII dump of the POST request send by the extension:
POST //v2/check HTTP/1.1..Accepts: application/json Content-Type: application/x-www-form-urlencoded;charset=UTF-8 Accept: */* Content-Length: User-Agent: node-fetch/1.0 (+https://github.com/bitinn/node-fetch) Accept-Encoding: gzip,deflate Connection: close Host: 192.168.44.5:8010
and the POST data
HTML Form URL Encoded: application/x-www-form-urlencoded Form item: "language" = "en-US" Key: language Value: en-US Form item: "data" = "{"annotation":[{"interpretAs":"","markup":"","offset":{"end":0,"start":0}},{"offset":{"end":13,"start":0},"text":"A simple test"},{"interpretAs":"","markup":" ","offset":{"end":14,"start":13}}]}" Key: data Value: {"annotation":[{"interpretAs":"","markup":"","offset":{"end":0,"start":0}},{"offset":{"end":13,"start":0},"text":"A simple test"},{"interpretAs":"","markup":" ","offset":{"end":14,"start":13}}]}

@davidlday
Copy link
Owner

Hey! Thanks for opening an issue, and sorry about the long delay. Was on an extended vacation. I'll take a look as soon as I can.

@davidlday
Copy link
Owner

@chrillek - I'm unable to recreate the issue with either the Markdown document or "A simple test" in a plain text file. I'm running LT v5.8 via podman locally.

Are you still experiencing issues?

@chrillek
Copy link
Author

chrillek commented Sep 21, 2022 via email

@chrillek
Copy link
Author

chrillek commented Oct 21, 2022 via email

@davidlday
Copy link
Owner

Thanks for uncovering this! I'll incorporate something to prevent this from happening to others.

@davidlday davidlday changed the title Using a local server (i.e. external) with a markdown document results in an error Trailing Slash in LT Server URL Causes 400 Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants