From d3c2a37281dcca53f823094406e3c59b1947688f Mon Sep 17 00:00:00 2001 From: Jason Woofenden Date: Sat, 23 Jan 2016 14:09:53 -0500 Subject: [PATCH] html serialization: implement attr encoding --- editor.coffee | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/editor.coffee b/editor.coffee index b608e6b..c01a2b1 100644 --- a/editor.coffee +++ b/editor.coffee @@ -15,9 +15,12 @@ # along with this program. If not, see . # encode text so it can be safely placed inside an html attribute +enc_attr_regex = new RegExp '(&)|(")|(\u00A0)', 'g' enc_attr = (txt) -> - # FIXME implement - return txt + return txt.replace enc_attr_regex, (match, amp, quote) -> + return '&' if (amp) + return '"' if (quote) + return ' ' void_elements = { area: true -- 1.7.10.4