Update xenforo.rb (#5622)

#Fix for the error: xenforo.rb: 160: in `gsub!': invalid byte sequence in UTF-8 (ArgumentError)
This commit is contained in:
neerajmalve 2018-03-08 09:27:38 +05:30 committed by Sam
parent 88fdc926d1
commit 4b8ff7a057
1 changed files with 6 additions and 0 deletions

View File

@ -156,6 +156,12 @@ class ImportScripts::XenForo < ImportScripts::Base
# phpBB shortens link text like this, which breaks our markdown processing:
# [http://answers.yahoo.com/question/index ... 223AAkkPli](http://answers.yahoo.com/question/index?qid=20070920134223AAkkPli)
#
#Fix for the error: xenforo.rb: 160: in `gsub!': invalid byte sequence in UTF-8 (ArgumentError)
if ! s.valid_encoding?
s = s.encode("UTF-16be", invalid: :replace, replace: "?").encode('UTF-8')
end
#End Fix
# Work around it for now:
s.gsub!(/\[http(s)?:\/\/(www\.)?/, '[')