changeset 2546:6e4494772328

mod_firewall: Add stripslashes() function
author Matthew Wild <mwild1@gmail.com>
date Thu, 23 Feb 2017 13:57:48 +0000
parents 9b46d24edf0d
children eb4f45bd7fef
files mod_firewall/mod_firewall.lua
diffstat 1 files changed, 8 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mod_firewall/mod_firewall.lua	Tue Feb 21 22:41:58 2017 +0000
+++ b/mod_firewall/mod_firewall.lua	Thu Feb 23 13:57:48 2017 +0000
@@ -125,6 +125,14 @@
 		:gsub([[%.%.""$]], ""));
 end
 
+local escape_chars = {
+	a = "\a", b = "\b", f = "\f", n = "\n", r = "\r", t = "\t",
+	v = "\v", ["\\"] = "\\", ["\""] = "\"", ["\'"] = "\'"
+};
+function stripslashes(s)
+	return (s:gsub("\\(.)", escape_chars));
+end
+
 -- Dependency locations:
 -- <type lib>
 -- <type global>