Skip to content

Commit

Permalink
Merge pull request #54 from jjcomer/fix-escaping
Browse files Browse the repository at this point in the history
fix: revert to prior set of escape characters
  • Loading branch information
jjcomer authored Aug 20, 2020
2 parents 40e9756 + 714f0a7 commit ae85f26
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 23 deletions.
30 changes: 15 additions & 15 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ doc = false

[package]
name = 'hogan'
version = '0.8.4'
version = '0.8.5'
authors = [
'Jonathan Morley <[email protected]>',
'Josh Comer <[email protected]>',
Expand All @@ -15,7 +15,7 @@ edition = '2018'
[dependencies]
failure = '0.1'
lru_time_cache = '0.10'
handlebars = '3'
handlebars = '3.4'
itertools = '0.9'
json-patch = '0.2'
log = '0.4'
Expand Down
8 changes: 3 additions & 5 deletions src/app/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ fn open_sql_db(db_path: &str, read_only: bool) -> Result<Connection, Error> {
let read_flag = if read_only {
OpenFlags::SQLITE_OPEN_READ_ONLY
} else {
OpenFlags::SQLITE_OPEN_READ_WRITE
OpenFlags::SQLITE_OPEN_READ_WRITE | OpenFlags::SQLITE_OPEN_CREATE
};
let conn = Connection::open_with_flags(
db_path,
read_flag | OpenFlags::SQLITE_OPEN_CREATE | OpenFlags::SQLITE_OPEN_SHARED_CACHE,
)?;
let conn =
Connection::open_with_flags(db_path, read_flag | OpenFlags::SQLITE_OPEN_SHARED_CACHE)?;

if !read_only {
conn.execute(
Expand Down
18 changes: 17 additions & 1 deletion src/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ use self::helper_url_rm_path::UrlRmPathHelper;
use self::helper_url_rm_slash::UrlRmSlashHelper;
use self::helper_yaml_string::YamlStringHelper;

//This fn was changed here https://github.com/sunng87/handlebars-rust/pull/366 which added additional characters to the list
//To maintain backwards compatibility we are reverting to the original default escape fn
pub fn old_escape_html(s: &str) -> String {
let mut output = String::new();
for c in s.chars() {
match c {
'<' => output.push_str("&lt;"),
'>' => output.push_str("&gt;"),
'"' => output.push_str("&quot;"),
'&' => output.push_str("&amp;"),
_ => output.push(c),
}
}
output
}

pub fn handlebars<'a>(strict: bool) -> Handlebars<'a> {
let mut handlebars = Handlebars::new();
handlebars.set_strict_mode(strict);
Expand All @@ -30,7 +46,7 @@ pub fn handlebars<'a>(strict: bool) -> Handlebars<'a> {
handlebars.register_helper("url-rm-path", Box::new(UrlRmPathHelper));
handlebars.register_helper("url-rm-slash", Box::new(UrlRmSlashHelper));
handlebars.register_helper("yaml-string", Box::new(YamlStringHelper));

handlebars.register_escape_fn(old_escape_html);
handlebars
}

Expand Down

0 comments on commit ae85f26

Please sign in to comment.