Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Plasma
Plasma Workspace
Commits
9a35dcd5
Commit
9a35dcd5
authored
Mar 24, 2022
by
Nicolas Fella
Browse files
[libnotificationmanager] Don't recreate same regex all the time
We have better things to do
parent
5c3976d5
Pipeline
#154776
passed with stage
in 5 minutes and 53 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
libnotificationmanager/notification.cpp
View file @
9a35dcd5
...
...
@@ -41,11 +41,13 @@ QString Notification::Private::sanitize(const QString &text)
// Finally, check if we don't have multiple <br/>s following,
// can happen for example when "\n \n" is sent, this replaces
// all <br/>s in succession with just one
t
.
replace
(
QRegularExpression
(
QStringLiteral
(
"<br/>
\\
s*<br/>(
\\
s|<br/>)*"
)),
QLatin1String
(
"<br/>"
));
static
const
QRegularExpression
brExpr
(
QStringLiteral
(
"<br/>
\\
s*<br/>(
\\
s|<br/>)*"
));
t
.
replace
(
brExpr
,
QLatin1String
(
"<br/>"
));
// This fancy RegExp escapes every occurrence of & since QtQuick Text will blatantly cut off
// text where it finds a stray ampersand.
// Only &{apos, quot, gt, lt, amp}; as well as { character references will be allowed
t
.
replace
(
QRegularExpression
(
QStringLiteral
(
"&(?!(?:apos|quot|[gl]t|amp);|#)"
)),
QLatin1String
(
"&"
));
static
const
QRegularExpression
escapeExpr
(
QStringLiteral
(
"&(?!(?:apos|quot|[gl]t|amp);|#)"
));
t
.
replace
(
escapeExpr
,
QLatin1String
(
"&"
));
// Don't bother adding some HTML structure if the body is now empty
if
(
t
.
isEmpty
())
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment