Skip to content

Commit

Permalink
UTF8 decoding of archive json is now eval'd.
Browse files Browse the repository at this point in the history
This makes the "blanket double decoding done because I fucked up something in unicode support and can't figure out where it is" unable to crash the entire app on weird filenames.

Signed-off-by: difegue <sugoi@cock.li>
  • Loading branch information
Difegue committed Dec 10, 2017
1 parent 32817a4 commit 86d27f1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions functions/functions_index.pl
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ ()
my ($name,$event,$artist,$title,$series,$language,$tags,$filecheck,$isnew) = @hash{qw(name event artist title series language tags file isnew)};

#Parameters have been obtained, let's decode them.
($_ = decode_utf8($_)) for ($name, $event, $artist, $title, $series, $language, $tags, $filecheck);
( eval { $_ = decode_utf8($_) } ) for ($name, $event, $artist, $title, $series, $language, $tags, $filecheck);

#Update the real file path and title if they differ from the saved one just in case the file got manually renamed or some weird shit
unless ($file eq $filecheck)
Expand Down Expand Up @@ -113,7 +113,7 @@ ()
if ($title =~ /^\s*$/) #Workaround if title was incorrectly parsed as blank
{ $title = "<i class='fa fa-exclamation-circle'></i> Untitled archive, please edit metadata.";}

return qq(
my $finaljson = qq(
{
"arcid": "$id",
"url": "$urlencoded",
Expand All @@ -127,4 +127,10 @@ ()
},
);

#Try to UTF8-decode the JSON again, in case it has mangled japanese characters.
#This comes from a misstep somewhere earlier in the code, but the whole unicode situation is such a mess this'll do as a bandaid.
eval { $finaljson = decode_utf8($finaljson) };

return $finaljson;

}
6 changes: 3 additions & 3 deletions index.pl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
require 'functions/functions_index.pl';
require 'functions/functions_login.pl';

my $version = "v.0.3.8";
my $version = "v.0.3.9";
my $dirname = &get_dirname;

#Get all files in content directory and subdirectories.
Expand Down Expand Up @@ -70,8 +70,8 @@
userlogged => &isUserLogged($cgi),
motd => &get_motd,
cssdrop => &printCssDropdown(1),
archiveJSON => decode_utf8($archivejson),
newarchiveJSON => decode_utf8($newarchivejson),
archiveJSON => $archivejson,
newarchiveJSON => $newarchivejson,
nonewarchives => ($newarchivejson eq "[]"),
usingdefpass => $passcheck,
version => $version,
Expand Down

0 comments on commit 86d27f1

Please sign in to comment.