[macruby-changes] [4919] MacRuby/trunk/string.c
source_changes at macosforge.org
source_changes at macosforge.org
Sat Nov 20 04:56:00 PST 2010
Revision: 4919
http://trac.macosforge.org/projects/ruby/changeset/4919
Author: watson1978 at gmail.com
Date: 2010-11-20 04:55:58 -0800 (Sat, 20 Nov 2010)
Log Message:
-----------
String#sub will copy the status of untrust.
Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
str = 'test'
str.taint
str.untrust
str.freeze
s = str.sub(/te/, "01")
assert_equal(true, s.tainted?)
assert_equal(true, s.untrusted?)
assert_equal(false, s.frozen?)
s = "012test".sub(/0/, str)
assert_equal(true, s.tainted?)
assert_equal(true, s.untrusted?)
assert_equal(false, s.frozen?)
puts :ok
}}}
Modified Paths:
--------------
MacRuby/trunk/string.c
Modified: MacRuby/trunk/string.c
===================================================================
--- MacRuby/trunk/string.c 2010-11-20 02:07:46 UTC (rev 4918)
+++ MacRuby/trunk/string.c 2010-11-20 12:55:58 UTC (rev 4919)
@@ -3731,6 +3731,7 @@
VALUE repl, hash = Qnil;
bool block_given = false;
bool tainted = false;
+ bool untrusted = false;
if (argc == 1 && rb_block_given_p()) {
block_given = true;
@@ -3744,6 +3745,9 @@
if (OBJ_TAINTED(repl)) {
tainted = true;
}
+ if (OBJ_UNTRUSTED(repl)) {
+ untrusted = true;
+ }
}
else {
rb_raise(rb_eArgError, "wrong number of arguments (%d for 2)", argc);
@@ -3791,10 +3795,16 @@
if (OBJ_TAINTED(repl)) {
tainted = true;
}
+ if (OBJ_UNTRUSTED(repl)) {
+ untrusted = true;
+ }
if (tainted) {
OBJ_TAINT(str);
}
+ if (untrusted) {
+ OBJ_UNTRUST(str);
+ }
return str;
}
return Qnil;
@@ -6145,6 +6155,9 @@
if (OBJ_TAINTED(source)) {
OBJ_TAINT(str);
}
+ if (OBJ_UNTRUSTED(source)) {
+ OBJ_UNTRUST(str);
+ }
return (VALUE)str;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101120/31b2aaac/attachment.html>
More information about the macruby-changes
mailing list