Skip to content

Commit

Permalink
Merge pull request #1165 from nanoc/scrub-strings-in-cleaning-stream
Browse files Browse the repository at this point in the history
Scrub strings in cleaning stream
  • Loading branch information
denisdefreyne committed Apr 22, 2017
2 parents bb63790 + 6648190 commit 10e2519
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/nanoc/cli/cleaning_stream.rb
Expand Up @@ -147,7 +147,7 @@ def set_encoding(*args)
protected

def _nanoc_clean(s)
@stream_cleaners.reduce(s.to_s) { |acc, elem| elem.clean(acc) }
@stream_cleaners.reduce(s.to_s.scrub) { |acc, elem| elem.clean(acc) }
end

def _nanoc_swallow_broken_pipe_errors_while
Expand Down
8 changes: 8 additions & 0 deletions test/cli/test_cleaning_stream.rb
Expand Up @@ -84,4 +84,12 @@ def obj.to_s
cleaning_stream << obj
assert_equal 'Hello… world!', stream.string
end

def test_invalid_string
s = "\x80"
stream = StringIO.new
cleaning_stream = Nanoc::CLI::CleaningStream.new(stream)
cleaning_stream << s
assert_equal "\xef\xbf\xbd", stream.string
end
end

0 comments on commit 10e2519

Please sign in to comment.