openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.71k forks source link

[http] http binding incorrectly decodes url when url contains encoded colon #5940

Closed Dem72 closed 4 years ago

Dem72 commented 4 years ago

Expected Behavior

I need to use the url such http://192.168.88.247/sec/?pt=6&cmd=6A:1 for switch item On
http://192.168.88.247/sec/?pt=6&cmd=6A:0 for switch item On
My http.items case1

Switch MySwitch1 { http=">[ON:GET:'http://192.168.88.247/sec/?pt=6&cmd=6A:1'] >[OFF:GET:http://192.168.88.247/sec/?pt=6&cmd=6A:0]" }

It doesn't work because this gets cut off at the colon after the cmd=6A because colon character is used as delimiter in item describing for http binding

[DEBUG] [ab.binding.http.internal.HttpBinding] - Executing url 'h_ttp://192.168.88.247/sec/?pt=6&cmd=6A' via method GET

This issue was solved here: https://community.openhab.org/t/colon-in-http-binding/26516

I try http.items case2

Switch MySwitch1 { http=">[ON:GET:http://192.168.88.247/sec/?pt=6&cmd=6A%%3A1] >[OFF:GET:http://192.168.88.247/sec/?pt=6&cmd=6A%%3A0]" }

or http.items case3 Switch MySwitch1 { http=">[ON:GET:http://192.168.88.247/sec/?pt=6&cmd=6A%3A1] >[OFF:GET:http://192.168.88.247/sec/?pt=6&cmd=6A%3A0]" }

I expect to get url string on device such http://192.168.88.247/sec/?pt=6&cmd=6A:1

Current Behavior

I get url without decoding, in the same encoded form. case2 case3 I asked the community. https://community.openhab.org/t/colon-in-http-binding/92885

Possible Solution

  1. implement colon escaping
  2. fix url-decode function

Steps to Reproduce (for bugs)

  1. Create http.items with record as above (with IP-address of existing http server)
  2. Execute the url
  3. Run tcpdump for capture packets
  4. Watch captured url

Context

I have need to manage controllers that are controlled by http-get requests. These queries include the colon character.

Your Environment

9037568 commented 4 years ago

You can probably get your URL to work by setting the format parameter to FALSE. See this community forum thread.

But at any rate, no changes will be made to the binding, as this repository is closed.

Dem72 commented 4 years ago

The format parameter has already been set to FALSE in http.cfg. So, then there is no solution for this bug. It's a pity :(

9037568 commented 4 years ago

You should try using the new http action provided in OH2.