From b07f9f4fe82f3995be38a8230fe6e99d58ac8357 Mon Sep 17 00:00:00 2001 From: nuex Date: Fri, 2 Dec 2011 10:05:20 -0500 Subject: [PATCH] prevent awk from replacing ampersand's with matched text --- lib/render.awk | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/render.awk b/lib/render.awk index dca80ce..0035d47 100644 --- a/lib/render.awk +++ b/lib/render.awk @@ -58,7 +58,7 @@ action == "layout" { # replace yield with rendered content if (match($0, /{{{yield}}}/)) { - sub(/{{{yield}}}/, render_content(main)) + sub(/{{{yield}}}/, escape_special_chars(render_content(main))) } if (layout == "") { @@ -129,3 +129,9 @@ function run_filter(cmd, txt, rand_date, tmpfile, rendered_txt, date_cmd, filt return rendered_txt } + +# Prevent awk from replacing ampersand's with matched text +function escape_special_chars( txt) { + gsub(/&/, "\\\\&", txt) + return txt +}