Skip to content

Commit

Permalink
Item14070: Revert 25545ae and fix the lnkformat
Browse files Browse the repository at this point in the history
The right linkformat should escape the macros to avoid
prematurely expanding them.
  • Loading branch information
gac410 committed Mar 15, 2017
1 parent 25545ae commit 5244f3d
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions UnitTestContrib/test/unit/UploadScriptTests.pm
Expand Up @@ -547,21 +547,19 @@ sub test_propschanges {
hidefile => 1,
filecomment => 'Educate the hedgehog',
createlink => 1,
linkformat => '\n * [[%ATTACHURL%/$fileurl][$filename]]: $comment',
linkformat =>
'\n * [[$percentATTACHURL$percent/$fileurl][$filename]]: $comment',
changeproperties => 1
);
$this->assert_matches( qr/^Status: 302/ms, $result );
my ( $meta, $text ) =
Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} );

my $attachurl = Foswiki::Func::expandCommonVariables(
"%PUBURL{\"Flappadoodle.txt\" topic=\"$this->{test_web}.$this->{test_topic}\"}%"
);

# Check the link was created
$this->assert_matches(
qr/\[\[$attachurl]\[Flappadoodle\.txt\]\]: Educate the hedgehog/,
$text );
qr/\[\[%ATTACHURL%\/Flappadoodle\.txt\]\[Flappadoodle\.txt\]\]: Educate the hedgehog/,
$text
);

# Check the meta
my $at = $meta->get( 'FILEATTACHMENT', 'Flappadoodle.txt' );
Expand Down Expand Up @@ -593,21 +591,17 @@ sub test_linkformat {
hidefile => 1,
filecomment => 'Educate the hedgehog',
createlink => 1,
linkformat => '\n * [[%ATTACHURL%/$fileurl][$filename]]: $comment',
linkformat =>
'\n * [[$percntATTACHURL$percnt/$fileurl][$filename]]: $comment',
changeproperties => 1
);
$this->assert_matches( qr/^Status: 302/ms, $result );
my ( $meta, $text ) =
Foswiki::Func::readTopic( $this->{test_web}, $this->{test_topic} );

my $attachurl = Foswiki::Func::expandCommonVariables(
"%PUBURL{\"Flappadoodle.txt\" topic=\"$this->{test_web}.$this->{test_topic}\"}%"
);
my $txticon = Foswiki::Func::expandCommonVariables("%ICON{txt}%");

# This tests the original default link format
$this->assert_matches(
qr/^ \* \[\[$attachurl]\[Flappadoodle\.txt\]\]: Educate the hedgehog/ms,
qr/^ \* \[\[%ATTACHURL%\/Flappadoodle\.txt\]\[Flappadoodle\.txt\]\]: Educate the hedgehog/ms,
$text
);

Expand All @@ -620,7 +614,7 @@ qr/^ \* \[\[$attachurl]\[Flappadoodle\.txt\]\]: Educate the hedgehog/ms,
filecomment => 'Wikiworld',
createlink => 1,
linkformat =>
'$n |$year-$mo $wday|Effort $lt-- |[[%ATTACHURL%/$name][%ICON{$fileext}% $name]]| received from $comment |',
'$n |$year-$mo $wday|Effort $lt-- |[[$percntATTACHURL$percnt/$name][$percntICON{$fileext}$percnt $name]]| received from $comment |',
changeproperties => 1
);
$this->assert_matches( qr/^Status: 302/ms, $result );
Expand All @@ -632,15 +626,15 @@ qr/^ \* \[\[$attachurl]\[Flappadoodle\.txt\]\]: Educate the hedgehog/ms,

if ( $this->check_dependency('Foswiki,<,1.2') ) {
$this->assert_matches(
qr#^\$n\Q |$format|Effort \E\$\Qlt-- |[[$attachurl][%ICON{\E\$\Qfileext}% Flappadoodle.txt]]| received from Wikiworld |\E#ms,
qr#^\$n\Q |$format|Effort \E\$\Qlt-- |[[%ATTACHURL%/Flappadoodle.txt][%ICON{\E\$\Qfileext}% Flappadoodle.txt]]| received from Wikiworld |\E#ms,
$text
);
}
else {

# Item5935 added time and standard tokens to the attachment link text to version 1.2
$this->assert_matches(
qr#^\Q |$formatted|Effort <-- |[[$attachurl][$txticon Flappadoodle.txt]]| received from Wikiworld |\E#ms,
qr#^\Q |$formatted|Effort <-- |[[%ATTACHURL%/Flappadoodle.txt][%ICON{txt}% Flappadoodle.txt]]| received from Wikiworld |\E#ms,
$text
);
}
Expand Down

0 comments on commit 5244f3d

Please sign in to comment.