summaryrefslogtreecommitdiffstats
path: root/vendor/golang.org/x/text/internal/export
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/text/internal/export')
-rw-r--r--vendor/golang.org/x/text/internal/export/idna/example_test.go7
-rw-r--r--vendor/golang.org/x/text/internal/export/idna/idna.go13
2 files changed, 11 insertions, 9 deletions
diff --git a/vendor/golang.org/x/text/internal/export/idna/example_test.go b/vendor/golang.org/x/text/internal/export/idna/example_test.go
index 6e31be97e..6e6b8727c 100644
--- a/vendor/golang.org/x/text/internal/export/idna/example_test.go
+++ b/vendor/golang.org/x/text/internal/export/idna/example_test.go
@@ -49,6 +49,10 @@ func ExampleNew() {
idna.Transitional(true)) // Map ß -> ss
fmt.Println(p.ToASCII("*.faß.com"))
+ // Lookup for registration. Also does not allow '*'.
+ p = idna.New(idna.ValidateForRegistration())
+ fmt.Println(p.ToUnicode("*.faß.com"))
+
// Set up a profile maps for lookup, but allows wild cards.
p = idna.New(
idna.MapForLookup(),
@@ -58,6 +62,7 @@ func ExampleNew() {
// Output:
// *.xn--fa-hia.com <nil>
- // *.fass.com idna: disallowed rune U+002E
+ // *.fass.com idna: disallowed rune U+002A
+ // *.faß.com idna: disallowed rune U+002A
// *.fass.com <nil>
}
diff --git a/vendor/golang.org/x/text/internal/export/idna/idna.go b/vendor/golang.org/x/text/internal/export/idna/idna.go
index a3d9ad29d..3184fbbd9 100644
--- a/vendor/golang.org/x/text/internal/export/idna/idna.go
+++ b/vendor/golang.org/x/text/internal/export/idna/idna.go
@@ -373,23 +373,20 @@ func validateRegistration(p *Profile, s string) (string, error) {
if !norm.NFC.IsNormalString(s) {
return s, &labelError{s, "V1"}
}
- var err error
for i := 0; i < len(s); {
v, sz := trie.lookupString(s[i:])
- i += sz
// Copy bytes not copied so far.
switch p.simplify(info(v).category()) {
// TODO: handle the NV8 defined in the Unicode idna data set to allow
// for strict conformance to IDNA2008.
case valid, deviation:
case disallowed, mapped, unknown, ignored:
- if err == nil {
- r, _ := utf8.DecodeRuneInString(s[i:])
- err = runeError(r)
- }
+ r, _ := utf8.DecodeRuneInString(s[i:])
+ return s, runeError(r)
}
+ i += sz
}
- return s, err
+ return s, nil
}
func validateAndMap(p *Profile, s string) (string, error) {
@@ -408,7 +405,7 @@ func validateAndMap(p *Profile, s string) (string, error) {
continue
case disallowed:
if err == nil {
- r, _ := utf8.DecodeRuneInString(s[i:])
+ r, _ := utf8.DecodeRuneInString(s[start:])
err = runeError(r)
}
continue