diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-06-12 22:02:21 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-06-12 22:02:21 +0000 |
| commit | 8b114f3bf4ccea3b065551fa94649a9e45935b5b (patch) | |
| tree | 06f2faa7e896e9434ba89ec68445ea56e6c8c6dc /src/mime.lua | |
| parent | b22f6f3830515a57a8776e7489b3e2d434abd12f (diff) | |
| download | luasocket-8b114f3bf4ccea3b065551fa94649a9e45935b5b.tar.gz luasocket-8b114f3bf4ccea3b065551fa94649a9e45935b5b.tar.bz2 luasocket-8b114f3bf4ccea3b065551fa94649a9e45935b5b.zip | |
Stupid bug in http.lua.
Diffstat (limited to 'src/mime.lua')
| -rw-r--r-- | src/mime.lua | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/mime.lua b/src/mime.lua index 6492a96..6ef82b8 100644 --- a/src/mime.lua +++ b/src/mime.lua | |||
| @@ -15,9 +15,9 @@ local mime = require("cmime") | |||
| 15 | module("mime") | 15 | module("mime") |
| 16 | 16 | ||
| 17 | -- encode, decode and wrap algorithm tables | 17 | -- encode, decode and wrap algorithm tables |
| 18 | mime.encodet = {} | 18 | encodet = {} |
| 19 | mime.decodet = {} | 19 | decodet = {} |
| 20 | mime.wrapt = {} | 20 | wrapt = {} |
| 21 | 21 | ||
| 22 | -- creates a function that chooses a filter by name from a given table | 22 | -- creates a function that chooses a filter by name from a given table |
| 23 | local function choose(table) | 23 | local function choose(table) |
| @@ -32,21 +32,21 @@ local function choose(table) | |||
| 32 | end | 32 | end |
| 33 | 33 | ||
| 34 | -- define the encoding filters | 34 | -- define the encoding filters |
| 35 | mime.encodet['base64'] = function() | 35 | encodet['base64'] = function() |
| 36 | return ltn12.filter.cycle(b64, "") | 36 | return ltn12.filter.cycle(b64, "") |
| 37 | end | 37 | end |
| 38 | 38 | ||
| 39 | mime.encodet['quoted-printable'] = function(mode) | 39 | encodet['quoted-printable'] = function(mode) |
| 40 | return ltn12.filter.cycle(qp, "", | 40 | return ltn12.filter.cycle(qp, "", |
| 41 | (mode == "binary") and "=0D=0A" or "\r\n") | 41 | (mode == "binary") and "=0D=0A" or "\r\n") |
| 42 | end | 42 | end |
| 43 | 43 | ||
| 44 | -- define the decoding filters | 44 | -- define the decoding filters |
| 45 | mime.decodet['base64'] = function() | 45 | decodet['base64'] = function() |
| 46 | return ltn12.filter.cycle(unb64, "") | 46 | return ltn12.filter.cycle(unb64, "") |
| 47 | end | 47 | end |
| 48 | 48 | ||
| 49 | mime.decodet['quoted-printable'] = function() | 49 | decodet['quoted-printable'] = function() |
| 50 | return ltn12.filter.cycle(unqp, "") | 50 | return ltn12.filter.cycle(unqp, "") |
| 51 | end | 51 | end |
| 52 | 52 | ||
| @@ -60,29 +60,29 @@ local function format(chunk) | |||
| 60 | end | 60 | end |
| 61 | 61 | ||
| 62 | -- define the line-wrap filters | 62 | -- define the line-wrap filters |
| 63 | mime.wrapt['text'] = function(length) | 63 | wrapt['text'] = function(length) |
| 64 | length = length or 76 | 64 | length = length or 76 |
| 65 | return ltn12.filter.cycle(wrp, length, length) | 65 | return ltn12.filter.cycle(wrp, length, length) |
| 66 | end | 66 | end |
| 67 | mime.wrapt['base64'] = wrapt['text'] | 67 | wrapt['base64'] = wrapt['text'] |
| 68 | mime.wrapt['default'] = wrapt['text'] | 68 | wrapt['default'] = wrapt['text'] |
| 69 | 69 | ||
| 70 | mime.wrapt['quoted-printable'] = function() | 70 | wrapt['quoted-printable'] = function() |
| 71 | return ltn12.filter.cycle(qpwrp, 76, 76) | 71 | return ltn12.filter.cycle(qpwrp, 76, 76) |
| 72 | end | 72 | end |
| 73 | 73 | ||
| 74 | -- function that choose the encoding, decoding or wrap algorithm | 74 | -- function that choose the encoding, decoding or wrap algorithm |
| 75 | mime.encode = choose(encodet) | 75 | encode = choose(encodet) |
| 76 | mime.decode = choose(decodet) | 76 | decode = choose(decodet) |
| 77 | mime.wrap = choose(wrapt) | 77 | wrap = choose(wrapt) |
| 78 | 78 | ||
| 79 | -- define the end-of-line normalization filter | 79 | -- define the end-of-line normalization filter |
| 80 | function mime.normalize(marker) | 80 | function normalize(marker) |
| 81 | return ltn12.filter.cycle(eol, 0, marker) | 81 | return ltn12.filter.cycle(eol, 0, marker) |
| 82 | end | 82 | end |
| 83 | 83 | ||
| 84 | -- high level stuffing filter | 84 | -- high level stuffing filter |
| 85 | function mime.stuff() | 85 | function stuff() |
| 86 | return ltn12.filter.cycle(dot, 2) | 86 | return ltn12.filter.cycle(dot, 2) |
| 87 | end | 87 | end |
| 88 | 88 | ||
