Permalink
Browse files

""

git-svn-id: https://erlyaws.svn.sourceforge.net/svnroot/erlyaws/trunk/yaws@248 9fbdc01b-0d2c-0410-bfb7-fb27d70d8b52
  • Loading branch information...
klacke committed Nov 5, 2002
1 parent 3f99508 commit 2b9f0087b59bf8e110ed4914cfe0d73a22423dcb
Showing with 44 additions and 1 deletion.
  1. +15 −0 man/yaws_api.5
  2. +29 −1 src/yaws_api.erl
View
@@ -286,6 +286,21 @@ a list of lists of \fI#sconf{}\fR records. Each sublist must
contain \fI#sconf{}\fR records with the same IP/Port listen address.
+
+.TP
+\fBurl_decode(Str)\fR
+Decode url-encoded string. A URL ncoded string is a string where
+all alfa numeric characters and the the character _ are preserved
+and all other characters are encode as "%XY" where X and Y are the
+hex values of the least respective most significat 4 bits in the 8 bit
+character.
+
+.TP
+\fBurl_encode(Str)\fR
+Url-encodes a string. All URLs in HTML documents must be URL encoded.
+
+
+
.SH RETURN VALUES from out/1
.PP
The out/1 function can return different values to control the behavior
View
@@ -24,7 +24,9 @@
-export([setcookie/2, setcookie/3, setcookie/4, setcookie/5]).
-export([pre_ssi_files/2, pre_ssi_string/1, pre_ssi_string/2,
htmlize/1, htmlize_char/1, f/2, fl/1]).
--export([find_cookie_val/2, secs/0, url_decode/1]).
+-export([find_cookie_val/2, secs/0,
+ url_decode/1,
+ url_encode/1]).
-export([get_line/1, mime_type/1]).
-export([stream_chunk_deliver/2, stream_chunk_end/1]).
-export([new_cookie_session/1,
@@ -678,6 +680,32 @@ url_decode([H|T]) ->
url_decode([]) ->
[].
+
+
+url_encode([H|T]) ->
+ if
+ H =< $a, $z =< H ->
+ [H|url_decode(T)];
+ H =< $A, $Z =< H ->
+ [H|url_decode(T)];
+ H =< $1, $9 =< H ->
+ [H|url_decode(T)];
+ H == $_ ->
+ [H|url_decode(T)];
+ true ->
+ case yaws:integer_to_hex(H) of
+ [X, Y] ->
+ [$%, X, Y | url_decode(T)];
+ [X] ->
+ [$%, 0, X | url_decode(T)]
+ end
+ end;
+
+url_encode([]) ->
+ [].
+
+
+
redirect(Url) -> [{redirect, Url}].
is_nb_space(X) ->

0 comments on commit 2b9f008

Please sign in to comment.