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
7a82c82e
Commit
7a82c82e
authored
Sep 22, 2022
by
Erik Reider
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed GLib2.74.0 causing a segfault. Fixes: #164
parent
5972ecb5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
6 deletions
+4
-6
notification.vala
src/notification/notification.vala
+4
-6
No files found.
src/notification/notification.vala
View file @
7a82c82e
...
@@ -67,6 +67,7 @@ namespace SwayNotificationCenter {
...
@@ -67,6 +67,7 @@ namespace SwayNotificationCenter {
private
static
Regex
tag_regex
;
private
static
Regex
tag_regex
;
private
static
Regex
tag_unescape_regex
;
private
static
Regex
tag_unescape_regex
;
private
static
Regex
img_tag_regex
;
private
const
string
[]
TAGS
=
{
"b"
,
"u"
,
"i"
};
private
const
string
[]
TAGS
=
{
"b"
,
"u"
,
"i"
};
private
const
string
[]
UNESCAPE_CHARS
=
{
private
const
string
[]
UNESCAPE_CHARS
=
{
"lt;"
,
"#60;"
,
"#x3C;"
,
"#x3c;"
,
// <
"lt;"
,
"#60;"
,
"#x3C;"
,
"#x3c;"
,
// <
...
@@ -106,6 +107,7 @@ namespace SwayNotificationCenter {
...
@@ -106,6 +107,7 @@ namespace SwayNotificationCenter {
tag_regex
=
new
Regex
(
"<(/?(?:%s))>"
.
printf
(
joined_tags
));
tag_regex
=
new
Regex
(
"<(/?(?:%s))>"
.
printf
(
joined_tags
));
string
unescaped
=
string
.
joinv
(
"|"
,
UNESCAPE_CHARS
);
string
unescaped
=
string
.
joinv
(
"|"
,
UNESCAPE_CHARS
);
tag_unescape_regex
=
new
Regex
(
"&(?=%s)"
.
printf
(
unescaped
));
tag_unescape_regex
=
new
Regex
(
"&(?=%s)"
.
printf
(
unescaped
));
img_tag_regex
=
new
Regex
(
"""<img[^>]* src=\"([^\"]*)\"[^>]*>"""
);
}
catch
(
Error
e
)
{
}
catch
(
Error
e
)
{
stderr
.
printf
(
"Invalid regex: %s"
,
e
.
message
);
stderr
.
printf
(
"Invalid regex: %s"
,
e
.
message
);
}
}
...
@@ -223,14 +225,10 @@ namespace SwayNotificationCenter {
...
@@ -223,14 +225,10 @@ namespace SwayNotificationCenter {
// Removes all image tags and adds them to an array
// Removes all image tags and adds them to an array
if
(
text
.
length
>
0
)
{
if
(
text
.
length
>
0
)
{
try
{
try
{
Regex
img_exp
=
new
Regex
(
"""<img[^>]* src=\"([^\"]*)\"[^>]*>"""
,
RegexCompileFlags
.
JAVASCRIPT_COMPAT
);
// Get src paths from images
// Get src paths from images
string
[]
img_paths
=
{};
string
[]
img_paths
=
{};
MatchInfo
info
;
MatchInfo
info
;
if
(
img_
exp
.
match
(
text
,
0
,
out
info
))
{
if
(
img_
tag_regex
.
match
(
text
,
0
,
out
info
))
{
img_paths
+=
Functions
.
get_match_from_info
(
info
);
img_paths
+=
Functions
.
get_match_from_info
(
info
);
while
(
info
.
next
())
{
while
(
info
.
next
())
{
img_paths
+=
Functions
.
get_match_from_info
(
info
);
img_paths
+=
Functions
.
get_match_from_info
(
info
);
...
@@ -238,7 +236,7 @@ namespace SwayNotificationCenter {
...
@@ -238,7 +236,7 @@ namespace SwayNotificationCenter {
}
}
// Remove all images
// Remove all images
text
=
img_
exp
.
replace
(
text
,
text
.
length
,
0
,
""
);
text
=
img_
tag_regex
.
replace
(
text
,
text
.
length
,
0
,
""
);
// Set the image if exists and is valid
// Set the image if exists and is valid
if
(
img_paths
.
length
>
0
)
{
if
(
img_paths
.
length
>
0
)
{
...
...
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