Skip to content
This repository was archived by the owner on Sep 27, 2022. It is now read-only.

Commit 215363b

Browse files
committed
Escape all labels
1 parent cc6a1fe commit 215363b

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "timer-for-harvest"
33
description = "Timer for Harvest"
44
homepage = "https://github.com/frenkel/timer-for-harvest"
5-
version = "0.3.5"
5+
version = "0.3.6"
66
authors = ["Frank Groeneveld <frank@frankgroeneveld.nl>"]
77
edition = "2018"
88
readme = "README.md"

src/lib.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -557,16 +557,23 @@ pub fn parse_account_details(request: &str) -> (String, String, String) {
557557
)
558558
}
559559

560+
pub fn escape_html(subject: &str) -> String {
561+
subject
562+
.replace("&", "&amp;")
563+
.replace("<", "&lt;")
564+
.replace(">", "&gt;")
565+
.replace("\"", "&quot;")
566+
.replace("'", "&#x27;")
567+
.replace("`", "&#x60;")
568+
}
569+
560570
pub fn format_timeentry_notes_for_list(n: &str, length: Option<usize>) -> std::string::String {
561571
let take: usize = match length {
562572
Some(value) => value,
563573
None => 80,
564574
};
565575

566-
let formatted: String = n
567-
.replace("&", "&amp;")
568-
.replace("<", "&lt;")
569-
.replace(">", "&gt;")
576+
let formatted: String = escape_html(n)
570577
.replace("\n\n", "\n")
571578
.replace("\n", " - ")
572579
.chars()

src/ui.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,9 @@ impl Ui {
289289

290290
let project_client = format!(
291291
"<b>{}</b> ({})\n{} - {}",
292-
&time_entry.project.name_and_code(),
293-
&time_entry.client.name,
294-
&time_entry.task.name,
292+
&escape_html(&time_entry.project.name_and_code()),
293+
&escape_html(&time_entry.client.name),
294+
&escape_html(&time_entry.task.name),
295295
&notes
296296
);
297297
let project_label = gtk::Label::new(Some(&project_client));

0 commit comments

Comments
 (0)