Documentation ¶
Overview ¶
Package stringprep provides data tables and algorithms for RFC-3454, including errata (as of 2018-02). It also provides a profile for SASLprep as defined in RFC-4013.
Example (CustomProfile) ¶
package main import ( "fmt" "github.com/xdg-go/stringprep" ) func main() { customProfile := stringprep.Profile{ Mappings: []stringprep.Mapping{ stringprep.TableB1, stringprep.TableB2, }, Normalize: true, Prohibits: []stringprep.Set{ stringprep.TableC1_1, stringprep.TableC1_2, }, CheckBiDi: true, } prepped, err := customProfile.Prepare("TrustNô1") if err != nil { panic("stringprep failed") } fmt.Print(prepped) }
Output: trustnô1
Example (SASLprep) ¶
package main import ( "fmt" "github.com/xdg-go/stringprep" ) func main() { prepped, err := stringprep.SASLprep.Prepare("TrustNô1") if err != nil { panic("SASLprep failed") } fmt.Print(prepped) }
Output: TrustNô1
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
Error describes problems encountered during stringprep, including what rune was problematic.
type Mapping ¶
Mapping represents a stringprep mapping, from a single rune to zero or more runes.
var TableB1 Mapping = tableB1
TableB1 represents RFC-3454 Table B.1.
var TableB2 Mapping = tableB2
TableB2 represents RFC-3454 Table B.2.
var TableB3 Mapping = tableB3
TableB3 represents RFC-3454 Table B.3.
type Profile ¶
Profile represents a stringprep profile.
var SASLprep Profile = saslprep
SASLprep is a pre-defined stringprep profile for user names and passwords as described in RFC-4013.
Because the stringprep distinction between query and stored strings was intended for compatibility across profile versions, but SASLprep was never updated and is now deprecated, this profile only operates in stored strings mode, prohibiting unassigned code points.
type RuneRange ¶
type RuneRange [2]rune
RuneRange represents a close-ended range of runes: [N,M]. For a range consisting of a single rune, N and M will be equal.
type Set ¶
type Set []RuneRange
Set represents a stringprep data table used to identify runes of a particular type.
var TableA1 Set = tableA1
TableA1 represents RFC-3454 Table A.1.
var TableC1_1 Set = tableC1_1
TableC1_1 represents RFC-3454 Table C.1.1.
var TableC1_2 Set = tableC1_2
TableC1_2 represents RFC-3454 Table C.1.2.
var TableC2_1 Set = tableC2_1
TableC2_1 represents RFC-3454 Table C.2.1.
var TableC2_2 Set = tableC2_2
TableC2_2 represents RFC-3454 Table C.2.2.
var TableC3 Set = tableC3
TableC3 represents RFC-3454 Table C.3.
var TableC4 Set = tableC4
TableC4 represents RFC-3454 Table C.4.
var TableC5 Set = tableC5
TableC5 represents RFC-3454 Table C.5.
var TableC6 Set = tableC6
TableC6 represents RFC-3454 Table C.6.
var TableC7 Set = tableC7
TableC7 represents RFC-3454 Table C.7.
var TableC8 Set = tableC8
TableC8 represents RFC-3454 Table C.8.
var TableC9 Set = tableC9
TableC9 represents RFC-3454 Table C.9.
var TableD1 Set = tableD1
TableD1 represents RFC-3454 Table D.1.
var TableD2 Set = tableD2
TableD2 represents RFC-3454 Table D.2.