Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ All notable changes to eww will be listed here, starting at changes since versio
- Add `value-pos` to scale widget (By: ipsvn)
- Add `floor` and `ceil` function calls to simplexpr (By: wsbankenstein)
- Add `formatbytes` function calls to simplexpr (By: topongo)
- Add proper escaping for string literals (By: netfri25)

## [0.6.0] (21.04.2024)

Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion crates/eww/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,5 @@ simple-signal.workspace = true
sysinfo = { workspace = true }
tokio-util.workspace = true
tokio = { workspace = true, features = ["full"] }
unescape.workspace = true
wait-timeout.workspace = true
zbus = { workspace = true, default-features = false, features = ["tokio"] }
1 change: 0 additions & 1 deletion crates/eww/src/widgets/widget_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,6 @@ fn build_gtk_label(bargs: &mut BuilderArgs) -> Result<gtk::Label> {
}
};

let text = unescape::unescape(&text).context(format!("Failed to unescape label text {}", &text))?;
let text = if unindent { util::unindent(&text) } else { text };
gtk_widget.set_text(&text);
},
Expand Down
1 change: 1 addition & 0 deletions crates/simplexpr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static_assertions.workspace = true
strsim.workspace = true
strum = { workspace = true, features = ["derive"] }
thiserror.workspace = true
unescape.workspace = true


[build-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions crates/simplexpr/src/parser/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ macro_rules! regex_rules {
}
}

static ESCAPE_REPLACE_REGEX: Lazy<regex::Regex> = Lazy::new(|| Regex::new(r"\\(.)").unwrap());
pub static STR_INTERPOLATION_START: &str = "${";
pub static STR_INTERPOLATION_END: &str = "}";

Expand Down Expand Up @@ -223,7 +222,8 @@ impl<'s> Lexer<'s> {

let segment_ender = self.advance_until_unescaped_one_of(&[STR_INTERPOLATION_START, &quote])?;
let lit_content = &self.source[segment_start + quote.len()..self.pos - segment_ender.len()];
let lit_content = ESCAPE_REPLACE_REGEX.replace_all(lit_content, "$1").to_string();
// will return the original string on any unescaping failure
let lit_content = unescape::unescape(lit_content).unwrap_or_else(|| lit_content.to_string());
elements.push((segment_start + self.offset, StrLitSegment::Literal(lit_content), self.pos + self.offset));

if segment_ender == STR_INTERPOLATION_START {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/expression_language.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Supported currently are the following features:
not an object or an array.
(`Number` or `String`).
- conditionals (`condition ? 'value' : 'other value'`)
- numbers, strings, booleans and variable references (`12`, `'hi'`, `true`, `some_variable`)
- numbers, strings (with support to escaping), booleans and variable references (`12`, `'hi'`, `true`, `some_variable`)
- json access (`object.field`, `array[12]`, `object["field"]`)
- for this, the object/array value needs to refer to a variable that contains a valid json string.
- some function calls:
Expand Down