Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
ximper-shell-notification-center
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
ximper-shell-notification-center
Commits
19beafa5
Commit
19beafa5
authored
May 08, 2022
by
Erik Reider
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some markup characters not being unescaped
parent
ec01b493
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
notification.vala
src/notification/notification.vala
+16
-2
No files found.
src/notification/notification.vala
View file @
19beafa5
...
...
@@ -58,7 +58,15 @@ namespace SwayNotificationCenter {
private
static
Regex
tag_regex
;
private
static
Regex
tag_replace_regex
;
private
static
Regex
tag_unescape_regex
;
private
const
string
[]
TAGS
=
{
"b"
,
"u"
,
"i"
};
private
const
string
[]
UNESCAPE_CHARS
=
{
"lt;"
,
"#60;"
,
"#x3C;"
,
"#x3c;"
,
// <
"gt;"
,
"#62;"
,
"#x3E;"
,
"#x3e;"
,
// >
"apos;"
,
"#39;"
,
// '
"quot;"
,
"#34;"
,
// "
"amp;"
// &
};
private
Notification
()
{}
...
...
@@ -89,6 +97,8 @@ namespace SwayNotificationCenter {
string
joined_tags
=
string
.
joinv
(
"|"
,
TAGS
);
tag_regex
=
new
Regex
(
"</?(%s)>"
.
printf
(
joined_tags
));
tag_replace_regex
=
new
Regex
(
"</?|>"
);
string
unescaped
=
string
.
joinv
(
"|"
,
UNESCAPE_CHARS
);
tag_unescape_regex
=
new
Regex
(
"&(?=%s)"
.
printf
(
unescaped
));
}
catch
(
Error
e
)
{
stderr
.
printf
(
"Invalid regex: %s"
,
e
.
message
);
}
...
...
@@ -255,6 +265,10 @@ namespace SwayNotificationCenter {
0
,
RegexMatchFlags
.
NOTEMPTY
,
this
.
regex_tag_eval_cb
);
// Unescape a few characters that may have been double escaped
// Sending "<" in Discord would result in "&lt;" without this
// &lt; -> <
escaped
=
tag_unescape_regex
.
replace_literal
(
escaped
,
escaped
.
length
,
0
,
"&"
);
// Turns it back to markdown, defaults to original if not valid
Pango
.
AttrList
?
attr
=
null
;
...
...
@@ -316,10 +330,10 @@ namespace SwayNotificationCenter {
private
void
set_style_urgency
()
{
switch
(
param
.
urgency
)
{
case
UrgencyLevels
.
LOW
:
case
UrgencyLevels
.
LOW
:
base_box
.
get_style_context
().
add_class
(
"low"
);
break
;
case
UrgencyLevels
.
NORMAL
:
case
UrgencyLevels
.
NORMAL
:
default
:
base_box
.
get_style_context
().
add_class
(
"normal"
);
break
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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