Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't assume good/badwords files are utf8-encoded #1267

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/lib/Guiguts/SpellCheck.pm
Original file line number Diff line number Diff line change
Expand Up @@ -494,19 +494,21 @@ sub spelladdgoodwords {

my $fh;

# Load good words first
if ( open( $fh, "<:encoding(utf8)", "good_words.txt" ) ) {
# Load good words first - these files may not be utf8-encoded, so don't assume they are
if ( open( $fh, "<", "good_words.txt" ) ) {
::busy();
while ( my $line = <$fh> ) {
utf8::decode($line);
$line =~ s/\s+$//;
next if $line eq '';
$::projectdict{$line} = '';
}
close($fh);

# The bad_words.txt file often doesn't exist, so don't error if that's the case
if ( open( $fh, "<:encoding(utf8)", "bad_words.txt" ) ) {
if ( open( $fh, "<", "bad_words.txt" ) ) {
while ( my $line = <$fh> ) {
utf8::decode($line);
$line =~ s/\s+$//;
next if $line eq '';
$::projectbadwords{$line} = '';
Expand Down
Loading