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

[http] URL encoding #11920

Closed
moodyblue opened this issue Jan 1, 2022 · 2 comments
Closed

[http] URL encoding #11920

moodyblue opened this issue Jan 1, 2022 · 2 comments
Labels
bug An unexpected problem or unintended behavior of an add-on

Comments

@moodyblue
Copy link

moodyblue commented Jan 1, 2022

Expected Behavior

Sometimes it's necessary to assign values containning national characters to string items (and this works ok). The problem is that http binding is not URL encoding such characters, therefore linking them in string channels results in errors such as

2021-12-31 17:00:03.013 [WARN ] [p.internal.http.HttpResponseListener] - Requesting 'https://api.telegram.org/bot****/sendMessage?chat_id=*****&text=The%20following%20batteries%20need%20to%20be%20replaced:%20[Interruptor%20Portão%20Garagem:%2016.0%25]' (method='GET', content='null') failed: 400 Bad Request

In above message the national character ã should have been encoded by the binding. In fact, if a was used instead of ã the message is sent.

Current Behavior

Errors are produced in openhab.log when national characters are assigned to string channels.

Possible Solution

Steps to Reproduce (for Bugs)

Create a thing as follows:

UID: http:url:d52db6a46a
label: $Telegram
thingTypeUID: http:url
configuration:
  authMode: BASIC
  ignoreSSLErrors: false
  baseURL: https://api.telegram.org/bot***************************************
  delay: 0
  stateMethod: GET
  refresh: 30
  commandMethod: GET
  contentType: text/plain
  timeout: 3000
  bufferSize: 2048
channels:
  - id: message
    channelTypeUID: http:string
    label: Message
    description: ""
    configuration:
      mode: WRITEONLY
      commandExtension: /sendMessage?chat_id=*********&text=%2$s
  1. Link the message to a string item
  2. Assign a value to the string item not containning national characters -> no errors in log
  3. Assign a value to the string item containning national characters -> errors in log

Context

I am using the http binding for multiple purposes. In above case I'm using it instead of the telegram binding (I don't need to poll received messages, I only need to send occasional alerts and http binding is perfect for that).

Your Environment

  • Version used: 3.2.0
  • Environment name and version (e.g. Chrome 76, Java 8, Node.js 12.9, ...): QNAP NAS
  • Operating System and version (desktop or mobile, Windows 10, Raspbian Buster, ...): QTS 5, Java11 (Zulu)
@moodyblue moodyblue added the bug An unexpected problem or unintended behavior of an add-on label Jan 1, 2022
@openhab-bot
Copy link
Collaborator

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/http-binding-and-special-characters/130940/9

@lsiepel
Copy link
Contributor

lsiepel commented Jan 14, 2024

Fixed by: #16282

@lsiepel lsiepel closed this as completed Jan 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants