Skip to content

Commit

Permalink
Item14436: support unicode filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
cdot committed Jul 14, 2017
1 parent b758baf commit 5967720
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
3 changes: 2 additions & 1 deletion data/System/AttachmentListPlugin.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="AdminGroup" date="1245704236" format="1.1" version="1.2"}%
%META:TOPICINFO{author="ProjectContributor" date="1500033995" format="1.1" version="1.2"}%
---+!! Attachment List Plugin

%$SHORTDESCRIPTION%.
Expand Down Expand Up @@ -213,6 +213,7 @@ You may specify image height and width parameters - this will read the imaage fi
| Version: | %$VERSION% |
| Release: | %$RELEASE% |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 14 Jul 2017 | v1.6 Crawford Currie: unicode fixes |
| 24 Aug 2011 | v.1.5.0 Arthur Clemens: sort on attachment comments. |
| 14 Dec 2010 | v.1.4.0 Support attachments in subwebs. Foswiki:Main.WillNorris, Support =AutoAttachPubFiles= -- Foswiki:Main.GeorgeClark |
| 01 Apr 2010 | V.1.3.4 Arthur Clemens: Fixed unit tests. |
Expand Down
17 changes: 7 additions & 10 deletions lib/Foswiki/Plugins/AttachmentListPlugin.pm
Expand Up @@ -22,8 +22,8 @@ use Foswiki::Meta;
use Foswiki::Plugins::AttachmentListPlugin::FileData;
use Foswiki::Plugins::TopicDataHelperPlugin;

our $VERSION = '$Rev$';
our $RELEASE = '1.5.0';
our $VERSION = '1.6';
our $RELEASE = '14 July 2017';
our $SHORTDESCRIPTION =
'Displays a formattable list of topic attachments - from any topic - anywhere in a topic';
our $NO_PREFS_IN_TOPIC = 1;
Expand Down Expand Up @@ -419,7 +419,7 @@ sub _formatFileData {
my $fileExtension = $fileData->{extension};
$fileExtension = ''
if $fileExtension eq
'none'; # do not use the extension placeholder for formatting
'none'; # do not use the extension placeholder for formatting
$listedExtensions{$fileExtension} = 1
if ($fileExtension)
; # add current attachment extension for display for $fileExtensions
Expand Down Expand Up @@ -476,13 +476,10 @@ sub _formatFileData {
$s =~ s/\$hidden/$hiddenStr/g;
}

my $webEnc = $fileData->{web};
$webEnc =~ s{([^-_/.a-zA-Z0-9])}{sprintf("%%%02x",ord($1))}eg;
my $topicEnc = $fileData->{topic};
$topicEnc =~ s{([^-_/.a-zA-Z0-9])}{sprintf("%%%02x",ord($1))}eg;
my $fileEnc = $fileData->{name};
$fileEnc =~ s{([^-_/.a-zA-Z0-9])}{sprintf("%%%02x",ord($1))}eg;
my $fileUrl = "$pubUrl/$webEnc/$topicEnc/$fileEnc";
my $webEnc = Foswiki::urlEncode( $fileData->{web} );
my $topicEnc = Foswiki::urlEncode( $fileData->{topic} );
my $fileEnc = Foswiki::urlEncode( $fileData->{name} );
my $fileUrl = "$pubUrl/$webEnc/$topicEnc/$fileEnc";

$s =~ s/\$fileUrl/$fileUrl/g;
$s =~ s/\$fileTopic/$fileData->{topic}/g;
Expand Down

0 comments on commit 5967720

Please sign in to comment.