Skip to content
Permalink
Browse files Browse the repository at this point in the history
Use a pattern that works on 1.8.7
  • Loading branch information
segiddins committed Aug 28, 2017
1 parent ef0aa61 commit 1bcbc7f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/rubygems/text.rb
Expand Up @@ -10,7 +10,7 @@ module Gem::Text
# Remove any non-printable characters and make the text suitable for
# printing.
def clean_text(text)
text.gsub(/[\u0000-\u0008\u000b-\u000c\u000e-\u001F\u007f]/, ".".freeze)
text.gsub(/[\000-\b\v-\f\016-\037\177]/, ".".freeze)
end

##
Expand Down
4 changes: 2 additions & 2 deletions test/rubygems/test_gem_commands_query_command.rb
Expand Up @@ -132,8 +132,8 @@ def test_execute_details_cleans_text
spec_fetcher do |fetcher|
fetcher.spec 'a', 2 do |s|
s.summary = 'This is a lot of text. ' * 4
s.authors = ["Abraham Lincoln \u0001", "\u0002 Hirohito"]
s.homepage = "http://a.example.com/\u0003"
s.authors = ["Abraham Lincoln \x01", "\x02 Hirohito"]
s.homepage = "http://a.example.com/\x03"
end

fetcher.legacy_platform
Expand Down
2 changes: 1 addition & 1 deletion test/rubygems/test_gem_text.rb
Expand Up @@ -37,7 +37,7 @@ def test_format_text_trailing # for two spaces after .
end

def test_format_removes_nonprintable_characters
assert_equal "text with weird .. stuff", format_text("text with weird \u001b\u0002 stuff", 40)
assert_equal "text with weird .. stuff .", format_text("text with weird \x1b\x02 stuff \x7f", 40)
end

def test_min3
Expand Down

0 comments on commit 1bcbc7f

Please sign in to comment.