bitfocus / companion-module-generic-http

Generic HTTP module
MIT License
9 stars 19 forks source link

Parse escape characters in plain/text #38

Closed llamafilm closed 1 year ago

llamafilm commented 1 year ago

Is this a feature relevant to companion itself, and not a module?

Is there an existing issue for this?

Describe the feature

I'm trying to use the Generic HTTP module to prototype a controller for Riedel Fusion. I need to PUT text containing line breaks. I've tried several variations of \n and \r and quotation marks but I can't get it to work. Those escape characters are preserved literally, and if I paste a newline character into the field it gets turned into a space. I'm not exactly sure where that substitution is happening but I believe it's in Companion itself, not the module.

To verify what's happening, I used tcpdump to look at the raw data being sent and it looks like this:

10.49.54.187.33516 > 10.49.54.176.80: Flags [P.], cksum 0x82f1 (incorrect -> 0x37c6), seq 0:266, ack 1, win 64240, length 266: HTTP, length: 266
    POST /emsfp/node/v1/sdp/104f66a2-9910-11e5-8894-feff819cdc9f HTTP/1.1
    user-agent: got (https://github.com/sindresorhus/got)
    content-type: application/sdp
    content-length: 12
    accept-encoding: gzip, deflate, br
    Host: 10.49.54.176
    Connection: close

    line1\nline2[!http]

The last line should be 2 separate lines without the literal \n.

Usecases

SDP (session description protocol) requires parameters to be written in plain text on separate lines.

llamafilm commented 1 year ago

I think the issue is here:

https://github.com/bitfocus/companion/blob/725c3583417a06f6ea9239fa5c6e03775418b379/webui/src/Controls/OptionsInputField.jsx#LL33C2-L33C2

I think switching to CTextarea instead of CInput would allow for newlines.

dnmeid commented 1 year ago

This is not a problem of the variables, I transferred the issue here.