File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -287,6 +287,13 @@ sub format_address {
287287
288288 # 2. deal with the options
289289
290+ foreach (grep { ! /^[a-z0-9_]+$/ } keys %$rh_components ) {
291+ if ($debug ){
292+ say STDERR " Skipping compontent $_ " ;
293+ }
294+ delete $rh_components -> {$_ };
295+ }
296+
290297 # 2a. which country format will we use?
291298 # might have been specified in options
292299 # otherwise look at components
Original file line number Diff line number Diff line change @@ -46,6 +46,32 @@ my $GAF = $CLASS->new(conf_path => $path);
4646 }
4747}
4848
49+ # Make sure invalid component names are skipped
50+ {
51+ my $af_path = dirname(__FILE__ ) . ' /../../address-formatting' ;
52+ my $conf_path = $af_path . ' /conf/' ;
53+ my $GAF = $CLASS -> new(conf_path => $conf_path );
54+
55+ my $rh_components = {
56+ ' ' => ' empty' ,
57+ ' *' => ' star' ,
58+ ' +' => ' plus' ,
59+ ' \\ ' => ' escape' ,
60+ ' $' => ' dollar' ,
61+ ' (' => ' bracket' ,
62+ ' \(' => ' quoted bracket' ,
63+ ' country' => ' United Kingdom' ,
64+ ' country_code' => ' gb' ,
65+ };
66+
67+ my $formatted = $GAF -> format_address($rh_components , {});
68+ chomp $formatted ;
69+
70+ is($formatted , ' United Kingdom' );
71+ }
72+
73+
74+
4975{
5076 # keep in mind this is using the test conf, not the real address-formatting conf
5177 is($GAF -> _add_state_code({}), undef );
You can’t perform that action at this time.
0 commit comments