diff options
author | Ciprian Dorin Craciun <ciprian@volution.ro> | 2020-05-24 20:45:37 +0300 |
---|---|---|
committer | Dirkjan Ochtman <dirkjan@ochtman.nl> | 2020-05-24 20:06:44 +0200 |
commit | b5ecf9bd871462463365c2de193c3c5dc1e0bb50 (patch) | |
tree | 6dedfcc51f07087894192192140633912b0356bd | |
parent | b5a6a34bdd642ea2d89f984fb50f4371365c9b93 (diff) | |
download | askama-b5ecf9bd871462463365c2de193c3c5dc1e0bb50.tar.gz askama-b5ecf9bd871462463365c2de193c3c5dc1e0bb50.tar.bz2 askama-b5ecf9bd871462463365c2de193c3c5dc1e0bb50.zip |
Update `EscapeWriter` HTML implementation to not output empty strings
-rw-r--r-- | askama_escape/src/lib.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/askama_escape/src/lib.rs b/askama_escape/src/lib.rs index 2771507..0222277 100644 --- a/askama_escape/src/lib.rs +++ b/askama_escape/src/lib.rs @@ -129,7 +129,11 @@ impl Escaper for Html { } } } - fmt.write_str(unsafe { str::from_utf8_unchecked(&bytes[start..]) }) + if start < bytes.len() { + fmt.write_str(unsafe { str::from_utf8_unchecked(&bytes[start..]) }) + } else { + Ok(()) + } } } |