Skip to content

Commit

Permalink
(#414) Fix regexparse not decoding the filesystem path + decode log i…
Browse files Browse the repository at this point in the history
…n minion upload for extra clarity
  • Loading branch information
Difegue committed Feb 28, 2021
1 parent 4172e92 commit a0f55ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 6 additions & 2 deletions lib/LANraragi/Plugin/Metadata/RegexParse.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use Scalar::Util qw(looks_like_number);

#You can also use the LRR Internal API when fitting.
use LANraragi::Model::Plugins;
use LANraragi::Utils::Database;
use LANraragi::Utils::Database qw(redis_encode redis_decode);
use LANraragi::Utils::Logging qw(get_logger);
use LANraragi::Utils::Generic qw(remove_spaces);
use LANraragi::Utils::Archive qw(is_file_in_archive extract_file_from_archive);
Expand Down Expand Up @@ -43,7 +43,11 @@ sub get_tags {
my ($savetitle) = @_; # Plugin parameters

my $logger = get_logger( "regexparse", "plugins" );
my $file = $lrr_info->{file_path};
my $file = $lrr_info->{file_path};

# lrr_info's file_path is taken straight from the filesystem, which might not be proper UTF-8.
# Run a decode to make sure we can derive tags with the proper encoding.
$file = redis_decode($file);

# Get the filename from the file_path info field
my ( $filename, $filepath, $suffix ) = fileparse( $file, qr/\.[^.]*/ );
Expand Down
7 changes: 5 additions & 2 deletions lib/LANraragi/Utils/Minion.pm
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ sub add_tasks {
my ( $file, $catid ) = @args;

my $logger = get_logger( "Minion", "minion" );
$logger->info("Processing uploaded file $file...");

# Superjank warning for the code below.
#
Expand All @@ -119,14 +118,18 @@ sub add_tasks {
or die "Bullshit! File path could not be converted back to a byte sequence!"
; # This error happening would not make any sense at all so it deserves the EYE reference

# For display however, we'd like to make sure we always show proper UTF-8.
# redis_decode, while not initially designed for this, does the job.
$logger->info( "Processing uploaded file" . redis_decode($file) . "..." );

# Since we already have a file, this goes straight to handle_incoming_file.
my ( $status, $id, $title, $message ) = LANraragi::Model::Upload::handle_incoming_file( $file, $catid, "" );

$job->finish(
{ success => $status,
id => $id,
category => $catid,
title => redis_decode($title), # We use a decode here to fix display issues in the response.
title => redis_decode($title), # Ditto, to fix display issues in the response
message => $message
}
);
Expand Down

0 comments on commit a0f55ea

Please sign in to comment.