this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

pkg/net: add regression tests for net.FQDN with invalid domain names

These tests demonstrate that net.FQDN incorrectly accepts strings
containing spaces, due to an upstream bug with idna.StrictDomainName.

For #2431.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Change-Id: I86b27e2a9c144a33608863b3c764b14b99507369
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1235281
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com>
Reviewed-by: Roger Peppe <rogpeppe@gmail.com>

+40 -26
+40 -26
pkg/net/testdata/gen.txtar
··· 5 5 6 6 t1: net.FQDN & "foo.bar." 7 7 t2: net.FQDN("foo.bararararararararararararararararararararararararararararararararara") 8 + 9 + // Regression test for https://cuelang.org/issue/2431. 10 + // StrictDomainName was not being applied due to an upstream bug. 11 + t48: net.FQDN("hello world") 12 + t49: net.FQDN("foo bar.") 13 + t50: net.FQDN("valid.example.com.") 14 + t51: net.FQDN("under_score.example.com.") 8 15 t3: net.SplitHostPort("[::%lo0]:80") 9 16 t4: net.JoinHostPort("mod.test", "80") 10 17 t5: net.JoinHostPort("2001:db8::1", 80) ··· 57 64 -- out/net-v3 -- 58 65 Errors: 59 66 t20b: invalid value 123 (does not satisfy net.IPCIDR): invalid type int for IP CIDR: 60 - ./in.cue:23:7 67 + ./in.cue:30:7 61 68 t20c: invalid value 123 (does not satisfy net.IP): invalid type int for IP address: 62 - ./in.cue:24:7 69 + ./in.cue:31:7 63 70 t20d: invalid value 123 (does not satisfy net.IPv4): invalid type int for IP address: 64 - ./in.cue:25:7 71 + ./in.cue:32:7 65 72 t20e: invalid value 123 (does not satisfy net.IPv6): invalid type int for IP address: 66 - ./in.cue:26:7 73 + ./in.cue:33:7 67 74 t25: invalid value "2001:db8::1234567" (does not satisfy net.IPv6): ParseAddr("2001:db8::1234567"): each group must have 4 or less digits (at "1234567"): 68 - ./in.cue:31:6 69 - ./in.cue:31:17 75 + ./in.cue:38:6 76 + ./in.cue:38:17 70 77 t30: invalid value "%" (does not satisfy net.URL): parse "%": invalid URL escape "%": 71 - ./in.cue:36:6 72 - ./in.cue:36:16 78 + ./in.cue:43:6 79 + ./in.cue:43:16 73 80 t32: invalid value "/foo/bar" (does not satisfy net.AbsURL): URL is not absolute: 74 - ./in.cue:38:6 75 - ./in.cue:38:19 81 + ./in.cue:45:6 82 + ./in.cue:45:19 76 83 t34: invalid value "%" (does not satisfy net.AbsURL): parse "%": invalid URL escape "%": 77 - ./in.cue:40:6 78 - ./in.cue:40:19 84 + ./in.cue:47:6 85 + ./in.cue:47:19 79 86 t9: invalid value "23.23.23.2333" (does not satisfy net.IPv4): ParseAddr("23.23.23.2333"): IPv4 field has value >255: 80 - ./in.cue:11:6 81 - ./in.cue:11:17 87 + ./in.cue:18:6 88 + ./in.cue:18:17 82 89 t7: error in call to net.JoinHostPort: invalid host [192, 30, 4]: 83 - ./in.cue:9:6 90 + ./in.cue:16:6 84 91 t13: invalid value "ff02::1:3" (does not satisfy net.IPv4): 85 - ./in.cue:15:6 86 - ./in.cue:15:19 92 + ./in.cue:22:6 93 + ./in.cue:22:19 87 94 t20: error in call to net.IPCIDR: netip.ParsePrefix("172.16.12.3"): no '/': 88 - ./in.cue:22:6 95 + ./in.cue:29:6 89 96 t27: invalid value "23.23.23.23" (does not satisfy net.IPv6): 90 - ./in.cue:33:6 91 - ./in.cue:33:19 97 + ./in.cue:40:6 98 + ./in.cue:40:19 92 99 t39: error in call to net.AddIP: ParseAddr("invalid ip"): unable to parse IP: 93 - ./in.cue:45:6 100 + ./in.cue:52:6 94 101 t40: error in call to net.AddIP: IP address arithmetic resulted in out-of-range address (underflow): 95 - ./in.cue:46:6 102 + ./in.cue:53:6 96 103 t41: error in call to net.AddIP: IP address arithmetic resulted in out-of-range address (overflow): 97 - ./in.cue:47:6 104 + ./in.cue:54:6 98 105 t45: error in call to net.AddIPCIDR: netip.ParsePrefix("192.168.0.0"): no '/': 99 - ./in.cue:51:6 106 + ./in.cue:58:6 100 107 t46: error in call to net.AddIPCIDR: IP address arithmetic resulted in out-of-range address (underflow): 101 - ./in.cue:52:6 108 + ./in.cue:59:6 102 109 t47: error in call to net.AddIPCIDR: IP address arithmetic resulted in out-of-range address (overflow): 103 - ./in.cue:53:6 110 + ./in.cue:60:6 104 111 105 112 Result: 106 113 t1: "foo.bar." 107 114 t2: false 115 + 116 + // Regression test for https://cuelang.org/issue/2431. 117 + // StrictDomainName was not being applied due to an upstream bug. 118 + t48: true 119 + t49: true 120 + t50: true 121 + t51: true 108 122 t3: ["::%lo0", "80"] 109 123 t4: "mod.test:80" 110 124 t5: "[2001:db8::1]:80"