Skip to content

Commit

Permalink
filters: fix calendar filter parsing
Browse files Browse the repository at this point in the history
Fix parsing of colons. Since the field separator is also the colon, it
could mess up the parsed fields, i.e. a subject line like "WG: dinner"
could end up as "WG" instead of keeping the entire string.

Fixes: ab941eb ("filters: posix compliant rewrite of calendar filter")
Signed-off-by: Koni Marti <[email protected]>
Acked-by: Robin Jarry <[email protected]>
  • Loading branch information
konimarti authored and rjarry committed Aug 22, 2022
1 parent 132b5fe commit 0db924d
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions filters/calendar
Original file line number Diff line number Diff line change
Expand Up @@ -115,20 +115,24 @@ BEGIN {
}

/^UID/ {
id = $2
line = prepare($0)
id = line
}

/^STATUS/ {
status = $2
line = prepare($0)
status = line
}

/^DESCRIPTION/ {
entry = entry $2
line = prepare($0)
entry = entry line
indescription = 1;
}

/^SUMMARY/ {
summary = $2
line = prepare($0)
summary = line
insummary = 1;
}

Expand All @@ -138,7 +142,8 @@ BEGIN {
}

/^LOCATION/ {
location = unescape($2, 0);
line = prepare($0)
location = unescape(line, 0);
inlocation = 1;
}

Expand Down Expand Up @@ -187,6 +192,11 @@ BEGIN {
}
}

func prepare(line) {
gsub($1, "", line)
gsub(/^[: ]/, "", line)
return line
}

function unescape(input, preserve_newlines)
{
Expand Down Expand Up @@ -237,6 +247,7 @@ function add_attendee(attendee)
function find_full_name(line)
{
name = get_value(line, "CN=[^;:]+", "=")
gsub(/"[^"]*"/,"",line)
email = get_value(line, "(mailto|MAILTO):[^;]+", ":")

if (name == "") {
Expand Down

0 comments on commit 0db924d

Please sign in to comment.