From 86d27f1719fd85720691a3b4a3bb6f7c1cbce4ef Mon Sep 17 00:00:00 2001 From: difegue Date: Sun, 10 Dec 2017 19:12:01 +0100 Subject: [PATCH] UTF8 decoding of archive json is now eval'd. 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 --- functions/functions_index.pl | 10 ++++++++-- index.pl | 6 +++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/functions/functions_index.pl b/functions/functions_index.pl index 2c19af9d3..a2040fc47 100644 --- a/functions/functions_index.pl +++ b/functions/functions_index.pl @@ -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) @@ -113,7 +113,7 @@ () if ($title =~ /^\s*$/) #Workaround if title was incorrectly parsed as blank { $title = " Untitled archive, please edit metadata.";} - return qq( + my $finaljson = qq( { "arcid": "$id", "url": "$urlencoded", @@ -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; + } \ No newline at end of file diff --git a/index.pl b/index.pl index 614e0caca..29cd229d5 100644 --- a/index.pl +++ b/index.pl @@ -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. @@ -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,