ioBroker / ioBroker.rest-api

Swagger UI for ioBroker
Apache License 2.0
12 stars 8 forks source link

`/command/setState` crashes Adapter, when state contains an url encoded '%' sign #84

Open nokxs opened 9 months ago

nokxs commented 9 months ago

Describe the bug
When setting the value of a state with the GET command /command/setState and the value contains an url encoded '%' sign (%25), then the whole adapter crashes.

To Reproduce
Execute curl -X 'GET' 'http://iobroker.lan:8093/v1/command/setState?id=0_userdata.0.test&state=100%25' -H 'accept: application/json'

Expected behavior
The value of the state 0_userdata.0.test contains 100%

Screenshots & Logfiles
Exception in ioBroker log:

rest-api.0 | 2024-02-16 14:02:42.530 | error | URI malformed
rest-api.0 | 2024-02-16 14:02:42.530 | error | URIError: URI malformed at decodeURIComponent (<anonymous>) at parseQuery (/opt/iobroker/node_modules/iobroker.rest-api/lib/rest-api.js:57:73) at /opt/iobroker/node_modules/iobroker.rest-api/lib/rest-api.js:838:26 at Layer.handle [as handle_request] (/opt/iobroker/node_modules/express/lib/router/layer.js:95:5) at trim_prefix (/opt/iobroker/node_modules/express/lib/router/index.js:328:13) at /opt/iobroker/node_modules/express/lib/router/index.js:286:9 at param (/opt/iobroker/node_modules/express/lib/router/index.js:365:14) at param (/opt/iobroker/node_modules/express/lib/router/index.js:376:14) at Function.process_params (/opt/iobroker/node_modules/express/lib/router/index.js:421:3) at next (/opt/iobroker/node_modules/express/lib/router/index.js:280:10)
rest-api.0 | 2024-02-16 14:02:42.529 | error | unhandled promise rejection: URI malformed
rest-api.0 | 2024-02-16 14:02:42.529 | error | Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().

Versions: