1 package Thrasher
::Nodeprep
;
5 # This module uses the Unicode::Stringprep module, combined with the
6 # specification in RFC3920, to define "nodeprep" and "stringprep"
7 # functions that can be used for converting strings of unknown safety
10 use Unicode
::Stringprep
;
11 use Unicode
::Stringprep
::Mapping
;
12 use Unicode
::Stringprep
::Prohibited
;
18 our @EXPORT_OK = qw(nodeprep stringprep);
19 our %EXPORT_TAGS = (all
=> \
@EXPORT_OK);
21 *nodeprep
= Unicode
::Stringprep
->new
25 # In accordance with RFC3920 section A.3
26 @Unicode::Stringprep
::Mapping
::B1
,
27 @Unicode::Stringprep
::Mapping
::B2
,
29 # The standard specifies these as banned in A.5, but I'm going to map
30 # them to blank strings instead, so they are eliminated instead
32 (map { defined($_) ?
($_, '') : () }
33 @Unicode::Stringprep
::Prohibited
::C11
,
34 @Unicode::Stringprep
::Prohibited
::C12
,
35 @Unicode::Stringprep
::Prohibited
::C21
,
36 @Unicode::Stringprep
::Prohibited
::C22
,
37 @Unicode::Stringprep
::Prohibited
::C3
,
38 @Unicode::Stringprep
::Prohibited
::C4
,
39 @Unicode::Stringprep
::Prohibited
::C5
,
40 @Unicode::Stringprep
::Prohibited
::C6
,
41 @Unicode::Stringprep
::Prohibited
::C7
,
42 @Unicode::Stringprep
::Prohibited
::C8
,
43 @Unicode::Stringprep
::Prohibited
::C9
,
55 ord('@') => '%' # I don't really like this but it's traditional
58 # Section A.4 specifies normalization form KC
61 # Prohibited characters are replaced with blanks
65 # Section A.6 specifies handling bi-directional strings.
71 *resource_prep
= Unicode
::Stringprep
->new
76 @Unicode::Stringprep
::Mapping
::B1
,
77 (map { defined($_) ?
($_, '') : () }
78 @Unicode::Stringprep
::Prohibited
::C12
,
79 @Unicode::Stringprep
::Prohibited
::C21
,
80 @Unicode::Stringprep
::Prohibited
::C22
,
81 @Unicode::Stringprep
::Prohibited
::C3
,
82 @Unicode::Stringprep
::Prohibited
::C4
,
83 @Unicode::Stringprep
::Prohibited
::C5
,
84 @Unicode::Stringprep
::Prohibited
::C6
,
85 @Unicode::Stringprep
::Prohibited
::C7
,
86 @Unicode::Stringprep
::Prohibited
::C8
,
87 @Unicode::Stringprep
::Prohibited
::C9