[macruby-changes] [5098] MacRuby/trunk/array.c

source_changes at macosforge.org source_changes at macosforge.org
Sat Jan 1 23:42:04 PST 2011


Revision: 5098
          http://trac.macosforge.org/projects/ruby/changeset/5098
Author:   watson1978 at gmail.com
Date:     2011-01-01 23:42:00 -0800 (Sat, 01 Jan 2011)
Log Message:
-----------
Array#inspect will return a untrusted string.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions

a = [ "a", "b", "c" ]
a.taint
a.untrust

assert_equal(true, a.inspect.tainted?)
assert_equal(true, a.inspect.untrusted?)

puts :ok
}}}

Modified Paths:
--------------
    MacRuby/trunk/array.c

Modified: MacRuby/trunk/array.c
===================================================================
--- MacRuby/trunk/array.c	2011-01-02 05:26:54 UTC (rev 5097)
+++ MacRuby/trunk/array.c	2011-01-02 07:42:00 UTC (rev 5098)
@@ -1243,12 +1243,16 @@
     }
 
     bool tainted = OBJ_TAINTED(ary);
+    bool untrusted = OBJ_UNTRUSTED(ary);
     VALUE str = rb_str_buf_new2("[");
     for (long i = 0; i < RARRAY_LEN(ary); i++) {
 	VALUE s = rb_inspect(RARRAY_AT(ary, i));
 	if (OBJ_TAINTED(s)) {
 	    tainted = true;
 	}
+	if (OBJ_UNTRUSTED(s)) {
+	    untrusted = true;
+	}
 	if (i > 0) {
 	    rb_str_buf_cat2(str, ", ");
 	}
@@ -1259,6 +1263,9 @@
     if (tainted) {
 	OBJ_TAINT(str);
     }
+    if (untrusted) {
+	OBJ_UNTRUST(str);
+    }
     return str;
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20110101/35e33d56/attachment.html>


More information about the macruby-changes mailing list