Improve handling of man names with special characters
The 'source' link was broken for mans with [ or ] characters. All links were broken for mans with space characters. Man page of the week: https://manned.org/KGenericFactory_%20KTypeList_%20Product,%20ProductListTail%20_,%20KTypeList_%20ParentType,%20ParentTypeListTail%20_%20_/dfc33ca6 There's a 5 man pages left with a '%' or '#' character. I've no idea if it's worth handling those; A fix for these isn't going to be as trivial as this commit.
This commit is contained in:
parent
8a0fac08b6
commit
5436435c3f
1 changed files with 15 additions and 3 deletions
18
www/index.pl
18
www/index.pl
|
|
@ -79,6 +79,7 @@ TUWF::register(
|
||||||
# I'm not a fan of this solution; might drop it in the future.
|
# I'm not a fan of this solution; might drop it in the future.
|
||||||
qr{lang/([^/]+)/([^/]+)} => sub {
|
qr{lang/([^/]+)/([^/]+)} => sub {
|
||||||
my($s, $l, $n) = @_;
|
my($s, $l, $n) = @_;
|
||||||
|
$n = _normalizename($n);
|
||||||
my($m, undef) = $s->dbManPrefName($n, language => $l);
|
my($m, undef) = $s->dbManPrefName($n, language => $l);
|
||||||
return $s->resNotFound if !$m;
|
return $s->resNotFound if !$m;
|
||||||
$s->resRedirect("/$m->{name}/".substr($m->{hash}, 0, 8), 'temp');
|
$s->resRedirect("/$m->{name}/".substr($m->{hash}, 0, 8), 'temp');
|
||||||
|
|
@ -577,12 +578,21 @@ sub _man_langsect {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub _normalizename {
|
||||||
|
local $_ = shift;
|
||||||
|
# Firefox seems to escape [ and ] in URLs. It doesn't really have to...
|
||||||
|
s/%5b/[/ig;
|
||||||
|
s/%5d/]/ig;
|
||||||
|
# Man pages with spaces in the path, eww
|
||||||
|
s/%20/ /g;
|
||||||
|
$_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub man {
|
sub man {
|
||||||
my($self, $name, $hash) = @_;
|
my($self, $name, $hash) = @_;
|
||||||
|
|
||||||
# Firefox seems to escape [ and ] in URLs. It doesn't really have to...
|
$name = _normalizename($name);
|
||||||
$name =~ s/%5b/[/ig;
|
|
||||||
$name =~ s/%5d/]/ig;
|
|
||||||
|
|
||||||
my $man;
|
my $man;
|
||||||
if($hash) {
|
if($hash) {
|
||||||
|
|
@ -617,6 +627,8 @@ sub man {
|
||||||
sub src {
|
sub src {
|
||||||
my($self, $name, $hash) = @_;
|
my($self, $name, $hash) = @_;
|
||||||
|
|
||||||
|
$name = _normalizename($name);
|
||||||
|
|
||||||
my $m = $self->dbManInfo(name => $name, shorthash => $hash);
|
my $m = $self->dbManInfo(name => $name, shorthash => $hash);
|
||||||
return $self->resNotFound if !@$m;
|
return $self->resNotFound if !@$m;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue