github.com/insionng/yougam@v0.0.0-20170714101924-2bc18d833463/libraries/golang/text/secure/precis/profiles.go (about) 1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package precis 6 7 import ( 8 "unicode" 9 10 "github.com/insionng/yougam/libraries/x/text/runes" 11 "github.com/insionng/yougam/libraries/x/text/transform" 12 "github.com/insionng/yougam/libraries/x/text/unicode/norm" 13 "github.com/insionng/yougam/libraries/x/text/width" 14 ) 15 16 var ( 17 Nickname Profile = nickname // Implements the Nickname profile specified in RFC 7700. 18 UsernameCaseMapped Profile = usernamecasemap // Implements the UsernameCaseMapped profile specified in RFC 7613. 19 UsernameCasePreserved Profile = usernamenocasemap // Implements the UsernameCasePreserved profile specified in RFC 7613. 20 OpaqueString Profile = opaquestring // Implements the OpaqueString profile defined in RFC 7613 for passwords and other secure labels. 21 ) 22 23 // TODO: mvl: "Ultimately, I would manually define the structs for the internal 24 // profiles. This avoid pulling in unneeded tables when they are not used." 25 var ( 26 nickname Profile = NewFreeform( 27 AdditionalMapping(func() transform.Transformer { 28 return &nickAdditionalMapping{} 29 }), 30 IgnoreCase, 31 Norm(norm.NFKC), 32 DisallowEmpty, 33 ) 34 usernamecasemap Profile = NewIdentifier( 35 AllowWide, 36 FoldCase(), 37 Norm(norm.NFC), 38 // TODO: BIDI rule 39 ) 40 usernamenocasemap Profile = NewIdentifier( 41 AllowWide, 42 Norm(norm.NFC), 43 Width(width.Fold), // TODO: Is this correct? 44 // TODO: BIDI rule 45 ) 46 opaquestring Profile = NewFreeform( 47 AdditionalMapping(func() transform.Transformer { 48 return runes.Map(func(r rune) rune { 49 if unicode.Is(unicode.Zs, r) { 50 return ' ' 51 } 52 return r 53 }) 54 }), 55 Norm(norm.NFC), 56 DisallowEmpty, 57 ) 58 )