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

Scrub strings in cleaning stream #1165

Merged
merged 1 commit into from Apr 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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