Created
February 5, 2011 06:42
-
-
Save spastorino/812284 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/kernel/common/string.rb b/kernel/common/string.rb | |
index 78c5b35..df6e295 100644 | |
--- a/kernel/common/string.rb | |
+++ b/kernel/common/string.rb | |
@@ -1460,9 +1460,13 @@ class String | |
return if @num_bytes == 0 | |
stop = @num_bytes - 1 | |
+ while stop >= 0 && @data[stop] == 0 | |
+ stop -= 1 | |
+ end | |
+ | |
while stop >= 0 | |
c = @data[stop] | |
- if c.isspace || c == 0 | |
+ if c.isspace | |
stop -= 1 | |
else | |
break | |
diff --git a/spec/ruby/core/string/strip_spec.rb b/spec/ruby/core/string/strip_spec.rb | |
index 22efc8e..53da880 100644 | |
--- a/spec/ruby/core/string/strip_spec.rb | |
+++ b/spec/ruby/core/string/strip_spec.rb | |
@@ -7,6 +7,7 @@ describe "String#strip" do | |
" hello world ".strip.should == "hello world" | |
"\tgoodbye\r\v\n".strip.should == "goodbye" | |
" goodbye \000".strip.should == "goodbye" | |
+ " goodbye \000 ".strip.should == "goodbye \000" | |
end | |
it "taints the result when self is tainted" do |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment