aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/mime/mediatype_test.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2018-01-09 01:23:08 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2018-01-09 01:23:08 +0000
commit1a2f01efa63036a5104f203a4789e682c0e0915d (patch)
tree373e15778dc8295354584e1f86915ae493b604ff /libgo/go/mime/mediatype_test.go
parent8799df67f2dab88f9fda11739c501780a85575e2 (diff)
downloadgcc-1a2f01efa63036a5104f203a4789e682c0e0915d.zip
gcc-1a2f01efa63036a5104f203a4789e682c0e0915d.tar.gz
gcc-1a2f01efa63036a5104f203a4789e682c0e0915d.tar.bz2
libgo: update to Go1.10beta1
Update the Go library to the 1.10beta1 release. Requires a few changes to the compiler for modifications to the map runtime code, and to handle some nowritebarrier cases in the runtime. Reviewed-on: https://go-review.googlesource.com/86455 gotools/: * Makefile.am (go_cmd_vet_files): New variable. (go_cmd_buildid_files, go_cmd_test2json_files): New variables. (s-zdefaultcc): Change from constants to functions. (noinst_PROGRAMS): Add vet, buildid, and test2json. (cgo$(EXEEXT)): Link against $(LIBGOTOOL). (vet$(EXEEXT)): New target. (buildid$(EXEEXT)): New target. (test2json$(EXEEXT)): New target. (install-exec-local): Install all $(noinst_PROGRAMS). (uninstall-local): Uninstasll all $(noinst_PROGRAMS). (check-go-tool): Depend on $(noinst_PROGRAMS). Copy down objabi.go. (check-runtime): Depend on $(noinst_PROGRAMS). (check-cgo-test, check-carchive-test): Likewise. (check-vet): New target. (check): Depend on check-vet. Look at cmd_vet-testlog. (.PHONY): Add check-vet. * Makefile.in: Rebuild. From-SVN: r256365
Diffstat (limited to 'libgo/go/mime/mediatype_test.go')
-rw-r--r--libgo/go/mime/mediatype_test.go183
1 files changed, 181 insertions, 2 deletions
diff --git a/libgo/go/mime/mediatype_test.go b/libgo/go/mime/mediatype_test.go
index 3ba8ee1..88d742f 100644
--- a/libgo/go/mime/mediatype_test.go
+++ b/libgo/go/mime/mediatype_test.go
@@ -139,79 +139,248 @@ func TestParseMediaType(t *testing.T) {
// Tests from http://greenbytes.de/tech/tc2231/
// Note: Backslash escape handling is a bit loose, like MSIE.
- // TODO(bradfitz): add the rest of the tests from that site.
+
+ // #attonly
+ {`attachment`,
+ "attachment",
+ m()},
+ // #attonlyucase
+ {`ATTACHMENT`,
+ "attachment",
+ m()},
+ // #attwithasciifilename
+ {`attachment; filename="foo.html"`,
+ "attachment",
+ m("filename", "foo.html")},
+ // #attwithasciifilename25
+ {`attachment; filename="0000000000111111111122222"`,
+ "attachment",
+ m("filename", "0000000000111111111122222")},
+ // #attwithasciifilename35
+ {`attachment; filename="00000000001111111111222222222233333"`,
+ "attachment",
+ m("filename", "00000000001111111111222222222233333")},
+ // #attwithasciifnescapedchar
{`attachment; filename="f\oo.html"`,
"attachment",
m("filename", "f\\oo.html")},
+ // #attwithasciifnescapedquote
{`attachment; filename="\"quoting\" tested.html"`,
"attachment",
m("filename", `"quoting" tested.html`)},
+ // #attwithquotedsemicolon
{`attachment; filename="Here's a semicolon;.html"`,
"attachment",
m("filename", "Here's a semicolon;.html")},
+ // #attwithfilenameandextparam
+ {`attachment; foo="bar"; filename="foo.html"`,
+ "attachment",
+ m("foo", "bar", "filename", "foo.html")},
+ // #attwithfilenameandextparamescaped
{`attachment; foo="\"\\";filename="foo.html"`,
"attachment",
m("foo", "\"\\", "filename", "foo.html")},
+ // #attwithasciifilenameucase
+ {`attachment; FILENAME="foo.html"`,
+ "attachment",
+ m("filename", "foo.html")},
+ // #attwithasciifilenamenq
{`attachment; filename=foo.html`,
"attachment",
m("filename", "foo.html")},
+ // #attwithasciifilenamenqs
{`attachment; filename=foo.html ;`,
"attachment",
m("filename", "foo.html")},
+ // #attwithfntokensq
{`attachment; filename='foo.html'`,
"attachment",
m("filename", "'foo.html'")},
+ // #attwithisofnplain
+ {`attachment; filename="foo-ä.html"`,
+ "attachment",
+ m("filename", "foo-ä.html")},
+ // #attwithutf8fnplain
+ {`attachment; filename="foo-ä.html"`,
+ "attachment",
+ m("filename", "foo-ä.html")},
+ // #attwithfnrawpctenca
{`attachment; filename="foo-%41.html"`,
"attachment",
m("filename", "foo-%41.html")},
+ // #attwithfnusingpct
+ {`attachment; filename="50%.html"`,
+ "attachment",
+ m("filename", "50%.html")},
+ // #attwithfnrawpctencaq
{`attachment; filename="foo-%\41.html"`,
"attachment",
m("filename", "foo-%\\41.html")},
+ // #attwithnamepct
+ {`attachment; name="foo-%41.html"`,
+ "attachment",
+ m("name", "foo-%41.html")},
+ // #attwithfilenamepctandiso
+ {`attachment; name="ä-%41.html"`,
+ "attachment",
+ m("name", "ä-%41.html")},
+ // #attwithfnrawpctenclong
+ {`attachment; filename="foo-%c3%a4-%e2%82%ac.html"`,
+ "attachment",
+ m("filename", "foo-%c3%a4-%e2%82%ac.html")},
+ // #attwithasciifilenamews1
+ {`attachment; filename ="foo.html"`,
+ "attachment",
+ m("filename", "foo.html")},
+ // #attmissingdisposition
{`filename=foo.html`,
"", m()},
+ // #attmissingdisposition2
{`x=y; filename=foo.html`,
"", m()},
+ // #attmissingdisposition3
{`"foo; filename=bar;baz"; filename=qux`,
"", m()},
+ // #attmissingdisposition4
+ {`filename=foo.html, filename=bar.html`,
+ "", m()},
+ // #emptydisposition
+ {`; filename=foo.html`,
+ "", m()},
+ // #doublecolon
+ {`: inline; attachment; filename=foo.html`,
+ "", m()},
+ // #attandinline
{`inline; attachment; filename=foo.html`,
"", m()},
+ // #attandinline2
+ {`attachment; inline; filename=foo.html`,
+ "", m()},
+ // #attbrokenquotedfn
{`attachment; filename="foo.html".txt`,
"", m()},
+ // #attbrokenquotedfn2
{`attachment; filename="bar`,
"", m()},
+ // #attbrokenquotedfn3
+ {`attachment; filename=foo"bar;baz"qux`,
+ "", m()},
+ // #attmultinstances
+ {`attachment; filename=foo.html, attachment; filename=bar.html`,
+ "", m()},
+ // #attmissingdelim
+ {`attachment; foo=foo filename=bar`,
+ "", m()},
+ // #attmissingdelim2
+ {`attachment; filename=bar foo=foo`,
+ "", m()},
+ // #attmissingdelim3
+ {`attachment filename=bar`,
+ "", m()},
+ // #attreversed
+ {`filename=foo.html; attachment`,
+ "", m()},
+ // #attconfusedparam
+ {`attachment; xfilename=foo.html`,
+ "attachment",
+ m("xfilename", "foo.html")},
+ // #attcdate
{`attachment; creation-date="Wed, 12 Feb 1997 16:29:51 -0500"`,
"attachment",
m("creation-date", "Wed, 12 Feb 1997 16:29:51 -0500")},
+ // #attmdate
+ {`attachment; modification-date="Wed, 12 Feb 1997 16:29:51 -0500"`,
+ "attachment",
+ m("modification-date", "Wed, 12 Feb 1997 16:29:51 -0500")},
+ // #dispext
{`foobar`, "foobar", m()},
+ // #dispextbadfn
+ {`attachment; example="filename=example.txt"`,
+ "attachment",
+ m("example", "filename=example.txt")},
+ // #attwithfn2231utf8
+ {`attachment; filename*=UTF-8''foo-%c3%a4-%e2%82%ac.html`,
+ "attachment",
+ m("filename", "foo-ä-€.html")},
+ // #attwithfn2231noc
+ {`attachment; filename*=''foo-%c3%a4-%e2%82%ac.html`,
+ "attachment",
+ m()},
+ // #attwithfn2231utf8comp
+ {`attachment; filename*=UTF-8''foo-a%cc%88.html`,
+ "attachment",
+ m("filename", "foo-ä.html")},
+ // #attwithfn2231ws2
+ {`attachment; filename*= UTF-8''foo-%c3%a4.html`,
+ "attachment",
+ m("filename", "foo-ä.html")},
+ // #attwithfn2231ws3
{`attachment; filename* =UTF-8''foo-%c3%a4.html`,
"attachment",
m("filename", "foo-ä.html")},
+ // #attwithfn2231quot
+ {`attachment; filename*="UTF-8''foo-%c3%a4.html"`,
+ "attachment",
+ m("filename", "foo-ä.html")},
+ // #attwithfn2231quot2
+ {`attachment; filename*="foo%20bar.html"`,
+ "attachment",
+ m()},
+ // #attwithfn2231singleqmissing
+ {`attachment; filename*=UTF-8'foo-%c3%a4.html`,
+ "attachment",
+ m()},
+ // #attwithfn2231nbadpct1
+ {`attachment; filename*=UTF-8''foo%`,
+ "attachment",
+ m()},
+ // #attwithfn2231nbadpct2
+ {`attachment; filename*=UTF-8''f%oo.html`,
+ "attachment",
+ m()},
+ // #attwithfn2231dpct
{`attachment; filename*=UTF-8''A-%2541.html`,
"attachment",
m("filename", "A-%41.html")},
+ // #attfncont
{`attachment; filename*0="foo."; filename*1="html"`,
"attachment",
m("filename", "foo.html")},
+ // #attfncontenc
{`attachment; filename*0*=UTF-8''foo-%c3%a4; filename*1=".html"`,
"attachment",
m("filename", "foo-ä.html")},
+ // #attfncontlz
{`attachment; filename*0="foo"; filename*01="bar"`,
"attachment",
m("filename", "foo")},
+ // #attfncontnc
{`attachment; filename*0="foo"; filename*2="bar"`,
"attachment",
m("filename", "foo")},
- {`attachment; filename*1="foo"; filename*2="bar"`,
+ // #attfnconts1
+ {`attachment; filename*1="foo."; filename*2="html"`,
"attachment", m()},
+ // #attfncontord
{`attachment; filename*1="bar"; filename*0="foo"`,
"attachment",
m("filename", "foobar")},
+ // #attfnboth
{`attachment; filename="foo-ae.html"; filename*=UTF-8''foo-%c3%a4.html`,
"attachment",
m("filename", "foo-ä.html")},
+ // #attfnboth2
{`attachment; filename*=UTF-8''foo-%c3%a4.html; filename="foo-ae.html"`,
"attachment",
m("filename", "foo-ä.html")},
+ // #attfnboth3
+ {`attachment; filename*0*=ISO-8859-15''euro-sign%3d%a4; filename*=ISO-8859-1''currency-sign%3d%a4`,
+ "attachment",
+ m()},
+ // #attnewandfn
+ {`attachment; foobar=x; filename="foo.html"`,
+ "attachment",
+ m("foobar", "x", "filename", "foo.html")},
// Browsers also just send UTF-8 directly without RFC 2231,
// at least when the source page is served with UTF-8.
@@ -265,6 +434,16 @@ var badMediaTypeTests = []badMediaTypeTest{
"application/pdf", "mime: invalid media parameter"},
{"bogus/<script>alert</script>", "", "mime: expected token after slash"},
{"bogus/bogus<script>alert</script>", "", "mime: unexpected content after media subtype"},
+ // Tests from http://greenbytes.de/tech/tc2231/
+ {`"attachment"`, "attachment", "mime: no media type"},
+ {"attachment; filename=foo,bar.html", "attachment", "mime: invalid media parameter"},
+ {"attachment; ;filename=foo", "attachment", "mime: invalid media parameter"},
+ {"attachment; filename=foo bar.html", "attachment", "mime: invalid media parameter"},
+ {`attachment; filename="foo.html"; filename="bar.html"`, "attachment", "mime: duplicate parameter name"},
+ {"attachment; filename=foo[1](2).html", "attachment", "mime: invalid media parameter"},
+ {"attachment; filename=foo-ä.html", "attachment", "mime: invalid media parameter"},
+ {"attachment; filename=foo-ä.html", "attachment", "mime: invalid media parameter"},
+ {`attachment; filename *=UTF-8''foo-%c3%a4.html`, "attachment", "mime: invalid media parameter"},
}
func TestParseMediaTypeBogus(t *testing.T) {