Clean, rather than Complain
Previously, if the user tried to submit content which was malformed utf-8, Instiki would complain loudly to him. A slightly more user-friendly approach was suggested by the latest Rails 2.3.4, and a conversation with Sam Ruby (who suggested some improvements). Now, instead of complaining, we remove the offending bytes, leaving a well-formed utf-8 string, which we pretend is what the user meant to submit.
This commit is contained in:
parent
f029aae60e
commit
c79fef9c01
9 changed files with 96 additions and 75 deletions
|
@ -124,14 +124,10 @@ class FileController < ApplicationController
|
|||
zip = Zip::ZipInputStream.open(archive)
|
||||
while (entry = zip.get_next_entry) do
|
||||
ext_length = File.extname(entry.name).length
|
||||
page_name = entry.name[0..-(ext_length + 1)]
|
||||
page_content = entry.get_input_stream.read
|
||||
page_name = entry.name[0..-(ext_length + 1)].purify
|
||||
page_content = entry.get_input_stream.read.purify
|
||||
logger.info "Processing page '#{page_name}'"
|
||||
begin
|
||||
if !page_content.is_utf8?
|
||||
logger.info "Page '#{page_name}' contains non-utf8 character data. Skipping."
|
||||
next
|
||||
end
|
||||
existing_page = @wiki.read_page(@web.address, page_name)
|
||||
if existing_page
|
||||
if existing_page.content == page_content
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue