Bug 456905 - NeoChat generating duplicate newlines
Summary: NeoChat generating duplicate newlines
Status: RESOLVED FIXED
Alias: None
Product: NeoChat
Classification: Applications
Component: General (show other bugs)
Version: unspecified
Platform: Flatpak Linux
: NOR normal
Target Milestone: ---
Assignee: Tobias Fella
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-07-19 10:44 UTC by Jan Bidler
Modified: 2022-11-24 00:08 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Bidler 2022-07-19 10:44:26 UTC
SUMMARY
NeoChat is now duplicating newlines. 

STEPS TO REPRODUCE
1. Send something like the
```
A
newline
```

OBSERVED RESULT
formatted_body will have duplicate newlines: `neochat<br />\nnewline`

EXPECTED RESULT
formatted_body should have only one newline: `neochat\nnewline`

SOFTWARE/OS VERSIONS
Linux: Arch Linux
KDE Frameworks Version: 5.95.0
Qt Version: 5.15.5
NeoChat: 22.06
Comment 1 James Graham 2022-07-24 09:46:55 UTC
Actually this is correct behaviour. As mentioned on matrix \n in the formatted body represents a newline in the html not the message and a <br> tag represents a newline in the message.

Now what we have could be simplified to 'neochat<br>newline' but what is currently being sent is technically correct and will be rendered correctly, this is just how the library we use for markdown to html outputs a hard break. I don't think we should mess around and potentially break thing just to prettify the source.
Comment 2 Jan Bidler 2022-07-24 10:40:23 UTC
Hm, I initially encountered it, because I chat on a matrix<->discord bridge from neochat, and whenever I used newlines, they showed up as double newlines on discord. That led me to check Element and noticed that it doesn't generate <br> and \n .
I would find it nice if we'd prettify the source, because the \n don't really give any meaningful input in formatted_body, although this does seem like an issue on the bridge software for not ignoring the \n to begin with.
Comment 3 James Graham 2022-07-24 14:48:01 UTC
(In reply to Jan Bidler from comment #2)
> Hm, I initially encountered it, because I chat on a matrix<->discord bridge
> from neochat, and whenever I used newlines, they showed up as double
> newlines on discord. That led me to check Element and noticed that it
> doesn't generate <br> and \n .
> I would find it nice if we'd prettify the source, because the \n don't
> really give any meaningful input in formatted_body, although this does seem
> like an issue on the bridge software for not ignoring the \n to begin with.

It would be interesting to know if that is the bridge or discord that treats the /n as newlines in the formatted body. However if it's causing an actual issue we can put in a fix I don't see that as prettification. We shouldn't break compatibility where it isn't necessary.

It shouldn't be too hard to write a string replace to specifically target <br />/n and replace with <br>. We need to keep it specific though as when I used to replace all /n in the formatted body I broke quotes.
Comment 4 Bug Janitor Service 2022-07-29 18:26:58 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/neochat/-/merge_requests/492
Comment 5 Tobias Fella 2022-11-24 00:08:48 UTC
This seems to have been fixed