https://bugs.kde.org/show_bug.cgi?id=466930

James Graham <james.h.gra...@protonmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Latest Commit|https://invent.kde.org/netw |https://invent.kde.org/netw
                   |ork/neochat/commit/f6ba4f2e |ork/neochat/commit/da1c664f
                   |cd470487f1133a5704590860597 |941b96d650e64240253ba09f46e
                   |50775                       |d291a

--- Comment #4 from James Graham <james.h.gra...@protonmail.com> ---
Git commit da1c664f941b96d650e64240253ba09f46ed291a by James Graham.
Committed on 13/03/2023 at 18:18.
Pushed by nvrwhere into branch 'release/23.04'.

Cherrypick Improve Text Handling to 23.04

Improve the handling of text both when sending and receiving.

The main feature is to fix the linked bug (and a host of others that are
unreported but similar) which is caused by the fact that we don't properly
clean html. This mr does that as per the matrix spec
https://spec.matrix.org/v1.5/client-server-api/#mroommessage-msgtypes. So any
disallowed tags or attributes are removed and it does the special handling for
certain attributes.

Additionally the functions are also designed to cover any other text formatting
required, particularly fro received strings.

The receive side is covered by 2 functions `handleRecieveRichText` and
`handleRecievePlainText`. The rich/plain in the function name refers to the
output type not the input type (both can take plain and rich input), so
`handleRecieveRichText` is called to get a string suitable to go in a rich text
control and `handleRecievePlainText` for a plain control.

The functions also handle the following some of which was previously handled by
`eventToString` in `NeoChatRoom`:
- Strip and reply from the string
- Format any user mentions
- Linkify links in plain strings
- Handle mxc urls in rich text (uses the new `room->makeMediaUrl` functionality
from libQuotient)
- `handleRecievePlainText` also deals with markup making
`NeoChatRoom->subtitle` redundant

There is also an extensive test suite which defines the behaviour and the best
way to review this is probably to look at the tests and decide whether you
agree with the expected output given the inputs and/or if there is any missing
behaviour.

The final aim especially with the test suite is to give us a framework to make
further updates in the future easier and hopefully prevent a new feature
breaking old behaviour with the tests.
Related: bug 463932, bug 466330


(cherry picked from commit f6ba4f2ecd470487f1133a570459086059750775)

M  +6    -0    autotests/CMakeLists.txt
M  +1    -1    autotests/neochatroomtest.cpp
A  +482  -0    autotests/texthandlertest.cpp     [License: GPL(3+eV) GPL(v3.0)
GPL(v2.0)]
M  +1    -1    src/CMakeLists.txt
M  +5    -17   src/actionshandler.cpp
M  +0    -2    src/actionshandler.h
M  +0    -1    src/models/messageeventmodel.cpp
M  +1    -1    src/models/roomlistmodel.cpp
M  +28   -76   src/neochatroom.cpp
M  +2    -8    src/neochatroom.h
M  +4    -2    src/notificationsmanager.cpp
M  +2    -19   src/qml/Component/Timeline/RichLabel.qml
A  +378  -0    src/texthandler.cpp     [License: GPL(3+eV) GPL(v3.0) GPL(v2.0)]
A  +131  -0    src/texthandler.h     [License: GPL(3+eV) GPL(v3.0) GPL(v2.0)]
D  +0    -4    src/utils.cpp
D  +0    -16   src/utils.h

https://invent.kde.org/network/neochat/commit/da1c664f941b96d650e64240253ba09f46ed291a

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to