From b5ecf9bd871462463365c2de193c3c5dc1e0bb50 Mon Sep 17 00:00:00 2001 From: Ciprian Dorin Craciun Date: Sun, 24 May 2020 20:45:37 +0300 Subject: Update `EscapeWriter` HTML implementation to not output empty strings --- askama_escape/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'askama_escape') 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(()) + } } } -- cgit