aboutsummaryrefslogtreecommitdiff
path: root/src/mime
AgeCommit message (Collapse)Author
2020-12-09all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTempRuss Cox
As part of #42026, these helpers from io/ioutil were moved to os. (ioutil.TempFile and TempDir became os.CreateTemp and MkdirTemp.) Update the Go tree to use the preferred names. As usual, code compiled with the Go 1.4 bootstrap toolchain and code vendored from other sources is excluded. ReadDir changes are in a separate CL, because they are not a simple search and replace. For #42026. Change-Id: If318df0216d57e95ea0c4093b89f65e5b0ababb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/266365 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-03mime/multipart: handle ReadForm(math.MaxInt64) betterRuss Cox
Returning an error about integer overflow is needlessly pedantic. The meaning of ReadForm(MaxInt64) is easily understood (accept a lot of data) and can be implemented. Fixes #40430. Change-Id: I8a522033dd9a2f9ad31dd2ad82cf08d553736ab9 Reviewed-on: https://go-review.googlesource.com/c/go/+/275112 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-10-27mime: look up mime types on Arch LinuxAndy Williams
Some systems use "httpd" directory structure instead of "apache" Change-Id: I77600baf356f0c0c3359b331505b0426112daebb GitHub-Last-Rev: c64766f88cc28899d3d387e3eebfa4fcc3eef808 GitHub-Pull-Request: golang/go#39416 Reviewed-on: https://go-review.googlesource.com/c/go/+/236677 Trust: Tobias Klauser <tobias.klauser@gmail.com> Trust: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-10-20all: update references to symbols moved from io/ioutil to ioRuss Cox
The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-10-13syscall: remove dependency on ioRuss Cox
Keep syscall and io separated; neither should depend on the other. Change-Id: Icdd61bd0c05d874cabd7b5ae6631dd09dec90112 Reviewed-on: https://go-review.googlesource.com/c/go/+/243902 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org>
2020-09-28mime/multipart: return overflow errors in Reader.ReadFormavivklas
Updates Reader.ReadForm to check for overflow errors that may result from a leeway addition of 10MiB to the input argument maxMemory. Fixes #40430 Change-Id: I510b8966c95c51d04695ba9d08fcfe005fd11a5d Reviewed-on: https://go-review.googlesource.com/c/go/+/247477 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-09-06mime: add examples for FormatMediaType and ParseMediaTypeAinar Garipov
Change-Id: Ic129c58784ad1f0b8b90fc9d33e52bee61bdf0eb Reviewed-on: https://go-review.googlesource.com/c/go/+/253237 Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-03-07mime: add .json to built-in list of MIME typesAn Long
Since json is popular and mime package's builtin type does not contain it, and some Linux distributions do not contain the '/etc/mime.types' file with minimal installations. Change-Id: I933393c82be296ef176206c253f4dd19b6f33bb1 GitHub-Last-Rev: ce4eae56a4d468631555dc85e0e7ab4bbd0ef45d GitHub-Pull-Request: golang/go#34737 Reviewed-on: https://go-review.googlesource.com/c/go/+/199657 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-02-25mime: fix ExtensionsByType bug when there are duplicatesBrad Fitzpatrick
Also, sort them so the results aren't random. Thanks to @junedev for the bug report & repro. Fixes #36524 Change-Id: Ic9197ebeceddfb3d0aee895d8fc12ce4d205b164 Reviewed-on: https://go-review.googlesource.com/c/go/+/214680 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-10-11mime/multipart: add Part.NextRawPart to avoid QP decodingAlex Buchanan
NextPart has automatic handling of quoted-printable encoding, which is sometimes undesirable. NextRawPart adds a method for reading a part while bypassing such automatic handling. Fixes #29090 Change-Id: I6a042a4077c64091efa3f5dbecce0d9a34ac7065 Reviewed-on: https://go-review.googlesource.com/c/go/+/152877 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-10-09all: remove the nacl port (part 1)Brad Fitzpatrick
You were a useful port and you've served your purpose. Thanks for all the play. A subsequent CL will remove amd64p32 (including assembly files and toolchain bits) and remaining bits. The amd64p32 removal will be separated into its own CL in case we want to support the Linux x32 ABI in the future and want our old amd64p32 support as a starting point. Updates #30439 Change-Id: Ia3a0c7d49804adc87bf52a4dea7e3d3007f2b1cd Reviewed-on: https://go-review.googlesource.com/c/go/+/199499 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-01mime: update type of .js and .mjs files to text/javascriptAndrew Bonventre
application/javascript is being deprecated per https://datatracker.ietf.org/doc/draft-ietf-dispatch-javascript-mjs/ Specify a charset to be consistent with other text/* mime types. Fixes #32351 Change-Id: I7300f6cfdbcf574103764991cb75172a252a3400 Reviewed-on: https://go-review.googlesource.com/c/go/+/186927 Run-TryBot: Andrew Bonventre <andybons@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2019-05-23mime: encode CTL and non-US-ASCII characters in FormatMediaTypeandrius4669
Encodes non-WSP CTL and non-US-ASCII UTF-8 characters using syntax specified in RFC 2231. Fixes #7668 Fixes #9624 Change-Id: I433f167c5bdd84a7f811ac0410b08b10790e0d9f GitHub-Last-Rev: 9c77146760341fdb3af35c1b94d4ee00ffb0daae GitHub-Pull-Request: golang/go#29328 Reviewed-on: https://go-review.googlesource.com/c/go/+/154760 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-22all: shorten some testsRuss Cox
Shorten some of the longest tests that run during all.bash. Removes 7r 50u 21s from all.bash. After this change, all.bash is under 5 minutes again on my laptop. For #26473. Change-Id: Ie0460aa935808d65460408feaed210fbaa1d5d79 Reviewed-on: https://go-review.googlesource.com/c/go/+/177559 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-21mime: add .webp for builtinEduard Urbach
This change modifies Go to include image/webp as a built-in mime type for the .webp file extension. Change-Id: Id46d34fac8cc859ddd69aa8669294815654214f8 GitHub-Last-Rev: f191e1c325126e2caeb3123c912131ce5236542b GitHub-Pull-Request: golang/go#32157 Reviewed-on: https://go-review.googlesource.com/c/go/+/178317 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-13mime: update .mjs MIME type from text/ to application/javascriptBrad Fitzpatrick
.mjs should be the same MIME type as .js, and RFC 4329 says that text/javascript is obsolete, even back in 2006: https://tools.ietf.org/html/rfc4329#section-7.1 I didn't notice this when I recently reviewed CL 169502. Also, re-sort it. Updates #30547 Change-Id: I8ed8ddaf06c8a08b010423ebd071f39ef3a325e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/175459 Reviewed-by: Andrew Bonventre <andybons@golang.org> Run-TryBot: Andrew Bonventre <andybons@golang.org>
2019-04-03mime: add .jpeg for builtinKenichi Tsunokawa
Change-Id: I32b0c02039d8baca1358dac2cc0afd14fa6cd173 GitHub-Last-Rev: d3be7aa039fbe94450c54f2c1dc5a510cf183378 GitHub-Pull-Request: golang/go#31232 Reviewed-on: https://go-review.googlesource.com/c/go/+/170657 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-27mime: add javascript module mime type (.mjs)John
There are default mime types in this package for handling static content, but there's a new one missing ".mjs" that is "Content-Type: text/javascript". https://developers.google.com/web/fundamentals/primers/modules#mjs Change-Id: Ie842ece0cb55770fb6c9eb65f8bfee2ecf7bc624 GitHub-Last-Rev: e26d9f76171c987112d5d6db292446819a8393e2 GitHub-Pull-Request: golang/go#31071 Reviewed-on: https://go-review.googlesource.com/c/go/+/169502 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-12-13mime/multipart: quote boundary in Content-Type if necessaryIan Lance Taylor
Fixes #26532 Change-Id: Ic086c90503c7b24982f947c828c7ccf016ddbf69 Reviewed-on: https://go-review.googlesource.com/c/154120 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-20mime: remove allocation introduced in recent fixBrad Fitzpatrick
CL 150417 was submitted before I could recommend this change to remove an unnecessary allocation. Updates #28849 Change-Id: I4cd655f62bb3d00eda6c997f074785385bceee0c Reviewed-on: https://go-review.googlesource.com/c/150498 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-11-20mime: correctly detect non-ASCII characters in FormatMediaTypeDavid Heuschmann
FormatMediaType used rune&0x80==0 to check if parameter values consisted of valid ascii charaters. Comparing strings using their runes instead of their bytes leads to some non-ascii strings to pass as valid. E.g. the rune for 'Ą' is 0x104, 0x104 & 0x80 => 0. Its byte representation is 0xc4 0x84, both of which result in non zero values when masked with 0x80 Fixes #28849 Change-Id: Ib9fb4968bcbbec0197d81136f380d40a2a56c14b Reviewed-on: https://go-review.googlesource.com/c/150417 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-11-09mime/multipart: check for quoted-printable case insensitivelyBrad Fitzpatrick
Fixes #28674 Change-Id: Id88e0a4b86b50eb45f0d968d7e4bbe66b7f37f82 Reviewed-on: https://go-review.googlesource.com/c/148579 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-10-10mime: add AIX operating systemClément Chigot
This commit adds AIX operating system to mime package for ppc64 architecture. Updates: #25893 Change-Id: I1b81a9204446c8c76ae24ea5c6fd33077c373ae4 Reviewed-on: https://go-review.googlesource.com/c/138723 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-09-26all: use strings.ReplaceAll and bytes.ReplaceAll where applicableBrad Fitzpatrick
I omitted vendor directories and anything necessary for bootstrapping. (Tested by bootstrapping with Go 1.4) Updates #27864 Change-Id: I7d9b68d0372d3a34dee22966cca323513ece7e8a Reviewed-on: https://go-review.googlesource.com/137856 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-09-24mime: derestrict value backslash unescaping for all encodingsEugene Kalinin
Previously consumeValue performed consumption of "unnecessary backslashes" strictly for non-ASCII and non-token runes. Thus if it encountered a backslash before a rune that is out of the ASCII range, it would erroneously skip that backslash. This change now derestricts "unnecessary backslash" unescaping for all character encodings, using "isTSpecial" instead of "!isTokenChar". This change is a follow-up of CL 32175. Fixes #25888 Change-Id: I5e02bbf9c42f753a6eb31399b8d20315af991490 Reviewed-on: https://go-review.googlesource.com/119795 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-27mime/quotedprintable: accept bytes >= 0x80Ian Lance Taylor
RFC 2045 doesn't permit non-ASCII bytes, but some systems send them anyhow. With this change, we accept them. This does make it harder to validate quotedprintable data, but on balance this seems like the best approach given the existence of systems that generate invalid data. Fixes #22597 Change-Id: I9f80f90a60b76ada2b5dea658b8dc8aace56cdbd Reviewed-on: https://go-review.googlesource.com/121095 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-26mime/multipart: restore 1.9 handling of missing/empty form-data file nameIan Lance Taylor
Revert the code changes of CL 96975 and CL 70931, but keep the tests, appropriately modified for the code changes. This restores the 1.9 handling of form-data entries with missing or empty file names. Changing the handling of this simply confused existing programs for no useful benefit. Go back to the old behavior. Updates #19183 Fixes #24041 Change-Id: I4ebc32433911e6360b9fd79d8f63a6d884822e0e Reviewed-on: https://go-review.googlesource.com/121055 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-20mime: change *.js mime type to application/javascript, not x-javascriptBrad Fitzpatrick
We delayed doing this for 4 years for fear that it might break something, but it was standardized (RFC 4329) 12 years ago, and the default in Debian and other places is correct: $ cat /etc/mime.types | grep js$ application/javascript js Time for us to change too. I doubt there will be problems, but we'll see during the Go 1.11 beta. Fixes #7498 Change-Id: Iba0bf8a6e707a64dd63317e1c0d6dd9a18634527 Reviewed-on: https://go-review.googlesource.com/120058 Reviewed-by: Andrew Bonventre <andybons@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-15mime: add .wasm for builtinYasuhiro Matsumoto
Change-Id: I9d9189ae7882164246abcc4b22d49c26d4a3f201 Reviewed-on: https://go-review.googlesource.com/118937 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-14mime/multipart: return error from NextPart if boundary is emptyConstantin Konstantinidis
NewReader cannot return an error. This behaviour is kept. NextPart returns EOF when boundary is empty. RFC 2046 does not allow it. The fix is to return an error on the call of NextPart. Fixes #23170 Change-Id: I775afd3f93e8b56e6cb274bc5c9de362a18bcc3c Reviewed-on: https://go-review.googlesource.com/118822 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-01all: update comment URLs from HTTP to HTTPS, where possibleTim Cooper
Each URL was manually verified to ensure it did not serve up incorrect content. Change-Id: I4dc846227af95a73ee9a3074d0c379ff0fa955df Reviewed-on: https://go-review.googlesource.com/115798 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2018-05-15mime: do a pre-allocation in encodeWordisharipo
The preallocated memory size is comparable to bytes.Buffer bootstraping array length (bytes.Buffer was used before rewrite to strings.Builder). Without preallocation, encodeWord does more than one allocation for almost any possible input. The regression happens because bytes.Buffer did a 80-bytes allocation at the beginning of encodeWord while strings.Builder did several smaller allocations (started with cap=0). Comparison with reported regression: name old time/op new time/op delta QEncodeWord-4 781ns ± 1% 593ns ± 1% -24.08% (p=0.008 n=5+5) name old alloc/op new alloc/op delta QEncodeWord-4 152B ± 0% 80B ± 0% -47.37% (p=0.008 n=5+5) name old allocs/op new allocs/op delta QEncodeWord-4 5.00 ± 0% 2.00 ± 0% -60.00% (p=0.008 n=5+5) Comparison with buffer solution (like before strings.Builder, but without sync pool for buffer re-using): name old time/op new time/op delta QEncodeWord-4 595ns ± 1% 593ns ± 1% ~ (p=0.460 n=5+5) name old alloc/op new alloc/op delta QEncodeWord-4 160B ± 0% 80B ± 0% -50.00% (p=0.008 n=5+5) name old allocs/op new allocs/op delta QEncodeWord-4 2.00 ± 0% 2.00 ± 0% ~ (all equal) We avoid allocation in buf.String(), as expected. Fixes #25379 Change-Id: I19763f0e593a27390c1a549b86ce6507b489046b Reviewed-on: https://go-review.googlesource.com/113235 Run-TryBot: Iskander Sharipov <iskander.sharipov@intel.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-13mime: add wasm architectureRichard Musiol
This commit adds the wasm architecture to the mime package. Updates #18892 Change-Id: I0481057bd52e39d84b3d6f5140335e293eff38f3 Reviewed-on: https://go-review.googlesource.com/106998 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-26all: use strings.Builder instead of bytes.Buffer where appropriateBrad Fitzpatrick
I grepped for "bytes.Buffer" and "buf.String" and mostly ignored test files. I skipped a few on purpose and probably missed a few others, but otherwise I think this should be most of them. Updates #18990 Change-Id: I5a6ae4296b87b416d8da02d7bfaf981d8cc14774 Reviewed-on: https://go-review.googlesource.com/102479 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-03-10mime/multipart: test for presence of filename instead of content-typeHenry Clifford
Fixes #24041 Preserving the intended fix in https://go.googlesource.com/go/+/81ec7256072ed5e20b8827c583193258769aebc0 Change-Id: I600d3d7edc74ca072a066739e2ef3235877d808f GitHub-Last-Rev: 14973d7c2bf4022c28ef4b4984ec3cd352c1d4d8 GitHub-Pull-Request: golang/go#24104 Reviewed-on: https://go-review.googlesource.com/96975 Reviewed-by: Andrew Bonventre <andybons@golang.org> Run-TryBot: Andrew Bonventre <andybons@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-31all: unindent some if bodies by exiting earlyDaniel Martí
All of these had a return or break in the else body, so flipping the condition means we can unindent and simplify. Change-Id: If93e97504480d18a0dac3f2c8ffe57ab8bcb929c Reviewed-on: https://go-review.googlesource.com/74190 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-24mime/multipart: permit empty file nameNils Larsgård
Fixes #19183 Change-Id: I11502d855f5b521b03ed7a63a990cca2d0ed4083 Reviewed-on: https://go-review.googlesource.com/70931 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-05all: revert "all: prefer strings.IndexByte over strings.Index"Marvin Stenger
This reverts https://golang.org/cl/65930. Fixes #22148 Change-Id: Ie0712621ed89c43bef94417fc32de9af77607760 Reviewed-on: https://go-review.googlesource.com/68430 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-25all: prefer strings.IndexByte over strings.IndexMarvin Stenger
strings.IndexByte was introduced in go1.2 and it can be used effectively wherever the second argument to strings.Index is exactly one byte long. This avoids generating unnecessary string symbols and saves a few calls to strings.Index. Change-Id: I1ab5edb7c4ee9058084cfa57cbcc267c2597e793 Reviewed-on: https://go-review.googlesource.com/65930 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-29mime: ignore key on ParseMediaType when value don't pass RFC 2231 checkGuilherme Rezende
Also add more test cases. Change-Id: I53cc6484b25560fc7a4b5d44e73bbd9270c25769 Reviewed-on: https://go-review.googlesource.com/59950 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-23mime/multipart: parse boundary with spaces properlyMichael Fraenkel
- spaces are allowed anywhere but the last character of a boundary Fixes #18768 Change-Id: I36b054462533ff6dfc060e37e7a58777ae4b66fe Reviewed-on: https://go-review.googlesource.com/35507 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-22mime/multipart: Allow ReadForm to process large non-file partsSteven Hartland
Allow the memory limit passed into ReadForm to be used as the memory limit for processing non-file form data as well as file form data, rather than the existing behaviour of the memory limit only applying to the file parts and the non-file parts being arbitrarily limited to 10MB. This ensures backwards compatibility while still providing the user with control over the amount of non-file data that can be processed instead of enforcing an arbitrary 10MB limit. Change-Id: I53c09eae00147d3ff2d6bdfd4e50949267932c3d Reviewed-on: https://go-review.googlesource.com/38195 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-29mime: re-accept empty encoded-textHiroshi Ioka
https://go-review.googlesource.com/37812 prohibits empty encoded-text. This CL accepts it again for backward compatibility. Change-Id: I0e0840b501927f147160b999bb59d2d029ea314c Reviewed-on: https://go-review.googlesource.com/40051 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-28mime: use sync.Map instead of RWMutex for type lookupsBryan C. Mills
This provides a significant speedup for TypeByExtension and ExtensionsByType when using many CPU cores. updates #17973 updates #18177 name old time/op new time/op delta QEncodeWord 526ns ± 3% 525ns ± 3% ~ (p=0.990 n=15+28) QEncodeWord-6 945ns ± 7% 913ns ±20% ~ (p=0.220 n=14+28) QEncodeWord-48 1.02µs ± 2% 1.00µs ± 6% -2.22% (p=0.036 n=13+27) QDecodeWord 311ns ±18% 323ns ±20% ~ (p=0.107 n=16+28) QDecodeWord-6 595ns ±12% 612ns ±11% ~ (p=0.093 n=15+27) QDecodeWord-48 592ns ± 6% 606ns ± 8% +2.39% (p=0.045 n=16+26) QDecodeHeader 389ns ± 4% 394ns ± 8% ~ (p=0.161 n=12+26) QDecodeHeader-6 685ns ±12% 674ns ±20% ~ (p=0.773 n=14+27) QDecodeHeader-48 658ns ±13% 669ns ±14% ~ (p=0.457 n=16+28) TypeByExtension/.html 77.4ns ±15% 55.5ns ±13% -28.35% (p=0.000 n=8+8) TypeByExtension/.html-6 263ns ± 9% 10ns ±21% -96.29% (p=0.000 n=8+8) TypeByExtension/.html-48 175ns ± 5% 2ns ±16% -98.88% (p=0.000 n=8+8) TypeByExtension/.HTML 113ns ± 6% 97ns ± 6% -14.37% (p=0.000 n=8+8) TypeByExtension/.HTML-6 273ns ± 7% 17ns ± 4% -93.93% (p=0.000 n=7+8) TypeByExtension/.HTML-48 175ns ± 4% 4ns ± 4% -97.73% (p=0.000 n=8+8) TypeByExtension/.unused 116ns ± 4% 90ns ± 4% -22.89% (p=0.001 n=7+7) TypeByExtension/.unused-6 262ns ± 5% 15ns ± 4% -94.17% (p=0.000 n=8+8) TypeByExtension/.unused-48 176ns ± 4% 3ns ±10% -98.10% (p=0.000 n=8+8) ExtensionsByType/text/html 630ns ± 5% 522ns ± 5% -17.19% (p=0.000 n=8+7) ExtensionsByType/text/html-6 314ns ±20% 136ns ± 6% -56.80% (p=0.000 n=8+8) ExtensionsByType/text/html-48 298ns ± 4% 104ns ± 6% -65.06% (p=0.000 n=8+8) ExtensionsByType/text/html;_charset=utf-8 1.12µs ± 3% 1.05µs ± 7% -6.19% (p=0.004 n=8+7) ExtensionsByType/text/html;_charset=utf-8-6 402ns ±11% 307ns ± 4% -23.77% (p=0.000 n=8+8) ExtensionsByType/text/html;_charset=utf-8-48 422ns ± 3% 309ns ± 4% -26.86% (p=0.000 n=8+8) ExtensionsByType/application/octet-stream 810ns ± 2% 747ns ± 5% -7.74% (p=0.000 n=8+8) ExtensionsByType/application/octet-stream-6 289ns ± 9% 185ns ± 8% -36.15% (p=0.000 n=7+8) ExtensionsByType/application/octet-stream-48 267ns ± 6% 94ns ± 2% -64.91% (p=0.000 n=8+7) name old alloc/op new alloc/op delta QEncodeWord 48.0B ± 0% 48.0B ± 0% ~ (all equal) QEncodeWord-6 48.0B ± 0% 48.0B ± 0% ~ (all equal) QEncodeWord-48 48.0B ± 0% 48.0B ± 0% ~ (all equal) QDecodeWord 48.0B ± 0% 48.0B ± 0% ~ (all equal) QDecodeWord-6 48.0B ± 0% 48.0B ± 0% ~ (all equal) QDecodeWord-48 48.0B ± 0% 48.0B ± 0% ~ (all equal) QDecodeHeader 48.0B ± 0% 48.0B ± 0% ~ (all equal) QDecodeHeader-6 48.0B ± 0% 48.0B ± 0% ~ (all equal) QDecodeHeader-48 48.0B ± 0% 48.0B ± 0% ~ (all equal) TypeByExtension/.html 0.00B 0.00B ~ (all equal) TypeByExtension/.html-6 0.00B 0.00B ~ (all equal) TypeByExtension/.html-48 0.00B 0.00B ~ (all equal) TypeByExtension/.HTML 0.00B 0.00B ~ (all equal) TypeByExtension/.HTML-6 0.00B 0.00B ~ (all equal) TypeByExtension/.HTML-48 0.00B 0.00B ~ (all equal) TypeByExtension/.unused 0.00B 0.00B ~ (all equal) TypeByExtension/.unused-6 0.00B 0.00B ~ (all equal) TypeByExtension/.unused-48 0.00B 0.00B ~ (all equal) ExtensionsByType/text/html 192B ± 0% 176B ± 0% -8.33% (p=0.000 n=8+8) ExtensionsByType/text/html-6 192B ± 0% 176B ± 0% -8.33% (p=0.000 n=8+8) ExtensionsByType/text/html-48 192B ± 0% 176B ± 0% -8.33% (p=0.000 n=8+8) ExtensionsByType/text/html;_charset=utf-8 480B ± 0% 464B ± 0% -3.33% (p=0.000 n=8+8) ExtensionsByType/text/html;_charset=utf-8-6 480B ± 0% 464B ± 0% -3.33% (p=0.000 n=8+8) ExtensionsByType/text/html;_charset=utf-8-48 480B ± 0% 464B ± 0% -3.33% (p=0.000 n=8+8) ExtensionsByType/application/octet-stream 160B ± 0% 160B ± 0% ~ (all equal) ExtensionsByType/application/octet-stream-6 160B ± 0% 160B ± 0% ~ (all equal) ExtensionsByType/application/octet-stream-48 160B ± 0% 160B ± 0% ~ (all equal) name old allocs/op new allocs/op delta QEncodeWord 1.00 ± 0% 1.00 ± 0% ~ (all equal) QEncodeWord-6 1.00 ± 0% 1.00 ± 0% ~ (all equal) QEncodeWord-48 1.00 ± 0% 1.00 ± 0% ~ (all equal) QDecodeWord 2.00 ± 0% 2.00 ± 0% ~ (all equal) QDecodeWord-6 2.00 ± 0% 2.00 ± 0% ~ (all equal) QDecodeWord-48 2.00 ± 0% 2.00 ± 0% ~ (all equal) QDecodeHeader 2.00 ± 0% 2.00 ± 0% ~ (all equal) QDecodeHeader-6 2.00 ± 0% 2.00 ± 0% ~ (all equal) QDecodeHeader-48 2.00 ± 0% 2.00 ± 0% ~ (all equal) TypeByExtension/.html 0.00 0.00 ~ (all equal) TypeByExtension/.html-6 0.00 0.00 ~ (all equal) TypeByExtension/.html-48 0.00 0.00 ~ (all equal) TypeByExtension/.HTML 0.00 0.00 ~ (all equal) TypeByExtension/.HTML-6 0.00 0.00 ~ (all equal) TypeByExtension/.HTML-48 0.00 0.00 ~ (all equal) TypeByExtension/.unused 0.00 0.00 ~ (all equal) TypeByExtension/.unused-6 0.00 0.00 ~ (all equal) TypeByExtension/.unused-48 0.00 0.00 ~ (all equal) ExtensionsByType/text/html 3.00 ± 0% 3.00 ± 0% ~ (all equal) ExtensionsByType/text/html-6 3.00 ± 0% 3.00 ± 0% ~ (all equal) ExtensionsByType/text/html-48 3.00 ± 0% 3.00 ± 0% ~ (all equal) ExtensionsByType/text/html;_charset=utf-8 4.00 ± 0% 4.00 ± 0% ~ (all equal) ExtensionsByType/text/html;_charset=utf-8-6 4.00 ± 0% 4.00 ± 0% ~ (all equal) ExtensionsByType/text/html;_charset=utf-8-48 4.00 ± 0% 4.00 ± 0% ~ (all equal) ExtensionsByType/application/octet-stream 2.00 ± 0% 2.00 ± 0% ~ (all equal) ExtensionsByType/application/octet-stream-6 2.00 ± 0% 2.00 ± 0% ~ (all equal) ExtensionsByType/application/octet-stream-48 2.00 ± 0% 2.00 ± 0% ~ (all equal) https://perf.golang.org/search?q=upload:20170427.4 Change-Id: I35438be087ad6eb3d5da9119b395723ea5babaf6 Reviewed-on: https://go-review.googlesource.com/41990 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-04-09mime: fix panic parsing 'encoded-word'Hiroshi Ioka
https://go-review.googlesource.com/37812 says fix panic parsing. Actually, it doesn't. so fix it. Fixes #19416 Change-Id: Ie0c4241f10e5ebcbac20e184c2a7b13b22632eab Reviewed-on: https://go-review.googlesource.com/37912 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-01mime/multipart: add Size to FileHeaderJamie Stackhouse
This change makes it possible to retrieve the size of a file part without having to Seek to determine file-size. Resolves #19501 Change-Id: I7b9994c4cf41c9b06a046eb7046f8952ae1f15e9 Reviewed-on: https://go-review.googlesource.com/39223 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-17mime: handling invalid mime media parametersAlexey Neganov
Sometimes it's necessary to deal with emails that do not follow the specification; in particular, it's possible to download such email via gmail. When the existing implementation handle invalid mime media parameters, it returns nils and error, although there is a valid media type, which may be returned. If this behavior changes, it may not affect any existing programs, but it will help to parse some emails. Fixes #19498 Change-Id: Ieb2fdbddfd93857faee941d2aa49d59e286d57fd Reviewed-on: https://go-review.googlesource.com/38190 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-07mime: fix panic parsing 'encoded-word', be stricterHiroshi Ioka
Fixes #19416 Change-Id: I23c69ff637abaa202909f1cba6ed41b3cfe3d117 Reviewed-on: https://go-review.googlesource.com/37812 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-03-06all: remove the the duplicate wordsEitan Adler
Change-Id: I6343c162e27e2e492547c96f1fc504909b1c03c0 Reviewed-on: https://go-review.googlesource.com/37793 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-02-14mime: add benchmarks for TypeByExtension and ExtensionsByTypeBryan C. Mills
These are possible use-cases for sync.Map. Updates golang/go#18177 Change-Id: I5e2a3d1249967c37d3f89a41122bf4a90522db11 Reviewed-on: https://go-review.googlesource.com/36964 Reviewed-by: Ian Lance Taylor <iant@golang.org>