Fix of
"Unicode char like for example "ł" crush app when used in profile name" https://github.com/prusa3d/Slic3r/issues/388 The Prusa3D binary builds are missing the UTF8 libraries. To avoid having to bundle them, the case sensitive regexes testing file suffixes were replaced with explicit enumeration of lower / upper case letters. While crude, it avoids triggering the UTF8 library.
This commit is contained in:
parent
32213ce679
commit
6f28818f87
@ -234,8 +234,8 @@ sub decode_path {
|
|||||||
my ($path) = @_;
|
my ($path) = @_;
|
||||||
|
|
||||||
$path = Encode::decode(locale_fs => $path)
|
$path = Encode::decode(locale_fs => $path)
|
||||||
unless utf8::is_utf8($path);
|
unless Encode::is_utf8($path);
|
||||||
|
|
||||||
# The filesystem might force a normalization form (like HFS+ does) so
|
# The filesystem might force a normalization form (like HFS+ does) so
|
||||||
# if we rely on the filename being comparable after the open() + readdir()
|
# if we rely on the filename being comparable after the open() + readdir()
|
||||||
# roundtrip (like when creating and then selecting a preset), we need to
|
# roundtrip (like when creating and then selecting a preset), we need to
|
||||||
|
@ -101,7 +101,9 @@ sub load {
|
|||||||
my $class = shift;
|
my $class = shift;
|
||||||
my ($file) = @_;
|
my ($file) = @_;
|
||||||
|
|
||||||
if ($file =~ /\.gcode$/i || $file =~ /\.g$/i) {
|
# Instead of using the /i modifier for case-insensitive matching, the case insensitivity is expressed
|
||||||
|
# explicitely to avoid having to bundle the UTF8 Perl library.
|
||||||
|
if ($file =~ /\.[gG][cC][oO][dD][eE]/ || $file =~ /\.[gG]/) {
|
||||||
my $config = $class->new;
|
my $config = $class->new;
|
||||||
$config->_load_from_gcode($file);
|
$config->_load_from_gcode($file);
|
||||||
return $config;
|
return $config;
|
||||||
|
@ -313,7 +313,9 @@ sub presets {
|
|||||||
my %presets = ();
|
my %presets = ();
|
||||||
opendir my $dh, Slic3r::encode_path("$Slic3r::GUI::datadir/$section")
|
opendir my $dh, Slic3r::encode_path("$Slic3r::GUI::datadir/$section")
|
||||||
or die "Failed to read directory $Slic3r::GUI::datadir/$section (errno: $!)\n";
|
or die "Failed to read directory $Slic3r::GUI::datadir/$section (errno: $!)\n";
|
||||||
foreach my $file (grep /\.ini$/i, readdir $dh) {
|
# Instead of using the /i modifier for case-insensitive matching, the case insensitivity is expressed
|
||||||
|
# explicitely to avoid having to bundle the UTF8 Perl library.
|
||||||
|
foreach my $file (grep /\.[iI][nN][iI]$/, readdir $dh) {
|
||||||
$file = Slic3r::decode_path($file);
|
$file = Slic3r::decode_path($file);
|
||||||
my $name = basename($file);
|
my $name = basename($file);
|
||||||
$name =~ s/\.ini$//;
|
$name =~ s/\.ini$//;
|
||||||
|
@ -417,7 +417,7 @@ sub quick_slice {
|
|||||||
$output_file = $qs_last_output_file if defined $qs_last_output_file;
|
$output_file = $qs_last_output_file if defined $qs_last_output_file;
|
||||||
} elsif ($params{save_as}) {
|
} elsif ($params{save_as}) {
|
||||||
$output_file = $sprint->output_filepath;
|
$output_file = $sprint->output_filepath;
|
||||||
$output_file =~ s/\.gcode$/.svg/i if $params{export_svg};
|
$output_file =~ s/\.[gG][cC][oO][dD][eE]$/.svg/ if $params{export_svg};
|
||||||
my $dlg = Wx::FileDialog->new($self, 'Save ' . ($params{export_svg} ? 'SVG' : 'G-code') . ' file as:',
|
my $dlg = Wx::FileDialog->new($self, 'Save ' . ($params{export_svg} ? 'SVG' : 'G-code') . ' file as:',
|
||||||
wxTheApp->output_path(dirname($output_file)),
|
wxTheApp->output_path(dirname($output_file)),
|
||||||
basename($output_file), $params{export_svg} ? &Slic3r::GUI::FILE_WILDCARDS->{svg} : &Slic3r::GUI::FILE_WILDCARDS->{gcode}, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
basename($output_file), $params{export_svg} ? &Slic3r::GUI::FILE_WILDCARDS->{svg} : &Slic3r::GUI::FILE_WILDCARDS->{gcode}, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
@ -485,7 +485,7 @@ sub repair_stl {
|
|||||||
|
|
||||||
my $output_file = $input_file;
|
my $output_file = $input_file;
|
||||||
{
|
{
|
||||||
$output_file =~ s/\.stl$/_fixed.obj/i;
|
$output_file =~ s/\.[sS][tT][lL]$/_fixed.obj/;
|
||||||
my $dlg = Wx::FileDialog->new($self, "Save OBJ file (less prone to coordinate errors than STL) as:", dirname($output_file),
|
my $dlg = Wx::FileDialog->new($self, "Save OBJ file (less prone to coordinate errors than STL) as:", dirname($output_file),
|
||||||
basename($output_file), &Slic3r::GUI::FILE_WILDCARDS->{obj}, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
basename($output_file), &Slic3r::GUI::FILE_WILDCARDS->{obj}, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
if ($dlg->ShowModal != wxID_OK) {
|
if ($dlg->ShowModal != wxID_OK) {
|
||||||
|
@ -703,7 +703,7 @@ sub load_files {
|
|||||||
# One of the files is potentionally a bundle of files. Don't bundle them, but load them one by one.
|
# One of the files is potentionally a bundle of files. Don't bundle them, but load them one by one.
|
||||||
# Only bundle .stls or .objs if the printer has multiple extruders.
|
# Only bundle .stls or .objs if the printer has multiple extruders.
|
||||||
my $one_by_one = (@$nozzle_dmrs <= 1) || (@$input_files == 1) ||
|
my $one_by_one = (@$nozzle_dmrs <= 1) || (@$input_files == 1) ||
|
||||||
defined(first { $_ =~ /.amf$/i || $_ =~ /.3mf$/i || $_ =~ /.prusa$/i } @$input_files);
|
defined(first { $_ =~ /.[aA][mM][fF]$/ || $_ =~ /.3[mM][fF]$/ || $_ =~ /.[pP][rR][uI][sS][aA]$/ } @$input_files);
|
||||||
|
|
||||||
my $process_dialog = Wx::ProgressDialog->new('Loading…', "Processing input file\n" . basename($input_files->[0]), 100, $self, 0);
|
my $process_dialog = Wx::ProgressDialog->new('Loading…', "Processing input file\n" . basename($input_files->[0]), 100, $self, 0);
|
||||||
$process_dialog->Pulse;
|
$process_dialog->Pulse;
|
||||||
@ -1660,7 +1660,7 @@ sub _get_export_file {
|
|||||||
my $output_file = $main::opt{output};
|
my $output_file = $main::opt{output};
|
||||||
{
|
{
|
||||||
$output_file = $self->{print}->output_filepath($output_file);
|
$output_file = $self->{print}->output_filepath($output_file);
|
||||||
$output_file =~ s/\.gcode$/$suffix/i;
|
$output_file =~ s/\.[gG][cC][oO][dD][eE]$/$suffix/;
|
||||||
my $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
|
my $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
|
||||||
basename($output_file), &Slic3r::GUI::MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
basename($output_file), &Slic3r::GUI::MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||||
if ($dlg->ShowModal != wxID_OK) {
|
if ($dlg->ShowModal != wxID_OK) {
|
||||||
@ -2194,7 +2194,7 @@ sub OnDropFiles {
|
|||||||
@_ = ();
|
@_ = ();
|
||||||
|
|
||||||
# only accept STL, OBJ and AMF files
|
# only accept STL, OBJ and AMF files
|
||||||
return 0 if grep !/\.(?:stl|obj|amf(?:\.xml)?|prusa)$/i, @$filenames;
|
return 0 if grep !/\.(?:[sS][tT][lL]|[oO][bB][jJ]|[aA][mM][fF](?:\.[xX][mM][lL])?|[pP][rR][uU][sS][aA])$/, @$filenames;
|
||||||
|
|
||||||
$self->{window}->load_files($filenames);
|
$self->{window}->load_files($filenames);
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ sub save_preset {
|
|||||||
if (!defined $name) {
|
if (!defined $name) {
|
||||||
my $preset = $self->get_current_preset;
|
my $preset = $self->get_current_preset;
|
||||||
my $default_name = $preset->default ? 'Untitled' : $preset->name;
|
my $default_name = $preset->default ? 'Untitled' : $preset->name;
|
||||||
$default_name =~ s/\.ini$//i;
|
$default_name =~ s/\.[iI][nN][iI]$//;
|
||||||
|
|
||||||
my $dlg = Slic3r::GUI::SavePresetWindow->new($self,
|
my $dlg = Slic3r::GUI::SavePresetWindow->new($self,
|
||||||
title => lc($self->title),
|
title => lc($self->title),
|
||||||
@ -1830,7 +1830,7 @@ sub accept {
|
|||||||
my ($self, $event) = @_;
|
my ($self, $event) = @_;
|
||||||
|
|
||||||
if (($self->{chosen_name} = $self->{combo}->GetValue)) {
|
if (($self->{chosen_name} = $self->{combo}->GetValue)) {
|
||||||
if ($self->{chosen_name} !~ /^[^<>:\/\\|?*\"]+$/i) {
|
if ($self->{chosen_name} !~ /^[^<>:\/\\|?*\"]+$/) {
|
||||||
Slic3r::GUI::show_error($self, "The supplied name is not valid; the following characters are not allowed: <>:/\|?*\"");
|
Slic3r::GUI::show_error($self, "The supplied name is not valid; the following characters are not allowed: <>:/\|?*\"");
|
||||||
} elsif ($self->{chosen_name} eq '- default -') {
|
} elsif ($self->{chosen_name} eq '- default -') {
|
||||||
Slic3r::GUI::show_error($self, "The supplied name is not available.");
|
Slic3r::GUI::show_error($self, "The supplied name is not available.");
|
||||||
|
@ -9,10 +9,10 @@ sub read_from_file {
|
|||||||
my ($class, $input_file, $add_default_instances) = @_;
|
my ($class, $input_file, $add_default_instances) = @_;
|
||||||
$add_default_instances //= 1;
|
$add_default_instances //= 1;
|
||||||
|
|
||||||
my $model = $input_file =~ /\.stl$/i ? Slic3r::Model->load_stl(Slic3r::encode_path($input_file), basename($input_file))
|
my $model = $input_file =~ /\.[sS][tT][lL]$/ ? Slic3r::Model->load_stl(Slic3r::encode_path($input_file), basename($input_file))
|
||||||
: $input_file =~ /\.obj$/i ? Slic3r::Model->load_obj(Slic3r::encode_path($input_file), basename($input_file))
|
: $input_file =~ /\.[oO][bB][jJ]$/ ? Slic3r::Model->load_obj(Slic3r::encode_path($input_file), basename($input_file))
|
||||||
: $input_file =~ /\.amf(\.xml)?$/i ? Slic3r::Model->load_amf(Slic3r::encode_path($input_file))
|
: $input_file =~ /\.[aA][mM][fF](\.[xX][mM][lL])?$/ ? Slic3r::Model->load_amf(Slic3r::encode_path($input_file))
|
||||||
: $input_file =~ /\.prusa$/i ? Slic3r::Model->load_prus(Slic3r::encode_path($input_file))
|
: $input_file =~ /\.[pP][rR][uU][sS][aA]$/ ? Slic3r::Model->load_prus(Slic3r::encode_path($input_file))
|
||||||
: die "Input file must have .stl, .obj or .amf(.xml) extension\n";
|
: die "Input file must have .stl, .obj or .amf(.xml) extension\n";
|
||||||
|
|
||||||
die "The supplied file couldn't be read because it's empty.\n"
|
die "The supplied file couldn't be read because it's empty.\n"
|
||||||
|
@ -115,7 +115,7 @@ sub export_svg {
|
|||||||
my $fh = $params{output_fh};
|
my $fh = $params{output_fh};
|
||||||
if (!$fh) {
|
if (!$fh) {
|
||||||
my $output_file = $self->output_filepath($params{output_file});
|
my $output_file = $self->output_filepath($params{output_file});
|
||||||
$output_file =~ s/\.gcode$/.svg/i;
|
$output_file =~ s/\.[gG][cC][oO][dD][eE]$/.svg/;
|
||||||
Slic3r::open(\$fh, ">", $output_file) or die "Failed to open $output_file for writing\n";
|
Slic3r::open(\$fh, ">", $output_file) or die "Failed to open $output_file for writing\n";
|
||||||
print "Exporting to $output_file..." unless $params{quiet};
|
print "Exporting to $output_file..." unless $params{quiet};
|
||||||
}
|
}
|
||||||
|
@ -125,10 +125,10 @@ if (@ARGV) { # slicing from command line
|
|||||||
foreach my $file (@ARGV) {
|
foreach my $file (@ARGV) {
|
||||||
$file = Slic3r::decode_path($file);
|
$file = Slic3r::decode_path($file);
|
||||||
die "Repair is currently supported only on STL files\n"
|
die "Repair is currently supported only on STL files\n"
|
||||||
if $file !~ /\.stl$/i;
|
if $file !~ /\.[sS][tT][lL]$/;
|
||||||
|
|
||||||
my $output_file = $file;
|
my $output_file = $file;
|
||||||
$output_file =~ s/\.(stl)$/_fixed.obj/i;
|
$output_file =~ s/\.([sS][tT][lL])$/_fixed.obj/;
|
||||||
my $tmesh = Slic3r::TriangleMesh->new;
|
my $tmesh = Slic3r::TriangleMesh->new;
|
||||||
$tmesh->ReadSTLFile($file);
|
$tmesh->ReadSTLFile($file);
|
||||||
$tmesh->repair;
|
$tmesh->repair;
|
||||||
|
@ -27,7 +27,7 @@ my %opt = ();
|
|||||||
{
|
{
|
||||||
my $model = Slic3r::Model->load_amf(Slic3r::encode_path($ARGV[0]));
|
my $model = Slic3r::Model->load_amf(Slic3r::encode_path($ARGV[0]));
|
||||||
my $output_file = $ARGV[0];
|
my $output_file = $ARGV[0];
|
||||||
$output_file =~ s/\.amf(?:\.xml)?$/\.stl/i;
|
$output_file =~ s/\.[aA][mM][fF](?:\.[xX][mM][lL])?$/\.stl/;
|
||||||
|
|
||||||
printf "Writing to %s\n", basename($output_file);
|
printf "Writing to %s\n", basename($output_file);
|
||||||
$model->store_stl(Slic3r::encode_path($output_file), binary => !$opt{ascii});
|
$model->store_stl(Slic3r::encode_path($output_file), binary => !$opt{ascii});
|
||||||
|
@ -82,7 +82,7 @@ my %opt = ();
|
|||||||
my $output_file = $opt{output_file};
|
my $output_file = $opt{output_file};
|
||||||
if (!defined $output_file) {
|
if (!defined $output_file) {
|
||||||
$output_file = $input_file;
|
$output_file = $input_file;
|
||||||
$output_file =~ s/\.(?:stl)$/.pdf/i;
|
$output_file =~ s/\.(?:[sS][tT][lL])$/.pdf/;
|
||||||
}
|
}
|
||||||
$pdf->saveas($output_file);
|
$pdf->saveas($output_file);
|
||||||
printf "PDF file written to %s\n", $output_file;
|
printf "PDF file written to %s\n", $output_file;
|
||||||
|
@ -27,7 +27,7 @@ my %opt = ();
|
|||||||
{
|
{
|
||||||
my $model = Slic3r::Model->load_stl(Slic3r::encode_path($ARGV[0]), basename($ARGV[0]));
|
my $model = Slic3r::Model->load_stl(Slic3r::encode_path($ARGV[0]), basename($ARGV[0]));
|
||||||
my $basename = $ARGV[0];
|
my $basename = $ARGV[0];
|
||||||
$basename =~ s/\.stl$//i;
|
$basename =~ s/\.[sS][tT][lL]$//;
|
||||||
|
|
||||||
my $part_count = 0;
|
my $part_count = 0;
|
||||||
my $mesh = $model->objects->[0]->volumes->[0]->mesh;
|
my $mesh = $model->objects->[0]->volumes->[0]->mesh;
|
||||||
|
@ -27,7 +27,7 @@ my %opt = ();
|
|||||||
{
|
{
|
||||||
my @models = map Slic3r::Model->load_stl(Slic3r::encode_path($_), basename($_)), @ARGV;
|
my @models = map Slic3r::Model->load_stl(Slic3r::encode_path($_), basename($_)), @ARGV;
|
||||||
my $output_file = $ARGV[0];
|
my $output_file = $ARGV[0];
|
||||||
$output_file =~ s/\.stl$/.amf.xml/i;
|
$output_file =~ s/\.[sS][tT][lL]$/.amf.xml/;
|
||||||
|
|
||||||
my $new_model = Slic3r::Model->new;
|
my $new_model = Slic3r::Model->new;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user