diff options
| author | Caleb Maclennan <caleb@alerque.com> | 2023-11-10 09:12:04 +0300 |
|---|---|---|
| committer | Caleb Maclennan <caleb@alerque.com> | 2023-11-10 09:12:04 +0300 |
| commit | 5c4fc93d5f4137bf4c22ddf1a048c907a4a26727 (patch) | |
| tree | a9a68e1f6a9c3bfe2b64fa1c3a4098865b7d3b5d /docs/mime.html | |
| parent | ccef3bc4e2aa6ee5b997a80aabb58f4ff0b0e98f (diff) | |
| parent | 43a97b7f0053313b43906371dbdc226271e6c8ab (diff) | |
| download | luasocket-hjelmeland-patch-1.tar.gz luasocket-hjelmeland-patch-1.tar.bz2 luasocket-hjelmeland-patch-1.zip | |
Merge branch 'master' into hjelmeland-patch-1hjelmeland-patch-1
Diffstat (limited to '')
| -rw-r--r-- | docs/mime.html (renamed from doc/mime.html) | 339 |
1 files changed, 170 insertions, 169 deletions
diff --git a/doc/mime.html b/docs/mime.html index ae136fd..ff4d8e8 100644 --- a/doc/mime.html +++ b/docs/mime.html | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" | 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> | 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
| 3 | <html> | 3 | <html> |
| 4 | 4 | ||
| 5 | <head> | 5 | <head> |
| 6 | <meta name="description" content="LuaSocket: MIME support"> | 6 | <meta name="description" content="LuaSocket: MIME support"> |
| 7 | <meta name="keywords" content="Lua, LuaSocket, MIME, Library, Support"> | 7 | <meta name="keywords" content="Lua, LuaSocket, MIME, Library, Support"> |
| 8 | <title>LuaSocket: MIME module</title> | 8 | <title>LuaSocket: MIME module</title> |
| 9 | <link rel="stylesheet" href="reference.css" type="text/css"> | 9 | <link rel="stylesheet" href="reference.css" type="text/css"> |
| 10 | </head> | 10 | </head> |
| @@ -13,22 +13,22 @@ | |||
| 13 | 13 | ||
| 14 | <!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 14 | <!-- header +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 15 | 15 | ||
| 16 | <div class=header> | 16 | <div class="header"> |
| 17 | <hr> | 17 | <hr> |
| 18 | <center> | 18 | <center> |
| 19 | <table summary="LuaSocket logo"> | 19 | <table summary="LuaSocket logo"> |
| 20 | <tr><td align=center><a href="http://www.lua.org"> | 20 | <tr><td align="center"><a href="http://www.lua.org"> |
| 21 | <img width=128 height=128 border=0 alt="LuaSocket" src="luasocket.png"> | 21 | <img width="128" height="128" border="0" alt="LuaSocket" src="luasocket.png"> |
| 22 | </a></td></tr> | 22 | </a></td></tr> |
| 23 | <tr><td align=center valign=top>Network support for the Lua language | 23 | <tr><td align="center" valign="top">Network support for the Lua language |
| 24 | </td></tr> | 24 | </td></tr> |
| 25 | </table> | 25 | </table> |
| 26 | <p class=bar> | 26 | <p class="bar"> |
| 27 | <a href="index.html">home</a> · | 27 | <a href="index.html">home</a> · |
| 28 | <a href="index.html#download">download</a> · | 28 | <a href="index.html#download">download</a> · |
| 29 | <a href="installation.html">installation</a> · | 29 | <a href="installation.html">installation</a> · |
| 30 | <a href="introduction.html">introduction</a> · | 30 | <a href="introduction.html">introduction</a> · |
| 31 | <a href="reference.html">reference</a> | 31 | <a href="reference.html">reference</a> |
| 32 | </p> | 32 | </p> |
| 33 | </center> | 33 | </center> |
| 34 | <hr> | 34 | <hr> |
| @@ -36,14 +36,14 @@ | |||
| 36 | 36 | ||
| 37 | <!-- mime +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 37 | <!-- mime +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 38 | 38 | ||
| 39 | <h2 id=mime>MIME</h2> | 39 | <h2 id="mime">MIME</h2> |
| 40 | 40 | ||
| 41 | <p> | 41 | <p> |
| 42 | The <tt>mime</tt> namespace offers filters that apply and remove common | 42 | The <tt>mime</tt> namespace offers filters that apply and remove common |
| 43 | content transfer encodings, such as Base64 and Quoted-Printable. | 43 | content transfer encodings, such as Base64 and Quoted-Printable. |
| 44 | It also provides functions to break text into lines and change | 44 | It also provides functions to break text into lines and change |
| 45 | the end-of-line convention. | 45 | the end-of-line convention. |
| 46 | MIME is described mainly in | 46 | MIME is described mainly in |
| 47 | <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>, | 47 | <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>, |
| 48 | <a href="http://www.ietf.org/rfc/rfc2046.txt">2046</a>, | 48 | <a href="http://www.ietf.org/rfc/rfc2046.txt">2046</a>, |
| 49 | <a href="http://www.ietf.org/rfc/rfc2047.txt">2047</a>, | 49 | <a href="http://www.ietf.org/rfc/rfc2047.txt">2047</a>, |
| @@ -52,17 +52,17 @@ MIME is described mainly in | |||
| 52 | </p> | 52 | </p> |
| 53 | 53 | ||
| 54 | <p> | 54 | <p> |
| 55 | All functionality provided by the MIME module | 55 | All functionality provided by the MIME module |
| 56 | follows the ideas presented in | 56 | follows the ideas presented in |
| 57 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks"> | 57 | <a href="http://lua-users.org/wiki/FiltersSourcesAndSinks"> |
| 58 | LTN012, Filters sources and sinks</a>. | 58 | LTN012, Filters sources and sinks</a>. |
| 59 | </p> | 59 | </p> |
| 60 | 60 | ||
| 61 | <p> | 61 | <p> |
| 62 | To obtain the <tt>mime</tt> namespace, run: | 62 | To obtain the <tt>mime</tt> namespace, run: |
| 63 | </p> | 63 | </p> |
| 64 | 64 | ||
| 65 | <pre class=example> | 65 | <pre class="example"> |
| 66 | -- loads the MIME module and everything it requires | 66 | -- loads the MIME module and everything it requires |
| 67 | local mime = require("mime") | 67 | local mime = require("mime") |
| 68 | </pre> | 68 | </pre> |
| @@ -70,88 +70,60 @@ local mime = require("mime") | |||
| 70 | 70 | ||
| 71 | <!-- High-level +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 71 | <!-- High-level +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 72 | 72 | ||
| 73 | <h3 id=high>High-level filters</h3> | 73 | <h3 id="high">High-level filters</h3> |
| 74 | |||
| 75 | <!-- normalize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 76 | |||
| 77 | <p class=name id="normalize"> | ||
| 78 | mime.<b>normalize(</b>[marker]<b>)</b> | ||
| 79 | </p> | ||
| 80 | 74 | ||
| 81 | <p class=description> | ||
| 82 | Converts most common end-of-line markers to a specific given marker. | ||
| 83 | </p> | ||
| 84 | |||
| 85 | <p class=parameters> | ||
| 86 | <tt>Marker</tt> is the new marker. It defaults to CRLF, the canonic | ||
| 87 | end-of-line marker defined by the MIME standard. | ||
| 88 | </p> | ||
| 89 | |||
| 90 | <p class=return> | ||
| 91 | The function returns a filter that performs the conversion. | ||
| 92 | </p> | ||
| 93 | |||
| 94 | <p class=note> | ||
| 95 | Note: There is no perfect solution to this problem. Different end-of-line | ||
| 96 | markers are an evil that will probably plague developers forever. | ||
| 97 | This function, however, will work perfectly for text created with any of | ||
| 98 | the most common end-of-line markers, i.e. the Mac OS (CR), the Unix (LF), | ||
| 99 | or the DOS (CRLF) conventions. Even if the data has mixed end-of-line | ||
| 100 | markers, the function will still work well, although it doesn't | ||
| 101 | guarantee that the number of empty lines will be correct. | ||
| 102 | </p> | ||
| 103 | 75 | ||
| 104 | <!-- decode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 76 | <!-- decode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 105 | 77 | ||
| 106 | <p class=name id="decode"> | 78 | <p class="name" id="decode"> |
| 107 | mime.<b>decode(</b>"base64"<b>)</b><br> | 79 | mime.<b>decode(</b>"base64"<b>)</b><br> |
| 108 | mime.<b>decode(</b>"quoted-printable"<b>)</b> | 80 | mime.<b>decode(</b>"quoted-printable"<b>)</b> |
| 109 | </p> | 81 | </p> |
| 110 | 82 | ||
| 111 | <p class=description> | 83 | <p class="description"> |
| 112 | Returns a filter that decodes data from a given transfer content | 84 | Returns a filter that decodes data from a given transfer content |
| 113 | encoding. | 85 | encoding. |
| 114 | </p> | 86 | </p> |
| 115 | 87 | ||
| 116 | <!-- encode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 88 | <!-- encode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 117 | 89 | ||
| 118 | <p class=name id="encode"> | 90 | <p class="name" id="encode"> |
| 119 | mime.<b>encode(</b>"base64"<b>)</b><br> | 91 | mime.<b>encode(</b>"base64"<b>)</b><br> |
| 120 | mime.<b>encode(</b>"quoted-printable" [, mode]<b>)</b> | 92 | mime.<b>encode(</b>"quoted-printable" [, mode]<b>)</b> |
| 121 | </p> | 93 | </p> |
| 122 | 94 | ||
| 123 | <p class=description> | 95 | <p class="description"> |
| 124 | Returns a filter that encodes data according to a given transfer content | 96 | Returns a filter that encodes data according to a given transfer content |
| 125 | encoding. | 97 | encoding. |
| 126 | </p> | 98 | </p> |
| 127 | 99 | ||
| 128 | <p class=parameters> | 100 | <p class="parameters"> |
| 129 | In the Quoted-Printable case, the user can specify whether the data is | 101 | In the Quoted-Printable case, the user can specify whether the data is |
| 130 | textual or binary, by passing the <tt>mode</tt> strings "<tt>text</tt>" or | 102 | textual or binary, by passing the <tt>mode</tt> strings "<tt>text</tt>" or |
| 131 | "<tt>binary</tt>". <tt>Mode</tt> defaults to "<tt>text</tt>". | 103 | "<tt>binary</tt>". <tt>Mode</tt> defaults to "<tt>text</tt>". |
| 132 | </p> | 104 | </p> |
| 133 | 105 | ||
| 134 | <p class=note> | 106 | <p class="note"> |
| 135 | Although both transfer content encodings specify a limit for the line | 107 | Although both transfer content encodings specify a limit for the line |
| 136 | length, the encoding filters do <em>not</em> break text into lines (for | 108 | length, the encoding filters do <em>not</em> break text into lines (for |
| 137 | added flexibility). | 109 | added flexibility). |
| 138 | Below is a filter that converts binary data to the Base64 transfer content | 110 | Below is a filter that converts binary data to the Base64 transfer content |
| 139 | encoding and breaks it into lines of the correct size. | 111 | encoding and breaks it into lines of the correct size. |
| 140 | </p> | 112 | </p> |
| 141 | 113 | ||
| 142 | <pre class=example> | 114 | <pre class="example"> |
| 143 | base64 = ltn12.filter.chain( | 115 | base64 = ltn12.filter.chain( |
| 144 | mime.encode("base64"), | 116 | mime.encode("base64"), |
| 145 | mime.wrap("base64") | 117 | mime.wrap("base64") |
| 146 | ) | 118 | ) |
| 147 | </pre> | 119 | </pre> |
| 148 | 120 | ||
| 149 | <p class=note> | 121 | <p class="note"> |
| 150 | Note: Text data <em>has</em> to be converted to canonic form | 122 | Note: Text data <em>has</em> to be converted to canonic form |
| 151 | <em>before</em> being encoded. | 123 | <em>before</em> being encoded. |
| 152 | </p> | 124 | </p> |
| 153 | 125 | ||
| 154 | <pre class=example> | 126 | <pre class="example"> |
| 155 | base64 = ltn12.filter.chain( | 127 | base64 = ltn12.filter.chain( |
| 156 | mime.normalize(), | 128 | mime.normalize(), |
| 157 | mime.encode("base64"), | 129 | mime.encode("base64"), |
| @@ -159,50 +131,79 @@ base64 = ltn12.filter.chain( | |||
| 159 | ) | 131 | ) |
| 160 | </pre> | 132 | </pre> |
| 161 | 133 | ||
| 134 | <!-- normalize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | ||
| 135 | |||
| 136 | <p class="name" id="normalize"> | ||
| 137 | mime.<b>normalize(</b>[marker]<b>)</b> | ||
| 138 | </p> | ||
| 139 | |||
| 140 | <p class="description"> | ||
| 141 | Converts most common end-of-line markers to a specific given marker. | ||
| 142 | </p> | ||
| 143 | |||
| 144 | <p class="parameters"> | ||
| 145 | <tt>Marker</tt> is the new marker. It defaults to CRLF, the canonic | ||
| 146 | end-of-line marker defined by the MIME standard. | ||
| 147 | </p> | ||
| 148 | |||
| 149 | <p class="return"> | ||
| 150 | The function returns a filter that performs the conversion. | ||
| 151 | </p> | ||
| 152 | |||
| 153 | <p class="note"> | ||
| 154 | Note: There is no perfect solution to this problem. Different end-of-line | ||
| 155 | markers are an evil that will probably plague developers forever. | ||
| 156 | This function, however, will work perfectly for text created with any of | ||
| 157 | the most common end-of-line markers, i.e. the Mac OS (CR), the Unix (LF), | ||
| 158 | or the DOS (CRLF) conventions. Even if the data has mixed end-of-line | ||
| 159 | markers, the function will still work well, although it doesn't | ||
| 160 | guarantee that the number of empty lines will be correct. | ||
| 161 | </p> | ||
| 162 | |||
| 162 | <!-- stuff +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 163 | <!-- stuff +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 163 | 164 | ||
| 164 | <p class=name id="stuff"> | 165 | <p class="name" id="stuff"> |
| 165 | mime.<b>stuff()</b><br> | 166 | mime.<b>stuff()</b><br> |
| 166 | </p> | 167 | </p> |
| 167 | 168 | ||
| 168 | <p class=description> | 169 | <p class="description"> |
| 169 | Creates and returns a filter that performs stuffing of SMTP messages. | 170 | Creates and returns a filter that performs stuffing of SMTP messages. |
| 170 | </p> | 171 | </p> |
| 171 | 172 | ||
| 172 | <p class=note> | 173 | <p class="note"> |
| 173 | Note: The <a href=smtp.html#send><tt>smtp.send</tt></a> function | 174 | Note: The <a href="smtp.html#send"><tt>smtp.send</tt></a> function |
| 174 | uses this filter automatically. You don't need to chain it with your | 175 | uses this filter automatically. You don't need to chain it with your |
| 175 | source, or apply it to your message body. | 176 | source, or apply it to your message body. |
| 176 | </p> | 177 | </p> |
| 177 | 178 | ||
| 178 | <!-- wrap +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 179 | <!-- wrap +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 179 | 180 | ||
| 180 | <p class=name id="wrap"> | 181 | <p class="name" id="wrap"> |
| 181 | mime.<b>wrap(</b>"text" [, length]<b>)</b><br> | 182 | mime.<b>wrap(</b>"text" [, length]<b>)</b><br> |
| 182 | mime.<b>wrap(</b>"base64"<b>)</b><br> | 183 | mime.<b>wrap(</b>"base64"<b>)</b><br> |
| 183 | mime.<b>wrap(</b>"quoted-printable"<b>)</b> | 184 | mime.<b>wrap(</b>"quoted-printable"<b>)</b> |
| 184 | </p> | 185 | </p> |
| 185 | 186 | ||
| 186 | <p class=description> | 187 | <p class="description"> |
| 187 | Returns a filter that breaks data into lines. | 188 | Returns a filter that breaks data into lines. |
| 188 | </p> | 189 | </p> |
| 189 | 190 | ||
| 190 | <p class=parameters> | 191 | <p class="parameters"> |
| 191 | The "<tt>text</tt>" line-wrap filter simply breaks text into lines by | 192 | The "<tt>text</tt>" line-wrap filter simply breaks text into lines by |
| 192 | inserting CRLF end-of-line markers at appropriate positions. | 193 | inserting CRLF end-of-line markers at appropriate positions. |
| 193 | <tt>Length</tt> defaults 76. | 194 | <tt>Length</tt> defaults 76. |
| 194 | The "<tt>base64</tt>" line-wrap filter works just like the default | 195 | The "<tt>base64</tt>" line-wrap filter works just like the default |
| 195 | "<tt>text</tt>" line-wrap filter with default length. | 196 | "<tt>text</tt>" line-wrap filter with default length. |
| 196 | The function can also wrap "<tt>quoted-printable</tt>" lines, taking care | 197 | The function can also wrap "<tt>quoted-printable</tt>" lines, taking care |
| 197 | not to break lines in the middle of an escaped character. In that case, the | 198 | not to break lines in the middle of an escaped character. In that case, the |
| 198 | line length is fixed at 76. | 199 | line length is fixed at 76. |
| 199 | </p> | 200 | </p> |
| 200 | 201 | ||
| 201 | <p class=note> | 202 | <p class="note"> |
| 202 | For example, to create an encoding filter for the Quoted-Printable transfer content encoding of text data, do the following: | 203 | For example, to create an encoding filter for the Quoted-Printable transfer content encoding of text data, do the following: |
| 203 | </p> | 204 | </p> |
| 204 | 205 | ||
| 205 | <pre class=example> | 206 | <pre class="example"> |
| 206 | qp = ltn12.filter.chain( | 207 | qp = ltn12.filter.chain( |
| 207 | mime.normalize(), | 208 | mime.normalize(), |
| 208 | mime.encode("quoted-printable"), | 209 | mime.encode("quoted-printable"), |
| @@ -210,155 +211,155 @@ qp = ltn12.filter.chain( | |||
| 210 | ) | 211 | ) |
| 211 | </pre> | 212 | </pre> |
| 212 | 213 | ||
| 213 | <p class=note> | 214 | <p class="note"> |
| 214 | Note: To break into lines with a different end-of-line convention, apply | 215 | Note: To break into lines with a different end-of-line convention, apply |
| 215 | a normalization filter after the line break filter. | 216 | a normalization filter after the line break filter. |
| 216 | </p> | 217 | </p> |
| 217 | 218 | ||
| 218 | <!-- Low-level ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 219 | <!-- Low-level ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 219 | 220 | ||
| 220 | <h3 id=low>Low-level filters</h3> | 221 | <h3 id="low">Low-level filters</h3> |
| 221 | 222 | ||
| 222 | <!-- b64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 223 | <!-- b64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 223 | 224 | ||
| 224 | <p class=name id="b64"> | 225 | <p class="name" id="b64"> |
| 225 | A, B = mime.<b>b64(</b>C [, D]<b>)</b> | 226 | A, B = mime.<b>b64(</b>C [, D]<b>)</b> |
| 226 | </p> | 227 | </p> |
| 227 | 228 | ||
| 228 | <p class=description> | 229 | <p class="description"> |
| 229 | Low-level filter to perform Base64 encoding. | 230 | Low-level filter to perform Base64 encoding. |
| 230 | </p> | 231 | </p> |
| 231 | 232 | ||
| 232 | <p class=description> | 233 | <p class="description"> |
| 233 | <tt>A</tt> is the encoded version of the largest prefix of | 234 | <tt>A</tt> is the encoded version of the largest prefix of |
| 234 | <tt>C..D</tt> | 235 | <tt>C..D</tt> |
| 235 | that can be encoded unambiguously. <tt>B</tt> has the remaining bytes of | 236 | that can be encoded unambiguously. <tt>B</tt> has the remaining bytes of |
| 236 | <tt>C..D</tt>, <em>before</em> encoding. | 237 | <tt>C..D</tt>, <em>before</em> encoding. |
| 237 | If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is padded with | 238 | If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is padded with |
| 238 | the encoding of the remaining bytes of <tt>C</tt>. | 239 | the encoding of the remaining bytes of <tt>C</tt>. |
| 239 | </p> | 240 | </p> |
| 240 | 241 | ||
| 241 | <p class=note> | 242 | <p class="note"> |
| 242 | Note: The simplest use of this function is to encode a string into it's | 243 | Note: The simplest use of this function is to encode a string into it's |
| 243 | Base64 transfer content encoding. Notice the extra parenthesis around the | 244 | Base64 transfer content encoding. Notice the extra parenthesis around the |
| 244 | call to <tt>mime.b64</tt>, to discard the second return value. | 245 | call to <tt>mime.b64</tt>, to discard the second return value. |
| 245 | </p> | 246 | </p> |
| 246 | 247 | ||
| 247 | <pre class=example> | 248 | <pre class="example"> |
| 248 | print((mime.b64("diego:password"))) | 249 | print((mime.b64("diego:password"))) |
| 249 | --> ZGllZ286cGFzc3dvcmQ= | 250 | --> ZGllZ286cGFzc3dvcmQ= |
| 250 | </pre> | 251 | </pre> |
| 251 | 252 | ||
| 252 | <!-- dot +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 253 | <!-- dot +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 253 | <p class=name id="dot"> | 254 | <p class="name" id="dot"> |
| 254 | A, n = mime.<b>dot(</b>m [, B]<b>)</b> | 255 | A, n = mime.<b>dot(</b>m [, B]<b>)</b> |
| 255 | </p> | 256 | </p> |
| 256 | 257 | ||
| 257 | <p class=description> | 258 | <p class="description"> |
| 258 | Low-level filter to perform SMTP stuffing and enable transmission of | 259 | Low-level filter to perform SMTP stuffing and enable transmission of |
| 259 | messages containing the sequence "CRLF.CRLF". | 260 | messages containing the sequence "CRLF.CRLF". |
| 260 | </p> | 261 | </p> |
| 261 | 262 | ||
| 262 | <p class=parameters> | 263 | <p class="parameters"> |
| 263 | <tt>A</tt> is the stuffed version of <tt>B</tt>. '<tt>n</tt>' gives the | 264 | <tt>A</tt> is the stuffed version of <tt>B</tt>. '<tt>n</tt>' gives the |
| 264 | number of characters from the sequence CRLF seen in the end of <tt>B</tt>. | 265 | number of characters from the sequence CRLF seen in the end of <tt>B</tt>. |
| 265 | '<tt>m</tt>' should tell the same, but for the previous chunk. | 266 | '<tt>m</tt>' should tell the same, but for the previous chunk. |
| 266 | </p> | 267 | </p> |
| 267 | 268 | ||
| 268 | <p class=note>Note: The message body is defined to begin with | 269 | <p class="note">Note: The message body is defined to begin with |
| 269 | an implicit CRLF. Therefore, to stuff a message correctly, the | 270 | an implicit CRLF. Therefore, to stuff a message correctly, the |
| 270 | first <tt>m</tt> should have the value 2. | 271 | first <tt>m</tt> should have the value 2. |
| 271 | </p> | 272 | </p> |
| 272 | 273 | ||
| 273 | <pre class=example> | 274 | <pre class="example"> |
| 274 | print((string.gsub(mime.dot(2, ".\r\nStuffing the message.\r\n.\r\n."), "\r\n", "\\n"))) | 275 | print((string.gsub(mime.dot(2, ".\r\nStuffing the message.\r\n.\r\n."), "\r\n", "\\n"))) |
| 275 | --> ..\nStuffing the message.\n..\n.. | 276 | --> ..\nStuffing the message.\n..\n.. |
| 276 | </pre> | 277 | </pre> |
| 277 | 278 | ||
| 278 | <p class=note> | 279 | <p class="note"> |
| 279 | Note: The <a href=smtp.html#send><tt>smtp.send</tt></a> function | 280 | Note: The <a href="smtp.html#send"><tt>smtp.send</tt></a> function |
| 280 | uses this filter automatically. You don't need to | 281 | uses this filter automatically. You don't need to |
| 281 | apply it again. | 282 | apply it again. |
| 282 | </p> | 283 | </p> |
| 283 | 284 | ||
| 284 | <!-- eol ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 285 | <!-- eol ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 285 | 286 | ||
| 286 | <p class=name id="eol"> | 287 | <p class="name" id="eol"> |
| 287 | A, B = mime.<b>eol(</b>C [, D, marker]<b>)</b> | 288 | A, B = mime.<b>eol(</b>C [, D, marker]<b>)</b> |
| 288 | </p> | 289 | </p> |
| 289 | 290 | ||
| 290 | <p class=description> | 291 | <p class="description"> |
| 291 | Low-level filter to perform end-of-line marker translation. | 292 | Low-level filter to perform end-of-line marker translation. |
| 292 | For each chunk, the function needs to know if the last character of the | 293 | For each chunk, the function needs to know if the last character of the |
| 293 | previous chunk could be part of an end-of-line marker or not. This is the | 294 | previous chunk could be part of an end-of-line marker or not. This is the |
| 294 | context the function receives besides the chunk. An updated version of | 295 | context the function receives besides the chunk. An updated version of |
| 295 | the context is returned after each new chunk. | 296 | the context is returned after each new chunk. |
| 296 | </p> | 297 | </p> |
| 297 | 298 | ||
| 298 | <p class=parameters> | 299 | <p class="parameters"> |
| 299 | <tt>A</tt> is the translated version of <tt>D</tt>. <tt>C</tt> is the | 300 | <tt>A</tt> is the translated version of <tt>D</tt>. <tt>C</tt> is the |
| 300 | ASCII value of the last character of the previous chunk, if it was a | 301 | ASCII value of the last character of the previous chunk, if it was a |
| 301 | candidate for line break, or 0 otherwise. | 302 | candidate for line break, or 0 otherwise. |
| 302 | <tt>B</tt> is the same as <tt>C</tt>, but for the current | 303 | <tt>B</tt> is the same as <tt>C</tt>, but for the current |
| 303 | chunk. <tt>Marker</tt> gives the new end-of-line marker and defaults to CRLF. | 304 | chunk. <tt>Marker</tt> gives the new end-of-line marker and defaults to CRLF. |
| 304 | </p> | 305 | </p> |
| 305 | 306 | ||
| 306 | <pre class=example> | 307 | <pre class="example"> |
| 307 | -- translates the end-of-line marker to UNIX | 308 | -- translates the end-of-line marker to UNIX |
| 308 | unix = mime.eol(0, dos, "\n") | 309 | unix = mime.eol(0, dos, "\n") |
| 309 | </pre> | 310 | </pre> |
| 310 | 311 | ||
| 311 | <!-- qp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 312 | <!-- qp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 312 | 313 | ||
| 313 | <p class=name id="qp"> | 314 | <p class="name" id="qp"> |
| 314 | A, B = mime.<b>qp(</b>C [, D, marker]<b>)</b> | 315 | A, B = mime.<b>qp(</b>C [, D, marker]<b>)</b> |
| 315 | </p> | 316 | </p> |
| 316 | 317 | ||
| 317 | <p class=description> | 318 | <p class="description"> |
| 318 | Low-level filter to perform Quoted-Printable encoding. | 319 | Low-level filter to perform Quoted-Printable encoding. |
| 319 | </p> | 320 | </p> |
| 320 | 321 | ||
| 321 | <p class=parameters> | 322 | <p class="parameters"> |
| 322 | <tt>A</tt> is the encoded version of the largest prefix of | 323 | <tt>A</tt> is the encoded version of the largest prefix of |
| 323 | <tt>C..D</tt> | 324 | <tt>C..D</tt> |
| 324 | that can be encoded unambiguously. <tt>B</tt> has the remaining bytes of | 325 | that can be encoded unambiguously. <tt>B</tt> has the remaining bytes of |
| 325 | <tt>C..D</tt>, <em>before</em> encoding. | 326 | <tt>C..D</tt>, <em>before</em> encoding. |
| 326 | If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is padded with | 327 | If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is padded with |
| 327 | the encoding of the remaining bytes of <tt>C</tt>. | 328 | the encoding of the remaining bytes of <tt>C</tt>. |
| 328 | Throughout encoding, occurrences of CRLF are replaced by the | 329 | Throughout encoding, occurrences of CRLF are replaced by the |
| 329 | <tt>marker</tt>, which itself defaults to CRLF. | 330 | <tt>marker</tt>, which itself defaults to CRLF. |
| 330 | </p> | 331 | </p> |
| 331 | 332 | ||
| 332 | <p class=note> | 333 | <p class="note"> |
| 333 | Note: The simplest use of this function is to encode a string into it's | 334 | Note: The simplest use of this function is to encode a string into it's |
| 334 | Quoted-Printable transfer content encoding. | 335 | Quoted-Printable transfer content encoding. |
| 335 | Notice the extra parenthesis around the call to <tt>mime.qp</tt>, to discard the second return value. | 336 | Notice the extra parenthesis around the call to <tt>mime.qp</tt>, to discard the second return value. |
| 336 | </p> | 337 | </p> |
| 337 | 338 | ||
| 338 | <pre class=example> | 339 | <pre class="example"> |
| 339 | print((mime.qp("maçã"))) | 340 | print((mime.qp("ma��"))) |
| 340 | --> ma=E7=E3= | 341 | --> ma=E7=E3= |
| 341 | </pre> | 342 | </pre> |
| 342 | 343 | ||
| 343 | <!-- qpwrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 344 | <!-- qpwrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 344 | 345 | ||
| 345 | <p class=name id="qpwrp"> | 346 | <p class="name" id="qpwrp"> |
| 346 | A, m = mime.<b>qpwrp(</b>n [, B, length]<b>)</b> | 347 | A, m = mime.<b>qpwrp(</b>n [, B, length]<b>)</b> |
| 347 | </p> | 348 | </p> |
| 348 | 349 | ||
| 349 | <p class=description> | 350 | <p class="description"> |
| 350 | Low-level filter to break Quoted-Printable text into lines. | 351 | Low-level filter to break Quoted-Printable text into lines. |
| 351 | </p> | 352 | </p> |
| 352 | 353 | ||
| 353 | <p class=parameters> | 354 | <p class="parameters"> |
| 354 | <tt>A</tt> is a copy of <tt>B</tt>, broken into lines of at most | 355 | <tt>A</tt> is a copy of <tt>B</tt>, broken into lines of at most |
| 355 | <tt>length</tt> bytes (defaults to 76). | 356 | <tt>length</tt> bytes (defaults to 76). |
| 356 | '<tt>n</tt>' should tell how many bytes are left for the first | 357 | '<tt>n</tt>' should tell how many bytes are left for the first |
| 357 | line of <tt>B</tt> and '<tt>m</tt>' returns the number of bytes | 358 | line of <tt>B</tt> and '<tt>m</tt>' returns the number of bytes |
| 358 | left in the last line of <tt>A</tt>. | 359 | left in the last line of <tt>A</tt>. |
| 359 | </p> | 360 | </p> |
| 360 | 361 | ||
| 361 | <p class=note> | 362 | <p class="note"> |
| 362 | Note: Besides breaking text into lines, this function makes sure the line | 363 | Note: Besides breaking text into lines, this function makes sure the line |
| 363 | breaks don't fall in the middle of an escaped character combination. Also, | 364 | breaks don't fall in the middle of an escaped character combination. Also, |
| 364 | this function only breaks lines that are bigger than <tt>length</tt> bytes. | 365 | this function only breaks lines that are bigger than <tt>length</tt> bytes. |
| @@ -366,86 +367,86 @@ this function only breaks lines that are bigger than <tt>length</tt> bytes. | |||
| 366 | 367 | ||
| 367 | <!-- unb64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 368 | <!-- unb64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 368 | 369 | ||
| 369 | <p class=name id="unb64"> | 370 | <p class="name" id="unb64"> |
| 370 | A, B = mime.<b>unb64(</b>C [, D]<b>)</b> | 371 | A, B = mime.<b>unb64(</b>C [, D]<b>)</b> |
| 371 | </p> | 372 | </p> |
| 372 | 373 | ||
| 373 | <p class=description> | 374 | <p class="description"> |
| 374 | Low-level filter to perform Base64 decoding. | 375 | Low-level filter to perform Base64 decoding. |
| 375 | </p> | 376 | </p> |
| 376 | 377 | ||
| 377 | <p class=parameters> | 378 | <p class="parameters"> |
| 378 | <tt>A</tt> is the decoded version of the largest prefix of | 379 | <tt>A</tt> is the decoded version of the largest prefix of |
| 379 | <tt>C..D</tt> | 380 | <tt>C..D</tt> |
| 380 | that can be decoded unambiguously. <tt>B</tt> has the remaining bytes of | 381 | that can be decoded unambiguously. <tt>B</tt> has the remaining bytes of |
| 381 | <tt>C..D</tt>, <em>before</em> decoding. | 382 | <tt>C..D</tt>, <em>before</em> decoding. |
| 382 | If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is the empty string | 383 | If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is the empty string |
| 383 | and <tt>B</tt> returns whatever couldn't be decoded. | 384 | and <tt>B</tt> returns whatever couldn't be decoded. |
| 384 | </p> | 385 | </p> |
| 385 | 386 | ||
| 386 | <p class=note> | 387 | <p class="note"> |
| 387 | Note: The simplest use of this function is to decode a string from it's | 388 | Note: The simplest use of this function is to decode a string from it's |
| 388 | Base64 transfer content encoding. | 389 | Base64 transfer content encoding. |
| 389 | Notice the extra parenthesis around the call to <tt>mime.unqp</tt>, to discard the second return value. | 390 | Notice the extra parenthesis around the call to <tt>mime.unqp</tt>, to discard the second return value. |
| 390 | </p> | 391 | </p> |
| 391 | 392 | ||
| 392 | <pre class=example> | 393 | <pre class="example"> |
| 393 | print((mime.unb64("ZGllZ286cGFzc3dvcmQ="))) | 394 | print((mime.unb64("ZGllZ286cGFzc3dvcmQ="))) |
| 394 | --> diego:password | 395 | --> diego:password |
| 395 | </pre> | 396 | </pre> |
| 396 | 397 | ||
| 397 | <!-- unqp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 398 | <!-- unqp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 398 | 399 | ||
| 399 | <p class=name id="unqp"> | 400 | <p class="name" id="unqp"> |
| 400 | A, B = mime.<b>unqp(</b>C [, D]<b>)</b> | 401 | A, B = mime.<b>unqp(</b>C [, D]<b>)</b> |
| 401 | </p> | 402 | </p> |
| 402 | 403 | ||
| 403 | <p class=description> | 404 | <p class="description"> |
| 404 | Low-level filter to remove the Quoted-Printable transfer content encoding | 405 | Low-level filter to remove the Quoted-Printable transfer content encoding |
| 405 | from data. | 406 | from data. |
| 406 | </p> | 407 | </p> |
| 407 | 408 | ||
| 408 | <p class=parameters> | 409 | <p class="parameters"> |
| 409 | <tt>A</tt> is the decoded version of the largest prefix of | 410 | <tt>A</tt> is the decoded version of the largest prefix of |
| 410 | <tt>C..D</tt> | 411 | <tt>C..D</tt> |
| 411 | that can be decoded unambiguously. <tt>B</tt> has the remaining bytes of | 412 | that can be decoded unambiguously. <tt>B</tt> has the remaining bytes of |
| 412 | <tt>C..D</tt>, <em>before</em> decoding. | 413 | <tt>C..D</tt>, <em>before</em> decoding. |
| 413 | If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is augmented with | 414 | If <tt>D</tt> is <tt><b>nil</b></tt>, <tt>A</tt> is augmented with |
| 414 | the encoding of the remaining bytes of <tt>C</tt>. | 415 | the encoding of the remaining bytes of <tt>C</tt>. |
| 415 | </p> | 416 | </p> |
| 416 | 417 | ||
| 417 | <p class=note> | 418 | <p class="note"> |
| 418 | Note: The simplest use of this function is to decode a string from it's | 419 | Note: The simplest use of this function is to decode a string from it's |
| 419 | Quoted-Printable transfer content encoding. | 420 | Quoted-Printable transfer content encoding. |
| 420 | Notice the extra parenthesis around the call to <tt>mime.unqp</tt>, to discard the second return value. | 421 | Notice the extra parenthesis around the call to <tt>mime.unqp</tt>, to discard the second return value. |
| 421 | </p> | 422 | </p> |
| 422 | 423 | ||
| 423 | <pre class=example> | 424 | <pre class="example"> |
| 424 | print((mime.qp("ma=E7=E3="))) | 425 | print((mime.qp("ma=E7=E3="))) |
| 425 | --> maçã | 426 | --> ma�� |
| 426 | </pre> | 427 | </pre> |
| 427 | 428 | ||
| 428 | <!-- wrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 429 | <!-- wrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 429 | 430 | ||
| 430 | <p class=name id="wrp"> | 431 | <p class="name" id="wrp"> |
| 431 | A, m = mime.<b>wrp(</b>n [, B, length]<b>)</b> | 432 | A, m = mime.<b>wrp(</b>n [, B, length]<b>)</b> |
| 432 | </p> | 433 | </p> |
| 433 | 434 | ||
| 434 | <p class=description> | 435 | <p class="description"> |
| 435 | Low-level filter to break text into lines with CRLF marker. | 436 | Low-level filter to break text into lines with CRLF marker. |
| 436 | Text is assumed to be in the <a href=#normalize><tt>normalize</tt></a> form. | 437 | Text is assumed to be in the <a href="#normalize"><tt>normalize</tt></a> form. |
| 437 | </p> | 438 | </p> |
| 438 | 439 | ||
| 439 | <p class=parameters> | 440 | <p class="parameters"> |
| 440 | <tt>A</tt> is a copy of <tt>B</tt>, broken into lines of at most | 441 | <tt>A</tt> is a copy of <tt>B</tt>, broken into lines of at most |
| 441 | <tt>length</tt> bytes (defaults to 76). | 442 | <tt>length</tt> bytes (defaults to 76). |
| 442 | '<tt>n</tt>' should tell how many bytes are left for the first | 443 | '<tt>n</tt>' should tell how many bytes are left for the first |
| 443 | line of <tt>B</tt> and '<tt>m</tt>' returns the number of bytes | 444 | line of <tt>B</tt> and '<tt>m</tt>' returns the number of bytes |
| 444 | left in the last line of <tt>A</tt>. | 445 | left in the last line of <tt>A</tt>. |
| 445 | </p> | 446 | </p> |
| 446 | 447 | ||
| 447 | <p class=note> | 448 | <p class="note"> |
| 448 | Note: This function only breaks lines that are bigger than | 449 | Note: This function only breaks lines that are bigger than |
| 449 | <tt>length</tt> bytes. The resulting line length does not include the CRLF | 450 | <tt>length</tt> bytes. The resulting line length does not include the CRLF |
| 450 | marker. | 451 | marker. |
| 451 | </p> | 452 | </p> |
| @@ -453,10 +454,10 @@ marker. | |||
| 453 | 454 | ||
| 454 | <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 455 | <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 455 | 456 | ||
| 456 | <div class=footer> | 457 | <div class="footer"> |
| 457 | <hr> | 458 | <hr> |
| 458 | <center> | 459 | <center> |
| 459 | <p class=bar> | 460 | <p class="bar"> |
| 460 | <a href="index.html">home</a> · | 461 | <a href="index.html">home</a> · |
| 461 | <a href="index.html#down">download</a> · | 462 | <a href="index.html#down">download</a> · |
| 462 | <a href="installation.html">installation</a> · | 463 | <a href="installation.html">installation</a> · |
| @@ -466,7 +467,7 @@ marker. | |||
| 466 | <p> | 467 | <p> |
| 467 | <small> | 468 | <small> |
| 468 | Last modified by Diego Nehab on <br> | 469 | Last modified by Diego Nehab on <br> |
| 469 | Thu Apr 20 00:25:44 EDT 2006 | 470 | Fri Mar 4 15:19:17 BRT 2016 |
| 470 | </small> | 471 | </small> |
| 471 | </p> | 472 | </p> |
| 472 | </center> | 473 | </center> |
