… | |
… | |
667 | ); |
667 | ); |
668 | |
668 | |
669 | sub msg { |
669 | sub msg { |
670 | my ($self, $color, $type, $text, @extra) = @_; |
670 | my ($self, $color, $type, $text, @extra) = @_; |
671 | |
671 | |
|
|
672 | # we now weed out all tags we do not support |
|
|
673 | $text =~ s%<(?!/?i>|/?u>|/?b>|fg |/fg>)%<%g; |
|
|
674 | # now all entities |
|
|
675 | $text =~ s/&(?!amp;|lt;|gt;|apos;|quot;|#[0-9]+;|#x[0-9a-fA-F]+;)/&/g; |
|
|
676 | |
|
|
677 | # handle some elements |
|
|
678 | $text =~ s/<fg name='([^']*)'>(.*?)<\/fg>/<span foreground='$1'>$2<\/span>/gs; |
|
|
679 | $text =~ s/<fg name="([^"]*)">(.*?)<\/fg>/<span foreground="$1">$2<\/span>/gs; |
|
|
680 | |
672 | if (my $cb = $self->{cb_msg}{$type}) { |
681 | if (my $cb = $self->{cb_msg}{$type}) { |
673 | $_->($self, $color, $type, $text, @extra) for values %$cb; |
682 | $_->($self, $color, $type, $text, @extra) for values %$cb; |
674 | } elsif ($type =~ /^(?:chargen-race-title|chargen-race-description)$/) { |
683 | } elsif ($type =~ /^(?:chargen-race-title|chargen-race-description)$/) { |
675 | $type =~ s/-/_/g; |
684 | $type =~ s/-/_/g; |
676 | $self->{$type} = $text; |
685 | $self->{$type} = $text; |