Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: dfe59cc70ee9
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 67a2ee6c2885
Choose a head ref
  • 4 commits
  • 4 files changed
  • 1 contributor

Commits on Apr 4, 2015

  1. Copy the full SHA
    7638042 View commit details
  2. Copy the full SHA
    7e5d407 View commit details
  3. Copy the full SHA
    7fc5ec1 View commit details
  4. Copy the full SHA
    67a2ee6 View commit details
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyString.java
Original file line number Diff line number Diff line change
@@ -4937,7 +4937,7 @@ private IRubyObject enumerateChars(ThreadContext context, String name, Block blo
Encoding enc;
RubyArray ary = null;

str = RubyString.newString(runtime, str.getByteList().dup());
str = strDup(runtime);
ByteList strByteList = str.getByteList();
ptrBytes = strByteList.unsafeBytes();
ptr = strByteList.begin();
12 changes: 12 additions & 0 deletions spec/ruby/core/string/shared/chars.rb
Original file line number Diff line number Diff line change
@@ -68,5 +68,17 @@
"\xA2".force_encoding('SJIS')
]
end

it "taints resulting strings when self is tainted" do
str = "hello"

str.send(@method) do |x|
x.tainted?.should == false
end

str.dup.taint.send(@method) do |x|
x.tainted?.should == true
end
end
end
end
5 changes: 2 additions & 3 deletions spec/truffle/tags/core/string/split_tags.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
fails:String#split with String splits on multibyte characters
fails:String#split with String taints the resulting strings if self is tainted
fails:String#split with Regexp taints the resulting strings if self is tainted
fails(regexp):String#split with String splits on multibyte characters
fails(regexp):String#split with Regexp taints the resulting strings if self is tainted
Original file line number Diff line number Diff line change
@@ -1100,14 +1100,15 @@ public RubyString eachByte(VirtualFrame frame, RubyString string, RubyProc block
@ImportGuards(StringGuards.class)
public abstract static class EachCharNode extends YieldingCoreMethodNode {

@Child private CallDispatchHeadNode toEnumNode;
@Child private TaintResultNode taintResultNode;

public EachCharNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public EachCharNode(EachCharNode prev) {
super(prev);
taintResultNode = prev.taintResultNode;
}

@Specialization(guards = "isValidOr7BitEncoding")
@@ -1170,7 +1171,14 @@ private Object substr(RubyString string, int beg, int len) {
final ByteList substringBytes = new ByteList(bytes, beg, end - beg);
substringBytes.setEncoding(bytes.getEncoding());

return getContext().makeString(string.getLogicalClass(), substringBytes);
if (taintResultNode == null) {
CompilerDirectives.transferToInterpreter();
taintResultNode = insert(new TaintResultNode(getContext(), getSourceSection(), true, new int[]{}));
}

final RubyString ret = getContext().makeString(string.getLogicalClass(), substringBytes);

return taintResultNode.maybeTaint(string, ret);
}
}