Bug 476731

Summary: Room preview: username height affects room avatar height, breaking layout
Product: [Applications] NeoChat Reporter: Austin Huang <im>
Component: GeneralAssignee: Tobias Fella <fella>
Status: RESOLVED WORKSFORME    
Severity: normal CC: carl, james.h.graham, josh
Priority: NOR    
Version First Reported In: 23.08.2   
Target Milestone: ---   
Platform: Arch Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: The extreme scenario where someone put linebreaks in their display name, severely breaking the layout
The usual scenario where one has emojis in display name

Description Austin Huang 2023-11-09 00:52:36 UTC
Created attachment 162961 [details]
The extreme scenario where someone put linebreaks in their display name, severely breaking the layout

SUMMARY
In a room preview, if the last author's display name has emojis or, in extreme cases, line breaks, then their display name would take more space vertically. The room preview does not seem to account for this, so if the display name's space is stretched, then it will also stretch the room icon on the left.

STEPS TO REPRODUCE
1. Be in a room where someone has a display name that either contains an emoji or line breaks.
2. Let them send the latest message.

OBSERVED RESULT
It stretches the entire space for that room's preview. Notably it stretches the room avatar.

EXPECTED RESULT
The space taken by each room is constant.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Arch ARM (Asahi Linux)
KDE Plasma Version: 5.27.9
KDE Frameworks Version: 5.111.0
Qt Version: 5.15.11

ADDITIONAL INFORMATION
Comment 1 Austin Huang 2023-11-09 00:52:59 UTC
Created attachment 162962 [details]
The usual scenario where one has emojis in display name
Comment 2 Tobias Fella 2023-11-11 23:55:42 UTC
do you know which character exactly is used as a linebreak here? for the usual candidates, this is already filtered out, so it's probably something more exotic, maybe unicode
Comment 3 Austin Huang 2023-11-12 00:31:04 UTC
Extracted from membership state events:

"Access forbidden!\n\nYou don't have permission to access the requested directory. There is either no index document or the directory is read-protected.\n\nIf you think this is a server error, please contact the webmaster.\nError 403\nlocalhost\nApache”

So it’s literally \n

> On Nov 11, 2023, at 18:55, Tobias Fella <bugzilla_noreply@kde.org> wrote:
> 
> https://bugs.kde.org/show_bug.cgi?id=476731
> 
> Tobias Fella <fella@posteo.de> changed:
> 
>           What    |Removed                     |Added
> ----------------------------------------------------------------------------
>             Status|REPORTED                    |NEEDSINFO
>         Resolution|---                         |WAITINGFORINFO
> 
> --- Comment #2 from Tobias Fella <fella@posteo.de> ---
> do you know which character exactly is used as a linebreak here? for the usual
> candidates, this is already filtered out, so it's probably something more
> exotic, maybe unicode
> 
> -- 
> You are receiving this mail because:
> You reported the bug.
Comment 4 James Graham 2023-11-12 16:40:48 UTC
OK so this is super weird I put the string you copied in as a test and as expected the newlines are successfully stripped from the topic so I have no idea why this is happening.

Since you seem to know how to get to the underlying event data are you able to copy me the entire JSON for the m.room.name and m.room.topic events for this room?
Comment 5 Austin Huang 2023-11-12 16:59:51 UTC
It’s a user display name, not a room topic/name.
Comment 6 James Graham 2023-11-12 17:51:15 UTC
(In reply to Austin Huang from comment #5)
> It’s a user display name, not a room topic/name.

Oh then that makes sense we don't sanitise those. But it looks like we need to and yes that would cause the issue seen.
Comment 7 Bug Janitor Service 2023-11-12 18:28:18 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/neochat/-/merge_requests/1438
Comment 8 Austin Huang 2023-11-12 18:45:43 UTC
But I also mentioned that putting some unicode characters also affect the height of the last author field in room previews. Element seems to just cut off the extra height for this. I don’t know if it’s my issue (sorry I’m new to Linux lol) of not installing a font, but fixing the height of the field could be considered.
Comment 9 James Graham 2023-11-12 18:46:07 UTC
Git commit 61ad8927325c8c994145c8611e7c26a8c4207f95 by James Graham.
Committed on 12/11/2023 at 19:46.
Pushed by nvrwhere into branch 'master'.

Handle multiple line names

Add function to get the display name for an author on a single line as nothing stops there being linebreaks.

M  +29   -0    autotests/data/test-eventhandler-sync.json
M  +19   -0    autotests/eventhandlertest.cpp
M  +22   -0    src/eventhandler.cpp
M  +11   -0    src/eventhandler.h
M  +1    -1    src/neochatroom.cpp

https://invent.kde.org/network/neochat/-/commit/61ad8927325c8c994145c8611e7c26a8c4207f95
Comment 10 James Graham 2023-11-12 19:03:02 UTC
(In reply to Austin Huang from comment #8)
> But I also mentioned that putting some unicode characters also affect the
> height of the last author field in room previews. Element seems to just cut
> off the extra height for this. I don’t know if it’s my issue (sorry I’m new
> to Linux lol) of not installing a font, but fixing the height of the field
> could be considered.

Do you have any examples of the other unicode characters as we just need to sanitize them as well?
Comment 11 Austin Huang 2023-11-12 19:14:59 UTC
Yes; see attachment 162962 [details], comment 1.
Comment 12 Joshua Goins 2025-05-15 18:13:07 UTC
This is fixed, correct? The last bug you mentioned should really be a separate ticket.
Comment 13 Bug Janitor Service 2025-05-30 03:48:11 UTC
🐛🧹 ⚠️ This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information, then set the bug status to REPORTED. If there is no change for at least 30 days, it will be automatically closed as RESOLVED WORKSFORME.

For more information about our bug triaging procedures, please read https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging.

Thank you for helping us make KDE software even better for everyone!
Comment 14 Bug Janitor Service 2025-06-14 03:47:59 UTC
🐛🧹 This bug has been in NEEDSINFO status with no change for at least 30 days. Closing as RESOLVED WORKSFORME.