webmcp
view framework/env/encode/url_part.lua @ 27:1da1078a87b1
fix crash on eglibc
compiling without _GNU_SOURCE causes extos to crash on crypt as the return pointer is invalid.
compiling without _GNU_SOURCE causes extos to crash on crypt as the return pointer is invalid.
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Wed Sep 15 02:43:06 2010 +0200 (2010-09-15) |
parents | 9fdfb27f8e67 |
children |
line source
1 --[[--
2 url_encoded_string = -- URL-encoded string
3 encode.url_part(
4 obj -- any native datatype or atom
5 )
7 This function encodes any native datatype or atom in a way that it can be placed inside an URL. It is first dumped with atom.dump(...) and then url-encoded.
9 --]]--
11 function encode.url_part(obj)
12 return (
13 string.gsub(
14 atom.dump(obj),
15 "[^0-9A-Za-z_%.~-]",
16 function (char)
17 return string.format("%%%02x", string.byte(char))
18 end
19 )
20 )
21 end