From a72ace4b33a35dbf322372b781ee7797da0a225a Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 4 Jan 2010 16:19:26 +0000 Subject: Automatic conversion of octal escape sequences in NAPTR regular expressions. --- tinydns-edit-html.lsp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tinydns-edit-html.lsp b/tinydns-edit-html.lsp index da18048..19fdf25 100644 --- a/tinydns-edit-html.lsp +++ b/tinydns-edit-html.lsp @@ -36,6 +36,13 @@ entryTypes[12]=new Entry("S","Service location",8,"Domain Service", "IP address", "Server", "Port", "Weight", "Priority", "Time to live", "Timestamp"); entryTypes[13]=new Entry("N","Naming authority pointer",9,"Domain", "Order", "Preference", "Flags", "Service", "Regular expression", "Replacement", "Time to live", "Timestamp"); + function octal_to_char(val){ + return String.fromCharCode(parseInt(val.substring(1), 8)) + } + function char_to_octal(val){ + var code = "000" + val.charCodeAt(0).toString(8) + return "\\" + code.slice(-3) + } function finishForm(entry){ var entrytext = entry.find("select").val() + entry.find("input:not(.submit)").map(function(){ if (this.name == "fixme") { @@ -43,6 +50,8 @@ return $(this).val() + ".<%= html.html_escape(domain) %>"; else return "<%= html.html_escape(domain) %>"; + } else if (this.name == "convertme") { + return $(this).val().replace(/[\\:\r\n ]/g, char_to_octal); } else { return $(this).val(); } @@ -76,6 +85,8 @@ if (entries[i] === null) { entries[i] = ""; } if (entryType.descriptions[i] == "Domain" || entryType.descriptions[i] == "Alias" || entryType.descriptions[i] == "Host" || entryType.descriptions[i] == "Domain Service" ) form = form + '
' + entryType.descriptions[i] + '
$/i, "") + '" name="fixme"> . <%= html.html_escape(domain) %>
'; + else if (entryType.descriptions[i] == "Regular expression") + form = form + '
' + entryType.descriptions[i] + '
'; else form = form + '
' + entryType.descriptions[i] + '
'; } -- cgit v1.2.3