girc icon indicating copy to clipboard operation
girc copied to clipboard

bug: newlines are removed instead of changed to a space

Open half-duplex opened this issue 2 years ago • 2 comments

🌧 Describe the problem

When calling Cmd.Message() with a message containing a newline, the newline is stripped, which smashes words together.

⛅ Expected behavior

The newline should be replaced with a space, instead of just stripped

🔄 Minimal reproduction

Call Cmd.Message("#foo", "example\nmessage") and observe that the resulting message is "examplemessage" instead of "example message"

💠 Version: girc

v0.0.0-20220410132120-49de39aea653

🖥 Version: Operating system

linux/other

⚙ Additional context

I'm using girc via https://github.com/RITlug/teleirc . When a telegram message contains a newline, the resulting IRC message has this problem. It could be worked around in TeleIRC, but it seemed like girc would be a better place to fix it for everyone.

I'm not sure the best way to handle \r or \r\n - ideally collapsing runs of either to just one space?

🤝 Requirements

  • [X] I believe the problem I'm facing is a bug, and is not intended behavior. Post here if you're not sure.
  • [X] I have confirmed that someone else has not submitted a similar bug report.

half-duplex avatar Apr 26 '22 03:04 half-duplex

I do think replacing newlines with spaces is a sufficient short-term solution, but I may finally start taking a look at #43, as that'd also resolve this. I'll try and take a look later today.

lrstanley avatar Apr 26 '22 21:04 lrstanley

Thanks! Another option, though this one may be better implemented by applications than girc: sopel-twitter replaces newlines with " ⏎ "

half-duplex avatar Apr 26 '22 21:04 half-duplex

Should be implemented via https://github.com/lrstanley/girc/pull/43 -- let me know if you have any further issues.

lrstanley avatar May 03 '23 02:05 lrstanley