SVN: nagios-notify/trunk/nagios-notify
glen
glen at pld-linux.org
Sat Oct 11 19:13:34 CEST 2008
Author: glen
Date: Sat Oct 11 19:13:34 2008
New Revision: 9902
Modified:
nagios-notify/trunk/nagios-notify
Log:
- implement $(urlencode:data)
Modified: nagios-notify/trunk/nagios-notify
==============================================================================
--- nagios-notify/trunk/nagios-notify (original)
+++ nagios-notify/trunk/nagios-notify Sat Oct 11 19:13:34 2008
@@ -53,6 +53,29 @@
return "=?" charset "?b?" base64_string(data) "?="
}
+ # urlencode
+ function urlencode(data) {
+ split("1 2 3 4 5 6 7 8 9 a b c d e f", hextab, " ")
+ hextab[0] = 0
+ for (i = 1; i <= 255; i++) {
+ ord[sprintf("%c", i) ""] = i + 0
+ }
+
+ n = length(data)
+ res = ""
+ for (i = 1; i <= n; i++) {
+ c = substr(data, i, 1);
+ if (!match(c, /[A-Za-z0-9._-]/)) {
+ lo = ord[c] % 16
+ hi = int(ord[c] / 16);
+ c = "%" hextab[hi] hextab[lo]
+ }
+ res = res c
+ }
+
+ return res
+ }
+
{
# replace environ variables
for (var in ENVIRON) {
@@ -82,6 +105,14 @@
data = substr(params, index(params, ",") + 1)
$0 = left encode_mime_header(charset, data) right;
}
+ # $(urlencode:data)
+ if (match($0, /\$\(urlencode:(.*)\)/)) {
+ pos = length("$(urlencode:")
+ data = substr($0, RSTART + pos, RLENGTH - pos - 1);
+ left = substr($0, 0, RSTART);
+ right = substr($0, RSTART + RLENGTH);
+ $0 = left urlencode(data) right;
+ }
# print out
print
More information about the pld-cvs-commit
mailing list