This file is indexed.

/usr/share/perl5/NAMEPREP.pm is in libopensrs-perl 3.0.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package NAMEPREP;

$VERSION = '3';

use strict;
use CHARLINT;
use Unicode::String qw(utf8 uchr);

Unicode::String->stringify_as('utf8');

my %RACESETTINGS;

sub Initialise
{
	my %args = @_;
	%RACESETTINGS=%args;		
}

sub nameprep
{
	my %args = @_;
	my $name = $args{name};
	my (%result,$i,$ChalintHash,$ProhibReturnHash,$mapresulthash);
	
	$result{hexin}=HexOut($name);

	$mapresulthash = DoMap($name);
	if(defined $mapresulthash->{error})
	{
		$result{error} = $mapresulthash->{error};
		return \%result;
	}
		
	$result{mapoutput} = $mapresulthash->{result};
	
	$result{hexmapoutput} = HexOut($result{mapoutput});

	for($i = 0; $i < length($result{mapoutput}); $i++) {
                if(ord(substr($result{mapoutput}, $i, 1)) == 0)
                        { $result{error} = "Null characters not allowed in normalization"; return \%result; }
        }
	$ChalintHash = CHARLINT::Charlint(Name=> $result{mapoutput}, DataFile=> $RACESETTINGS{DATAFILE});	
	if(defined $ChalintHash->{error})
	{
		$result{error} = $ChalintHash->{error};
		return \%result;
	}

	$result{normalizationout} = $ChalintHash->{charlint_domain};
		
	$result{hexnormalizationout} = HexOut($result{normalizationout});	

	$ProhibReturnHash = CheckForProhib(name => $result{normalizationout},
				       doUnass => 0,
				       unassFile => $RACESETTINGS{UNASSFILE},
				       prohibFile =>$RACESETTINGS{PROHIBFILE});
	if(defined $ProhibReturnHash->{error}) 
	{
		$result{error} = $ProhibReturnHash->{error};
                return \%result;
	}
	elsif($ProhibReturnHash->{result} == 1)
	{
		$result{error} = "Found Prohibited Chars: " . $ProhibReturnHash->{prohib_chars};	
               	return \%result;
	}

	$result{output} = $result{normalizationout};
	$result{hexoutput} = $result{hexnormalizationout};
	return \%result;
}

sub HexOut
{
	my $Temp = shift(@_);
	my (@UTF8Parts, $ThisUTF8Part,$result);
	@UTF8Parts = unpack( 'U0U*', $Temp);
	foreach $ThisUTF8Part (@UTF8Parts) 
	{
		$result .= 'U+' . sprintf('%04lX', $ThisUTF8Part) . ' ';
	}
	return $result;
}

sub DoMap {
        my $ToBeMap = shift(@_);
        my ($i, $TheLine, %MapTable, $From, $To, @AllInOrds);
        my ($ThisOrd, @OutParts, $Part, $OutMap,$Reason,%result);
        #if(!open(MAPFILE, '/home/tlovasic/NEWRACE/MapData-01.txt')) 
        if(!open(MAPFILE, $RACESETTINGS{MAPFILE})) 
	{
		$result{error} = "Could not read " .  $RACESETTINGS{MAPFILE} . " during mapping.";
		return \%result;
	}
        while(<MAPFILE>) {
                $TheLine = $_; chomp($TheLine);
                ($From, $To, $Reason) = split(/; /, $TheLine);
                $Reason = '';  # Needed to avoid the -w warning
                $MapTable{hex($From)} = $To;
        }
        @AllInOrds = unpack('U0U*', $ToBeMap);
        foreach $ThisOrd (@AllInOrds) {
                if(exists($MapTable{$ThisOrd})) {
                        # The mapping may be zero, one, or more encoded hex values
                        @OutParts = split(/ /, $MapTable{$ThisOrd});
                        foreach $Part (@OutParts) {
                                $OutMap .= uchr(hex($Part))->as_string;
                        }
                } else {  # No map, so just put out the character
                        $OutMap .= uchr($ThisOrd)->as_string;
                }
        }
	$result{result} = $OutMap;
        return \%result;
}

sub CheckForProhib {
	my %args = @_;
        my $ProhibCheckString = $args{name};
	my $DoUnass = $args{doUnass};
	my $UnassignedFile = $args{unassFile};
	my $ProhibFile = $args{prohibFile};
        my ($DebugTemp, $TheLine, @InputLines,$InRange, $Left, %ProhibHash, $ThisOrd,@AllInOrds,$FmtString);
	my ($FoundProhib,$Val, $Low, $High, @AllInChars, $i, $ThisChar, $ThisHex,%result);
        # Both the file with unassigned characters and the nameprep draft
        #     have lines in the same format: either they are a hex value,
        #     or they are two hex values with a dash between (indicating a range).
 
        # Only add in the unassigned characters if needed.
        if($DoUnass == 1) {
                if(! open(UNASSIGNED, $UnassignedFile))
		{
			$result{error} = "Could not read from $UnassignedFile\n";
			return \%result;
		}
                while(<UNASSIGNED>) {
                        $TheLine = $_; chomp($TheLine);
                        push(@InputLines, $TheLine);
                }
        }
 
        if(! open(PROHIBIN, $ProhibFile)) 
	{
		$result{error} = "Could not read from $ProhibFile\n";
                return \%result;
	}
        # Load the input array
        while(<PROHIBIN>) {
                $TheLine = $_; chomp($TheLine);
                next if($TheLine eq '');  # Skip blank lines
                push(@InputLines, $TheLine);
        }
 
        # Make a hash of values from the two files
        foreach $InRange (@InputLines) {
                ($Left) = split(/\s+/, $InRange, 2);
                if( (length($Left) == 4) or (length($Left) == 6) )
                        { $ProhibHash{hex($Left)} = 1 }
                else {
                        ($Low, $High) = split('-', $Left);
                        foreach $Val (hex($Low) .. hex($High))
                                { $ProhibHash{$Val} = 1 }
                }
        }
 
        # Compare the characters in the input against the values in
        #    the ProhibHash.
	 @AllInOrds = unpack('U0U*', $ProhibCheckString);
        foreach $ThisOrd (@AllInOrds) {
                if(exists($ProhibHash{$ThisOrd})) {
                        $FmtString = '%04lX';
                        $ThisHex = sprintf($FmtString, $ThisOrd);
                        $result{prohib_chars} .=  $ThisHex . " ";
                        $FoundProhib = 1;
                }
        }
        if($FoundProhib) {
		$result{result} = 1;
                return \%result;
        } else {
		$result{result} = 0;
                return \%result;
        }
}

return 1;