mirror of
https://github.com/webmin/webmin.git
synced 2026-02-14 02:42:07 +00:00
revert to previous commit, tunnel work with end url /
This commit is contained in:
@@ -186,57 +186,9 @@ if ($header{'content-type'} =~ /text\/html/ && !$header{'x-no-links'}) {
|
||||
#s/\.location\s*=\s*"$page([^']*)"/.location="$url\/$1"/gi;
|
||||
#s/window.open\("$page([^"]*)"/window.open\("$url\/$1"/gi;
|
||||
#s/name=return\s+value="$page([^"]*)"/name=return value="$url\/$1"/gi;
|
||||
|
||||
# fix href like <a href=aa.html>
|
||||
if ( m/\<(a|link).*href=(?!#|javascript:|https:|http:|\/|'|").*[ >]/gi ) {
|
||||
s/href=([^ "'>]*)/href=$linkurl$baseurl\/$1/gi;
|
||||
}
|
||||
|
||||
# fix href like <a href="aa.html">
|
||||
if ( m/\<(a|link).*href="(?!#|javascript:|https:|http:|\/).*"[ >]/gi ) {
|
||||
s/href="([^"]*)"/href="$linkurl$baseurl\/$1"/gi;
|
||||
}
|
||||
|
||||
# fix href like <a href='aa.html'>
|
||||
if ( m/\<(a|link).*href='(?!#|javascript:|https:|http:|\/).*'[ >]/gi ) {
|
||||
s/href='([^']*)'/href='$linkurl$baseurl\/$1'/gi;
|
||||
}
|
||||
|
||||
# fix src like <img src=aa.html>
|
||||
if ( m/\<(img|script).*src=(?!https:|http:|\/|'|").*[ >]/gi ) {
|
||||
s/src=([^ "'>]*)/src=$linkurl$baseurl\/$1/gi;
|
||||
}
|
||||
|
||||
# fix src like <img src="aa.html">
|
||||
if ( m/\<(img|script).*src="(?!https:|http:|\/).*"[ >]/gi ) {
|
||||
s/src="([^"]*)"/src="$linkurl$baseurl\/$1"/gi;
|
||||
}
|
||||
|
||||
# fix href like <img src='aa.html'>
|
||||
if ( m/\<(img|script).*src='(?!https:|http:|\/).*'[ >]/gi ) {
|
||||
s/src='([^']*)'/src='$linkurl$baseurl\/$1'/gi;
|
||||
}
|
||||
|
||||
print;
|
||||
}
|
||||
}
|
||||
|
||||
} elsif ($header{'content-type'} =~ /text\/css/) {
|
||||
my $s;
|
||||
my $pathinfo = $ENV{'PATH_INFO'};
|
||||
while($_ = &read_http_connection($con)) {
|
||||
if ( m/url\("(.*?)"\)/i ) {
|
||||
$s = &resolv_path($pathinfo, $1);
|
||||
s/url\("$1"\)/url\("$linkurl$s"\)/gi;
|
||||
} elsif ( m/url\('(.*?)'\)/i ) {
|
||||
$s = &resolv_path($pathinfo, $1);
|
||||
s/url\('$1'\)/url\('$linkurl$s'\)/gi;
|
||||
} elsif ( m/url\((.*?)\)/i ) {
|
||||
$s = &resolv_path($pathinfo, $1);
|
||||
s/url\($1\)/url\($linkurl$s\)/gi;
|
||||
}
|
||||
print;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while($buf = &read_http_connection($con, 1024)) {
|
||||
print $buf;
|
||||
|
||||
@@ -5,57 +5,5 @@ BEGIN { push(@INC, ".."); };
|
||||
use WebminCore;
|
||||
&init_config();
|
||||
|
||||
sub get_path {
|
||||
my ($file) = @_;
|
||||
$file =~ s!/?[^/]*/*$!!;
|
||||
return $file;
|
||||
}
|
||||
|
||||
sub pop_path {
|
||||
my ($dir, $stack) = @_;
|
||||
return get_path($dir) if ( $stack eq 0 );
|
||||
$ret = $dir;
|
||||
for($x=0; $x <= $stack; $x++) {
|
||||
$ret = get_path($ret);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
# $ENV{'PATH_INFO'}: /http:/rutweb.com/wp-content/themes/olympus/style.css
|
||||
# content: url(css/bootstrap.css)
|
||||
# path: css/bootstrap.css
|
||||
# translate to: http://rutweb.com/wp-content/themes/olympus/css/bootstrap.css
|
||||
# content: url(../css/bootstrap.css)
|
||||
# path: ../css/bootstrap.css
|
||||
# translate to: http://rutweb.com/wp-content/themes/css/bootstrap.css
|
||||
|
||||
# base on simplify_path
|
||||
sub resolv_path {
|
||||
my ($pathinfo, $path) = @_;
|
||||
|
||||
# fix schema
|
||||
$pathinfo =~ s/^\///g;
|
||||
$pathinfo =~ s/^(http:\/|https:\/)(?!\/.*)/$1\/$2/gi;
|
||||
|
||||
$path =~ s/^\/+//g;
|
||||
$path =~ s/\/+$//g;
|
||||
my @bits = split(/\/+/, $path);
|
||||
my @fixedbits = ();
|
||||
my $cnt = 0;
|
||||
foreach my $b (@bits) {
|
||||
if ($b eq ".") {
|
||||
# do nothing
|
||||
} elsif ($b eq "..") {
|
||||
$cnt++;
|
||||
pop(@fixedbits);
|
||||
} else {
|
||||
# Add dir to list
|
||||
push(@fixedbits, $b);
|
||||
}
|
||||
}
|
||||
$fpath = pop_path($pathinfo, $cnt);
|
||||
return "$fpath/".join('/', @fixedbits);
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user