Item14609: Incorrect path to resources when using subwebs
Priority: Urgent
Current State: Closed
Released In: n/a
Target Release:
When analysing the path to a resource, the code uses a split on the web separator. But when it puts it back together, it uses a shift off the path. This is wrong, and results in bad paths to resources.
Patch follows:
diff --git a/lib/Foswiki/Plugins/PublishPlugin/Publisher.pm b/lib/Foswiki/Plugins/PublishPlugin/Publisher.pm
index 4c4084f..27484f8 100644
--- a/lib/Foswiki/Plugins/PublishPlugin/Publisher.pm
+++ b/lib/Foswiki/Plugins/PublishPlugin/Publisher.pm
@@ -1137,12 +1137,11 @@ sub _processURL {
my $attachment;
my $new = $url;
- $web = shift(@$upath) if scalar(@$upath);
- $topic = shift(@$upath) if scalar(@$upath);
-
# Is it an internal resource?
if ($is_pub) {
- $attachment = shift(@$upath) if scalar(@$upath);
+ $attachment = pop(@$upath) if scalar(@$upath);
+ $topic = pop(@$upath) if scalar(@$upath);
+ $web = join('/', @$upath);
$new = $this->_processInternalResource( $web, $topic, $attachment );
}
elsif ($is_script) {
@@ -1151,6 +1150,8 @@ sub _processURL {
# for the template being generated. We do this even if the
# topic isn't included in the processed outout, so we may
# end up with broken links. C'est la guerre.
+ $topic = pop(@$upath) if scalar(@$upath);
+ $web = join('/', @$upath);
$new = $this->{archive}->getTopicPath( $web, $topic );
}
else {
--
CrawfordCurrie - 23 Jan 2018