A port over which a redirection is served to get-pure-port is not closed
if `get-pure-port' follows the redirection. This leaks file descriptors
on the host machine.
the errors that would be signalled by the body. also, remove
url-regexp from the exports (it was only recently added)
I believe this eliminates two of Eli's concerns:
- the contract is no longer so painful to read
- the performance is more reasonable.
Specifically, for the performance, here are the times I see to call
string->url on "http://www.racket-lang.org":
no contract: any/c
cpu time: 564 real time: 566 gc time: 3
weak contract: (-> (or/c string? bytes?) url?)
cpu time: 590 real time: 590 gc time: 3
strong, regexp-based contract:
(-> (or/c (not/c #rx"^([^:/?#]*):") #rx"^[a-zA-Z][a-zA-Z0-9+.-]*:") url?)
cpu time: 632 real time: 633 gc time: 5
This appears to be about a 10% slowdown for the regexp-based contract
over the weaker contract.
related to PR 12652
* In base64 encoding remove all newlines from the encoded result, avoids
getting an invalid result.
* In qp encoding:
- replace all spaces by underlines, not just the first (looks like a
typo in the previous code)
- encode "?"s and "_"s too, as required for this encoding
- remove soft newlines (again, avoid an invalid result)
* Use `regexp-replace*' to encode the parts between the lines. Besides
making the code simpler, it fixes a bug in the previous code where
multiple lines would each get encoded and the results concatenated
without the newlines or any other whitespace.
* When the string to be encoded is longer than 70 characters, split and
encode the sub-parts, then concatenate the encodings with a "\n "
separator. This is done as a poor attempt to follow the line length
limits specified in rfc2047, or more concretely, to avoid sendmail's
"!\n " splitting.
* Use `re:non-ascii' to look for a non-ascii character => faster.
* Use either CR or LF for a newline, not just LF.
* Use `regexp-replace*' to encode the parts between the lines. Besides
making the code simpler, it fixes a bug in the previous code where
multiple lines would each get encoded and the results concatenated
without the newlines or any other whitespace.
There might be existing uses of `net/sendmail' that did this quoting
since this code didn't do so. Such uses would continue to work fine,
since quoted strings would already be plain ASCII, so a second quoting
would leave it as is.
Note that the quoted strings are also used as command line arguments.
It seems that sendmail deals with these all fine when they appear as
command line arguments. This means that any valid email address format
can be used, not just "raw" emails. If there are some sendmails that
don't do this, then it would be better to add a `-t' flag to let
sendmail parse the text in the message.
One caveat (not a new one): since they're passed as is, it is possible
to use two emails in a single string, as in "a@b.com, c@d.com". This
could lead to obvious problems if someone uses "Bar, Foo <foo@bar.org>"
instead of "\"Bar, Foo\" <foo@bar.org>". (Using a `-t' to parse the
content won't help with that...) The only way to avoid this would be to
parse the emails and quote the name part if needed. But that's a much
hairier piece of code.
* Move the `X-Mailer' header to the top, so that the interesting headers
are all together at the bottom (the top gets littered by server
headers anyway).
* Use `subprocess' directly (`process*' wasn't really doing anything
more than that).
* Allow the sender to be `#f', leaving the header out. This makes all
sendmails that I've used use the username that is running the process.
* Just search for a sendmail program: don't barf on windows, so it can
be used in case there is a sendmail.exe executable there.
* Remove `no-mail-recipients' to make it in-line with other racket code
that doesn't raise super-specific exceptions.
* Use port counting instead of doing the counts manually, much simpler
code.