Skip to content

Commit

Permalink
Item14547: forward url params to internal sessions
Browse files Browse the repository at this point in the history
also:

- fixed regex to remove foswikiNewLink elems
- fixed passing the correct wikiUser to the internal session
  • Loading branch information
MichaelDaum committed Jan 25, 2018
1 parent ad7f829 commit 2efd93b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
39 changes: 30 additions & 9 deletions lib/Foswiki/Plugins/ExportPlugin/Exporter.pm
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ sub param {
return $val;
}

sub param_list {
my ($this) = @_;

my $request = Foswiki::Func::getRequestObject();
my @keys = $request->param();

return @keys;
}

sub writeDebug {
my ($this, $msg) = @_;

Expand Down Expand Up @@ -123,7 +132,6 @@ sub getElapsedTime {
sub export {
my ($this, $session, $subject, $verb, $response) = @_;


my $debug = $this->param("debug");
$this->{debug} = Foswiki::Func::isTrue($debug, 0) if defined $debug;

Expand Down Expand Up @@ -228,17 +236,19 @@ sub exportTopics {
# pushTopicContext does not suffice. we need a new Foswiki session for every topic
# Foswiki::Func::pushTopicContext($thisWeb, $thisTopic);

my $skin = $this->param("skin");
my $cover = $this->param("cover");
my $forceUpdate = $this->param("forceupdate") || 'off';
my $request = Foswiki::Request->new();

# forward params
foreach my $key ($this->param_list) {
next if $key eq 'topic';
my $val = $this->param($key);
$request->param($key, $val);
}
$request->param("topic", $thisWeb.'.'.$thisTopic);
$request->param("skin", $skin);
$request->param("cover", $cover);
$request->param("forceupdate", $forceUpdate);

my $wikiName = Foswiki::Func::getWikiName();
my $session = Foswiki->new($wikiName, $request, {
my $loginName = Foswiki::Func::wikiToUserName($wikiName);
my $session = Foswiki->new($loginName, $request, {
static => 1,
});

Expand Down Expand Up @@ -374,7 +384,7 @@ sub renderHTML {
$result =~ s/\s*&#37;\{(<\/pre>)\}\%/$1/g;

# clean up unsatisfied WikiWords.
$result =~ s/<([^\s]+)\s+[^>]*.+class=.foswikiNewLink.[^>]*>(.*?)<\/\1>/$2/g;
$result =~ s/<([^\s]+)\s+[^>]*?class=.foswikiNewLink.[^>]*?>(.*?)<\/\1>/$2/g;

my $pub = Foswiki::Func::getPubUrlPath();
my $request = Foswiki::Func::getRequestObject();
Expand Down Expand Up @@ -414,6 +424,7 @@ sub renderHTML {
sub copyAsset {
my ($this, $assetName) = @_;

$assetName = _urlDecode($assetName);
$assetName =~ s/^\s+|\s+$//g;
$assetName =~ s/\?.*$//;

Expand Down Expand Up @@ -527,4 +538,14 @@ sub renderZones {
return $text;
}

sub _urlDecode {
my $text = shift;

$text = Foswiki::encode_utf8($text);
$text =~ s/%([\da-fA-F]{2})/chr(hex($1))/ge;
$text = Foswiki::decode_utf8($text);

return $text;
}

1;
1 change: 0 additions & 1 deletion lib/Foswiki/Plugins/ExportPlugin/Pdf.pm
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ sub convertToPdf {

File::Path::mkpath($path);


# create print command
my $baseUrl = $this->{baseUrl};
$baseUrl = Foswiki::Func::getPubUrlPath(undef, undef, undef, absolute=>1);
Expand Down

0 comments on commit 2efd93b

Please sign in to comment.