diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2022-03-22 19:21:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-03-22 21:21:58 +0300 |
| commit | f97dc8489d58aef2d038288f9a8bc69f907e17bb (patch) | |
| tree | 3ac503f8ed1cc44b1c16528ed80347b0a5590cc7 /doc/mime.html | |
| parent | d3434c01983de3ec40e4535f856081ad138fa198 (diff) | |
| download | luasocket-f97dc8489d58aef2d038288f9a8bc69f907e17bb.tar.gz luasocket-f97dc8489d58aef2d038288f9a8bc69f907e17bb.tar.bz2 luasocket-f97dc8489d58aef2d038288f9a8bc69f907e17bb.zip | |
fix(docs) fix html linter issues in the docs (#358)
Diffstat (limited to 'doc/mime.html')
| -rw-r--r-- | doc/mime.html | 302 |
1 files changed, 151 insertions, 151 deletions
diff --git a/doc/mime.html b/doc/mime.html index 8cb3507..ff4d8e8 100644 --- a/doc/mime.html +++ b/doc/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,60 +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 | 74 | ||
| 75 | 75 | ||
| 76 | <!-- decode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 76 | <!-- decode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 77 | 77 | ||
| 78 | <p class=name id="decode"> | 78 | <p class="name" id="decode"> |
| 79 | mime.<b>decode(</b>"base64"<b>)</b><br> | 79 | mime.<b>decode(</b>"base64"<b>)</b><br> |
| 80 | mime.<b>decode(</b>"quoted-printable"<b>)</b> | 80 | mime.<b>decode(</b>"quoted-printable"<b>)</b> |
| 81 | </p> | 81 | </p> |
| 82 | 82 | ||
| 83 | <p class=description> | 83 | <p class="description"> |
| 84 | Returns a filter that decodes data from a given transfer content | 84 | Returns a filter that decodes data from a given transfer content |
| 85 | encoding. | 85 | encoding. |
| 86 | </p> | 86 | </p> |
| 87 | 87 | ||
| 88 | <!-- encode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 88 | <!-- encode +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 89 | 89 | ||
| 90 | <p class=name id="encode"> | 90 | <p class="name" id="encode"> |
| 91 | mime.<b>encode(</b>"base64"<b>)</b><br> | 91 | mime.<b>encode(</b>"base64"<b>)</b><br> |
| 92 | mime.<b>encode(</b>"quoted-printable" [, mode]<b>)</b> | 92 | mime.<b>encode(</b>"quoted-printable" [, mode]<b>)</b> |
| 93 | </p> | 93 | </p> |
| 94 | 94 | ||
| 95 | <p class=description> | 95 | <p class="description"> |
| 96 | 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 |
| 97 | encoding. | 97 | encoding. |
| 98 | </p> | 98 | </p> |
| 99 | 99 | ||
| 100 | <p class=parameters> | 100 | <p class="parameters"> |
| 101 | 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 |
| 102 | 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 |
| 103 | "<tt>binary</tt>". <tt>Mode</tt> defaults to "<tt>text</tt>". | 103 | "<tt>binary</tt>". <tt>Mode</tt> defaults to "<tt>text</tt>". |
| 104 | </p> | 104 | </p> |
| 105 | 105 | ||
| 106 | <p class=note> | 106 | <p class="note"> |
| 107 | Although both transfer content encodings specify a limit for the line | 107 | Although both transfer content encodings specify a limit for the line |
| 108 | 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 |
| 109 | added flexibility). | 109 | added flexibility). |
| 110 | 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 |
| 111 | encoding and breaks it into lines of the correct size. | 111 | encoding and breaks it into lines of the correct size. |
| 112 | </p> | 112 | </p> |
| 113 | 113 | ||
| 114 | <pre class=example> | 114 | <pre class="example"> |
| 115 | base64 = ltn12.filter.chain( | 115 | base64 = ltn12.filter.chain( |
| 116 | mime.encode("base64"), | 116 | mime.encode("base64"), |
| 117 | mime.wrap("base64") | 117 | mime.wrap("base64") |
| 118 | ) | 118 | ) |
| 119 | </pre> | 119 | </pre> |
| 120 | 120 | ||
| 121 | <p class=note> | 121 | <p class="note"> |
| 122 | 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 |
| 123 | <em>before</em> being encoded. | 123 | <em>before</em> being encoded. |
| 124 | </p> | 124 | </p> |
| 125 | 125 | ||
| 126 | <pre class=example> | 126 | <pre class="example"> |
| 127 | base64 = ltn12.filter.chain( | 127 | base64 = ltn12.filter.chain( |
| 128 | mime.normalize(), | 128 | mime.normalize(), |
| 129 | mime.encode("base64"), | 129 | mime.encode("base64"), |
| @@ -133,77 +133,77 @@ base64 = ltn12.filter.chain( | |||
| 133 | 133 | ||
| 134 | <!-- normalize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 134 | <!-- normalize ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 135 | 135 | ||
| 136 | <p class=name id="normalize"> | 136 | <p class="name" id="normalize"> |
| 137 | mime.<b>normalize(</b>[marker]<b>)</b> | 137 | mime.<b>normalize(</b>[marker]<b>)</b> |
| 138 | </p> | 138 | </p> |
| 139 | 139 | ||
| 140 | <p class=description> | 140 | <p class="description"> |
| 141 | Converts most common end-of-line markers to a specific given marker. | 141 | Converts most common end-of-line markers to a specific given marker. |
| 142 | </p> | 142 | </p> |
| 143 | 143 | ||
| 144 | <p class=parameters> | 144 | <p class="parameters"> |
| 145 | <tt>Marker</tt> is the new marker. It defaults to CRLF, the canonic | 145 | <tt>Marker</tt> is the new marker. It defaults to CRLF, the canonic |
| 146 | end-of-line marker defined by the MIME standard. | 146 | end-of-line marker defined by the MIME standard. |
| 147 | </p> | 147 | </p> |
| 148 | 148 | ||
| 149 | <p class=return> | 149 | <p class="return"> |
| 150 | The function returns a filter that performs the conversion. | 150 | The function returns a filter that performs the conversion. |
| 151 | </p> | 151 | </p> |
| 152 | 152 | ||
| 153 | <p class=note> | 153 | <p class="note"> |
| 154 | Note: There is no perfect solution to this problem. Different end-of-line | 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. | 155 | markers are an evil that will probably plague developers forever. |
| 156 | This function, however, will work perfectly for text created with any of | 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), | 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 | 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 | 159 | markers, the function will still work well, although it doesn't |
| 160 | guarantee that the number of empty lines will be correct. | 160 | guarantee that the number of empty lines will be correct. |
| 161 | </p> | 161 | </p> |
| 162 | 162 | ||
| 163 | <!-- stuff +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 163 | <!-- stuff +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 164 | 164 | ||
| 165 | <p class=name id="stuff"> | 165 | <p class="name" id="stuff"> |
| 166 | mime.<b>stuff()</b><br> | 166 | mime.<b>stuff()</b><br> |
| 167 | </p> | 167 | </p> |
| 168 | 168 | ||
| 169 | <p class=description> | 169 | <p class="description"> |
| 170 | Creates and returns a filter that performs stuffing of SMTP messages. | 170 | Creates and returns a filter that performs stuffing of SMTP messages. |
| 171 | </p> | 171 | </p> |
| 172 | 172 | ||
| 173 | <p class=note> | 173 | <p class="note"> |
| 174 | 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 |
| 175 | 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 |
| 176 | source, or apply it to your message body. | 176 | source, or apply it to your message body. |
| 177 | </p> | 177 | </p> |
| 178 | 178 | ||
| 179 | <!-- wrap +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 179 | <!-- wrap +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 180 | 180 | ||
| 181 | <p class=name id="wrap"> | 181 | <p class="name" id="wrap"> |
| 182 | mime.<b>wrap(</b>"text" [, length]<b>)</b><br> | 182 | mime.<b>wrap(</b>"text" [, length]<b>)</b><br> |
| 183 | mime.<b>wrap(</b>"base64"<b>)</b><br> | 183 | mime.<b>wrap(</b>"base64"<b>)</b><br> |
| 184 | mime.<b>wrap(</b>"quoted-printable"<b>)</b> | 184 | mime.<b>wrap(</b>"quoted-printable"<b>)</b> |
| 185 | </p> | 185 | </p> |
| 186 | 186 | ||
| 187 | <p class=description> | 187 | <p class="description"> |
| 188 | Returns a filter that breaks data into lines. | 188 | Returns a filter that breaks data into lines. |
| 189 | </p> | 189 | </p> |
| 190 | 190 | ||
| 191 | <p class=parameters> | 191 | <p class="parameters"> |
| 192 | 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 |
| 193 | inserting CRLF end-of-line markers at appropriate positions. | 193 | inserting CRLF end-of-line markers at appropriate positions. |
| 194 | <tt>Length</tt> defaults 76. | 194 | <tt>Length</tt> defaults 76. |
| 195 | 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 |
| 196 | "<tt>text</tt>" line-wrap filter with default length. | 196 | "<tt>text</tt>" line-wrap filter with default length. |
| 197 | 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 |
| 198 | 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 |
| 199 | line length is fixed at 76. | 199 | line length is fixed at 76. |
| 200 | </p> | 200 | </p> |
| 201 | 201 | ||
| 202 | <p class=note> | 202 | <p class="note"> |
| 203 | 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: |
| 204 | </p> | 204 | </p> |
| 205 | 205 | ||
| 206 | <pre class=example> | 206 | <pre class="example"> |
| 207 | qp = ltn12.filter.chain( | 207 | qp = ltn12.filter.chain( |
| 208 | mime.normalize(), | 208 | mime.normalize(), |
| 209 | mime.encode("quoted-printable"), | 209 | mime.encode("quoted-printable"), |
| @@ -211,155 +211,155 @@ qp = ltn12.filter.chain( | |||
| 211 | ) | 211 | ) |
| 212 | </pre> | 212 | </pre> |
| 213 | 213 | ||
| 214 | <p class=note> | 214 | <p class="note"> |
| 215 | 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 |
| 216 | a normalization filter after the line break filter. | 216 | a normalization filter after the line break filter. |
| 217 | </p> | 217 | </p> |
| 218 | 218 | ||
| 219 | <!-- Low-level ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 219 | <!-- Low-level ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 220 | 220 | ||
| 221 | <h3 id=low>Low-level filters</h3> | 221 | <h3 id="low">Low-level filters</h3> |
| 222 | 222 | ||
| 223 | <!-- b64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 223 | <!-- b64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 224 | 224 | ||
| 225 | <p class=name id="b64"> | 225 | <p class="name" id="b64"> |
| 226 | A, B = mime.<b>b64(</b>C [, D]<b>)</b> | 226 | A, B = mime.<b>b64(</b>C [, D]<b>)</b> |
| 227 | </p> | 227 | </p> |
| 228 | 228 | ||
| 229 | <p class=description> | 229 | <p class="description"> |
| 230 | Low-level filter to perform Base64 encoding. | 230 | Low-level filter to perform Base64 encoding. |
| 231 | </p> | 231 | </p> |
| 232 | 232 | ||
| 233 | <p class=description> | 233 | <p class="description"> |
| 234 | <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 |
| 235 | <tt>C..D</tt> | 235 | <tt>C..D</tt> |
| 236 | 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 |
| 237 | <tt>C..D</tt>, <em>before</em> encoding. | 237 | <tt>C..D</tt>, <em>before</em> encoding. |
| 238 | 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 |
| 239 | the encoding of the remaining bytes of <tt>C</tt>. | 239 | the encoding of the remaining bytes of <tt>C</tt>. |
| 240 | </p> | 240 | </p> |
| 241 | 241 | ||
| 242 | <p class=note> | 242 | <p class="note"> |
| 243 | 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 |
| 244 | Base64 transfer content encoding. Notice the extra parenthesis around the | 244 | Base64 transfer content encoding. Notice the extra parenthesis around the |
| 245 | 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. |
| 246 | </p> | 246 | </p> |
| 247 | 247 | ||
| 248 | <pre class=example> | 248 | <pre class="example"> |
| 249 | print((mime.b64("diego:password"))) | 249 | print((mime.b64("diego:password"))) |
| 250 | --> ZGllZ286cGFzc3dvcmQ= | 250 | --> ZGllZ286cGFzc3dvcmQ= |
| 251 | </pre> | 251 | </pre> |
| 252 | 252 | ||
| 253 | <!-- dot +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 253 | <!-- dot +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 254 | <p class=name id="dot"> | 254 | <p class="name" id="dot"> |
| 255 | A, n = mime.<b>dot(</b>m [, B]<b>)</b> | 255 | A, n = mime.<b>dot(</b>m [, B]<b>)</b> |
| 256 | </p> | 256 | </p> |
| 257 | 257 | ||
| 258 | <p class=description> | 258 | <p class="description"> |
| 259 | Low-level filter to perform SMTP stuffing and enable transmission of | 259 | Low-level filter to perform SMTP stuffing and enable transmission of |
| 260 | messages containing the sequence "CRLF.CRLF". | 260 | messages containing the sequence "CRLF.CRLF". |
| 261 | </p> | 261 | </p> |
| 262 | 262 | ||
| 263 | <p class=parameters> | 263 | <p class="parameters"> |
| 264 | <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 |
| 265 | 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>. |
| 266 | '<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. |
| 267 | </p> | 267 | </p> |
| 268 | 268 | ||
| 269 | <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 |
| 270 | an implicit CRLF. Therefore, to stuff a message correctly, the | 270 | an implicit CRLF. Therefore, to stuff a message correctly, the |
| 271 | first <tt>m</tt> should have the value 2. | 271 | first <tt>m</tt> should have the value 2. |
| 272 | </p> | 272 | </p> |
| 273 | 273 | ||
| 274 | <pre class=example> | 274 | <pre class="example"> |
| 275 | 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"))) |
| 276 | --> ..\nStuffing the message.\n..\n.. | 276 | --> ..\nStuffing the message.\n..\n.. |
| 277 | </pre> | 277 | </pre> |
| 278 | 278 | ||
| 279 | <p class=note> | 279 | <p class="note"> |
| 280 | 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 |
| 281 | uses this filter automatically. You don't need to | 281 | uses this filter automatically. You don't need to |
| 282 | apply it again. | 282 | apply it again. |
| 283 | </p> | 283 | </p> |
| 284 | 284 | ||
| 285 | <!-- eol ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 285 | <!-- eol ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 286 | 286 | ||
| 287 | <p class=name id="eol"> | 287 | <p class="name" id="eol"> |
| 288 | A, B = mime.<b>eol(</b>C [, D, marker]<b>)</b> | 288 | A, B = mime.<b>eol(</b>C [, D, marker]<b>)</b> |
| 289 | </p> | 289 | </p> |
| 290 | 290 | ||
| 291 | <p class=description> | 291 | <p class="description"> |
| 292 | Low-level filter to perform end-of-line marker translation. | 292 | Low-level filter to perform end-of-line marker translation. |
| 293 | 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 |
| 294 | 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 |
| 295 | context the function receives besides the chunk. An updated version of | 295 | context the function receives besides the chunk. An updated version of |
| 296 | the context is returned after each new chunk. | 296 | the context is returned after each new chunk. |
| 297 | </p> | 297 | </p> |
| 298 | 298 | ||
| 299 | <p class=parameters> | 299 | <p class="parameters"> |
| 300 | <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 |
| 301 | 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 |
| 302 | candidate for line break, or 0 otherwise. | 302 | candidate for line break, or 0 otherwise. |
| 303 | <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 |
| 304 | 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. |
| 305 | </p> | 305 | </p> |
| 306 | 306 | ||
| 307 | <pre class=example> | 307 | <pre class="example"> |
| 308 | -- translates the end-of-line marker to UNIX | 308 | -- translates the end-of-line marker to UNIX |
| 309 | unix = mime.eol(0, dos, "\n") | 309 | unix = mime.eol(0, dos, "\n") |
| 310 | </pre> | 310 | </pre> |
| 311 | 311 | ||
| 312 | <!-- qp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 312 | <!-- qp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 313 | 313 | ||
| 314 | <p class=name id="qp"> | 314 | <p class="name" id="qp"> |
| 315 | A, B = mime.<b>qp(</b>C [, D, marker]<b>)</b> | 315 | A, B = mime.<b>qp(</b>C [, D, marker]<b>)</b> |
| 316 | </p> | 316 | </p> |
| 317 | 317 | ||
| 318 | <p class=description> | 318 | <p class="description"> |
| 319 | Low-level filter to perform Quoted-Printable encoding. | 319 | Low-level filter to perform Quoted-Printable encoding. |
| 320 | </p> | 320 | </p> |
| 321 | 321 | ||
| 322 | <p class=parameters> | 322 | <p class="parameters"> |
| 323 | <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 |
| 324 | <tt>C..D</tt> | 324 | <tt>C..D</tt> |
| 325 | 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 |
| 326 | <tt>C..D</tt>, <em>before</em> encoding. | 326 | <tt>C..D</tt>, <em>before</em> encoding. |
| 327 | 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 |
| 328 | the encoding of the remaining bytes of <tt>C</tt>. | 328 | the encoding of the remaining bytes of <tt>C</tt>. |
| 329 | Throughout encoding, occurrences of CRLF are replaced by the | 329 | Throughout encoding, occurrences of CRLF are replaced by the |
| 330 | <tt>marker</tt>, which itself defaults to CRLF. | 330 | <tt>marker</tt>, which itself defaults to CRLF. |
| 331 | </p> | 331 | </p> |
| 332 | 332 | ||
| 333 | <p class=note> | 333 | <p class="note"> |
| 334 | 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 |
| 335 | Quoted-Printable transfer content encoding. | 335 | Quoted-Printable transfer content encoding. |
| 336 | 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. |
| 337 | </p> | 337 | </p> |
| 338 | 338 | ||
| 339 | <pre class=example> | 339 | <pre class="example"> |
| 340 | print((mime.qp("maçã"))) | 340 | print((mime.qp("ma��"))) |
| 341 | --> ma=E7=E3= | 341 | --> ma=E7=E3= |
| 342 | </pre> | 342 | </pre> |
| 343 | 343 | ||
| 344 | <!-- qpwrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 344 | <!-- qpwrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 345 | 345 | ||
| 346 | <p class=name id="qpwrp"> | 346 | <p class="name" id="qpwrp"> |
| 347 | A, m = mime.<b>qpwrp(</b>n [, B, length]<b>)</b> | 347 | A, m = mime.<b>qpwrp(</b>n [, B, length]<b>)</b> |
| 348 | </p> | 348 | </p> |
| 349 | 349 | ||
| 350 | <p class=description> | 350 | <p class="description"> |
| 351 | Low-level filter to break Quoted-Printable text into lines. | 351 | Low-level filter to break Quoted-Printable text into lines. |
| 352 | </p> | 352 | </p> |
| 353 | 353 | ||
| 354 | <p class=parameters> | 354 | <p class="parameters"> |
| 355 | <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 |
| 356 | <tt>length</tt> bytes (defaults to 76). | 356 | <tt>length</tt> bytes (defaults to 76). |
| 357 | '<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 |
| 358 | 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 |
| 359 | left in the last line of <tt>A</tt>. | 359 | left in the last line of <tt>A</tt>. |
| 360 | </p> | 360 | </p> |
| 361 | 361 | ||
| 362 | <p class=note> | 362 | <p class="note"> |
| 363 | 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 |
| 364 | 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, |
| 365 | 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. |
| @@ -367,86 +367,86 @@ this function only breaks lines that are bigger than <tt>length</tt> bytes. | |||
| 367 | 367 | ||
| 368 | <!-- unb64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 368 | <!-- unb64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 369 | 369 | ||
| 370 | <p class=name id="unb64"> | 370 | <p class="name" id="unb64"> |
| 371 | A, B = mime.<b>unb64(</b>C [, D]<b>)</b> | 371 | A, B = mime.<b>unb64(</b>C [, D]<b>)</b> |
| 372 | </p> | 372 | </p> |
| 373 | 373 | ||
| 374 | <p class=description> | 374 | <p class="description"> |
| 375 | Low-level filter to perform Base64 decoding. | 375 | Low-level filter to perform Base64 decoding. |
| 376 | </p> | 376 | </p> |
| 377 | 377 | ||
| 378 | <p class=parameters> | 378 | <p class="parameters"> |
| 379 | <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 |
| 380 | <tt>C..D</tt> | 380 | <tt>C..D</tt> |
| 381 | 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 |
| 382 | <tt>C..D</tt>, <em>before</em> decoding. | 382 | <tt>C..D</tt>, <em>before</em> decoding. |
| 383 | 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 |
| 384 | and <tt>B</tt> returns whatever couldn't be decoded. | 384 | and <tt>B</tt> returns whatever couldn't be decoded. |
| 385 | </p> | 385 | </p> |
| 386 | 386 | ||
| 387 | <p class=note> | 387 | <p class="note"> |
| 388 | 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 |
| 389 | Base64 transfer content encoding. | 389 | Base64 transfer content encoding. |
| 390 | 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. |
| 391 | </p> | 391 | </p> |
| 392 | 392 | ||
| 393 | <pre class=example> | 393 | <pre class="example"> |
| 394 | print((mime.unb64("ZGllZ286cGFzc3dvcmQ="))) | 394 | print((mime.unb64("ZGllZ286cGFzc3dvcmQ="))) |
| 395 | --> diego:password | 395 | --> diego:password |
| 396 | </pre> | 396 | </pre> |
| 397 | 397 | ||
| 398 | <!-- unqp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 398 | <!-- unqp +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 399 | 399 | ||
| 400 | <p class=name id="unqp"> | 400 | <p class="name" id="unqp"> |
| 401 | A, B = mime.<b>unqp(</b>C [, D]<b>)</b> | 401 | A, B = mime.<b>unqp(</b>C [, D]<b>)</b> |
| 402 | </p> | 402 | </p> |
| 403 | 403 | ||
| 404 | <p class=description> | 404 | <p class="description"> |
| 405 | Low-level filter to remove the Quoted-Printable transfer content encoding | 405 | Low-level filter to remove the Quoted-Printable transfer content encoding |
| 406 | from data. | 406 | from data. |
| 407 | </p> | 407 | </p> |
| 408 | 408 | ||
| 409 | <p class=parameters> | 409 | <p class="parameters"> |
| 410 | <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 |
| 411 | <tt>C..D</tt> | 411 | <tt>C..D</tt> |
| 412 | 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 |
| 413 | <tt>C..D</tt>, <em>before</em> decoding. | 413 | <tt>C..D</tt>, <em>before</em> decoding. |
| 414 | 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 |
| 415 | the encoding of the remaining bytes of <tt>C</tt>. | 415 | the encoding of the remaining bytes of <tt>C</tt>. |
| 416 | </p> | 416 | </p> |
| 417 | 417 | ||
| 418 | <p class=note> | 418 | <p class="note"> |
| 419 | 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 |
| 420 | Quoted-Printable transfer content encoding. | 420 | Quoted-Printable transfer content encoding. |
| 421 | 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. |
| 422 | </p> | 422 | </p> |
| 423 | 423 | ||
| 424 | <pre class=example> | 424 | <pre class="example"> |
| 425 | print((mime.qp("ma=E7=E3="))) | 425 | print((mime.qp("ma=E7=E3="))) |
| 426 | --> maçã | 426 | --> ma�� |
| 427 | </pre> | 427 | </pre> |
| 428 | 428 | ||
| 429 | <!-- wrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 429 | <!-- wrp ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 430 | 430 | ||
| 431 | <p class=name id="wrp"> | 431 | <p class="name" id="wrp"> |
| 432 | A, m = mime.<b>wrp(</b>n [, B, length]<b>)</b> | 432 | A, m = mime.<b>wrp(</b>n [, B, length]<b>)</b> |
| 433 | </p> | 433 | </p> |
| 434 | 434 | ||
| 435 | <p class=description> | 435 | <p class="description"> |
| 436 | Low-level filter to break text into lines with CRLF marker. | 436 | Low-level filter to break text into lines with CRLF marker. |
| 437 | 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. |
| 438 | </p> | 438 | </p> |
| 439 | 439 | ||
| 440 | <p class=parameters> | 440 | <p class="parameters"> |
| 441 | <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 |
| 442 | <tt>length</tt> bytes (defaults to 76). | 442 | <tt>length</tt> bytes (defaults to 76). |
| 443 | '<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 |
| 444 | 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 |
| 445 | left in the last line of <tt>A</tt>. | 445 | left in the last line of <tt>A</tt>. |
| 446 | </p> | 446 | </p> |
| 447 | 447 | ||
| 448 | <p class=note> | 448 | <p class="note"> |
| 449 | Note: This function only breaks lines that are bigger than | 449 | Note: This function only breaks lines that are bigger than |
| 450 | <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 |
| 451 | marker. | 451 | marker. |
| 452 | </p> | 452 | </p> |
| @@ -454,10 +454,10 @@ marker. | |||
| 454 | 454 | ||
| 455 | <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> | 455 | <!-- footer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ --> |
| 456 | 456 | ||
| 457 | <div class=footer> | 457 | <div class="footer"> |
| 458 | <hr> | 458 | <hr> |
| 459 | <center> | 459 | <center> |
| 460 | <p class=bar> | 460 | <p class="bar"> |
| 461 | <a href="index.html">home</a> · | 461 | <a href="index.html">home</a> · |
| 462 | <a href="index.html#down">download</a> · | 462 | <a href="index.html#down">download</a> · |
| 463 | <a href="installation.html">installation</a> · | 463 | <a href="installation.html">installation</a> · |
