HTTP binding does not work with special characters inside the url

Currently I migrate my fenecon/openems binding setup to a pure rest api based setup. Its more flexible an I can access much more data… But that not the problem.

The problem is the http binding. The rest api of openems is supporting regex syntax as part of the url

e.g. http://192.168.100.67/rest/channel/.*/.* (/rest/channel//)

this means I fetch everything and it works.

now I try a different url like http://192.168.100.67/rest/channel/(_sum|ess0)/.*

If I open this inside my browser, it works.

If I try to open it with the http binding, the pipe symbol is quoted to “%7C” and this result in a 500 error from openems. On the openems side I can see that the requested url is “http://192.168.100.67/rest/channel/(_sum|ess0)/.*” and this is not working.

I think the problem is the toASCIIString call inside the http binding. Maybe there should be a config option like “urlencode=true” by default with the possibility to disable it.

I think there are other scenarios for other people as well.

Does it work if you escape the special characters with a backslash?

http://192.168.100.67/rest/channel/\(\_sum\|ess0\)/

no, the backslash is quoted as well.

the tracelogs of the binding are showing me that the url is handled correctly, until it hits the toASCIIString function inside the binding.

Tried with ‘ ‘?

I have something similar with a ‘&’ sign..

And I put the link in a variable before.

Greets

could you please post your config?

Ah sorry. I use this in a rule with executeCommandLine.

But try something like

http://192.168.100.67/rest/channel/'(_sum|ess0)/'.

Greets

thanks for ther hint, but does not work.

/rest/channel/'(_sum|ess0)'/.*

is encoded as

/rest/channel/'(_sum%7Cess0)'/.*

I had a similar issue when I needed to hash an http with an email address and needed to add

if (hash) {
                    // For hash generation, preserve + and @ characters in values.
                    encodedValue = encodedValue.replace("%2B", "+");
                    encodedValue = encodedValue.replace("%40", "@");
                }

because they hash differently than their standard character sets. Based on the code snippet you may need a PR to add an additional .replace(%7C, |), but I’m not an expert