Roxen.git
/
server
/
etc
/
modules
/
Roxen.pmod
version
»
Context lines:
10
20
40
80
file
none
3
Roxen.git/server/etc/modules/Roxen.pmod:1:
-
// This is a roxen pike module. Copyright © 1999 -
2000
, Roxen IS.
+
// This is a roxen pike module. Copyright © 1999 -
2001
, Roxen IS.
//
-
// $Id: Roxen.pmod,v 1.
122
2001/09/
10
15
:
26
:
38
nilsson Exp $
+
// $Id: Roxen.pmod,v 1.
123
2001/09/
13
00
:
33
:
22
nilsson Exp $
#include <roxen.h> #include <config.h> #include <version.h> #include <module.h> #include <variables.h> #include <stat.h> #define roxen roxenp() #ifdef HTTP_DEBUG
Roxen.git/server/etc/modules/Roxen.pmod:475:
string http_encode_url (string f) //! Encodes any string to be used as a literal in a URL. This means //! that in addition to the characters encoded by //! @[http_encode_string], it encodes all URL special characters, i.e. //! /, #, ?, & etc. { return replace (f, ({"\000", " ", "\t", "\n", "\r", "%", "'", "\"", "#", "&", "?", "=", "/", ":", "+"}), ({"%00", "%20", "%09", "%0a", "%0d", "%25", "%27", "%22", "%23", "%26", "%3f", "%3d", "%2f", "%3a", "%2b"}));
+
}
-
+
//! Encodes any string to be used as a literal in a URL. This function
+
//! quotes all reserved and forbidden characters, including eight bit
+
//! characters. If the string is a wide string a UTF-8 conversion is
+
//! made.
+
string correctly_http_encode_url(string f) {
+
if(String.width(f)>8)
+
f = string_to_utf8(f);
+
return map(f/1, lambda(string in) {
+
int c = in[0];
+
// if(c>255) return sprintf("%%u%04x", c);
+
if( c<33 || c>126 ||
+
(< '"', '#', '%', '&', '\'', '+',
+
'<', '>', '?', '/', ':', ';',
+
'@', ',', '$', '=' >)[c] )
+
return sprintf("%%%02x", c);
+
return in;
+
} ) * "";
+
}
+
string add_pre_state( string url, multiset state ) //! Adds the provided states as prestates to the provided url. { if(!url) error("URL needed for add_pre_state()\n"); if(!state || !sizeof(state)) return url; string base; if (sscanf (url, "%s://%[^/]%s", base, string host, url) == 3) base += "://" + host;
Roxen.git/server/etc/modules/Roxen.pmod:1711:
case "http": return http_encode_string (val); case "cookie": return http_encode_cookie (val); case "url": return http_encode_url (val);
+
case "wml-url":
+
return correctly_http_encode_url(val);
+
case "html": return html_encode_string (val);
-
+
case "wml":
+
return replace(html_encode_string(val), "$", "$$");
+
case "dtag": // This is left for compatibility... return replace (val, "\"", "\"'\"'\""); case "stag": // This is left for compatibility return replace(val, "'", "'\"'\"'"); case "pike": return replace (val,