[macruby-changes] [4918] MacRuby/trunk/string.c
source_changes at macosforge.org
source_changes at macosforge.org
Fri Nov 19 18:07:49 PST 2010
Revision: 4918
http://trac.macosforge.org/projects/ruby/changeset/4918
Author: watson1978 at gmail.com
Date: 2010-11-19 18:07:46 -0800 (Fri, 19 Nov 2010)
Log Message:
-----------
rstr_substr() will copy the status of taint and untrust.
Test Script:
{{{
require 'strscan'
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
str = 'test'
str.taint
str.untrust
str.freeze
s = str.chr
assert_equal(true, s.tainted?)
assert_equal(true, s.untrusted?)
assert_equal(false, s.frozen?)
s = str[1..3]
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-19 15:55:17 UTC (rev 4917)
+++ MacRuby/trunk/string.c 2010-11-20 02:07:46 UTC (rev 4918)
@@ -1215,6 +1215,13 @@
}
rb_str_t *substr = str_get_characters(RSTR(str), beg, beg + len - 1, true);
+ if (OBJ_TAINTED(str)) {
+ OBJ_TAINT((VALUE)substr);
+ }
+ if (OBJ_UNTRUSTED(str)) {
+ OBJ_UNTRUST((VALUE)substr);
+ }
+
return substr == NULL ? Qnil : (VALUE)substr;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101119/da3bd89c/attachment.html>
More information about the macruby-changes
mailing list