fix invalid byte sequence in UTF-8 (ArgumentError) (#9077)

This commit is contained in:
Brad Morrical 2020-02-28 09:26:18 -06:00 committed by GitHub
parent 0903aa44bb
commit ff5ff8d0d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -195,6 +195,11 @@ class ImportScripts::SimplePress < ImportScripts::Base
def process_simplepress_post(raw, import_id)
s = raw.dup
# fix invalid byte sequence in UTF-8 (ArgumentError)
unless s.valid_encoding?
s.force_encoding("UTF-8")
end
# convert the quote line
s.gsub!(/\[quote='([^']+)'.*?pid='(\d+).*?\]/) {
"[quote=\"#{convert_username($1, import_id)}, " + post_id_to_post_num_and_topic($2, import_id) + '"]'