Skip to content

Commit 0894fba

Browse files
committed
The taint mechanism will be deprecated in Ruby 2.7
The Ruby core team decided to deprecate the taint mechanism in Ruby 2.7 and will remove that in Ruby 3. https://bugs.ruby-lang.org/issues/16131 ruby/ruby#2476 In Ruby 2.7, `Object#{taint,untaint,trust,untrust}` and related functions in the C-API no longer have an effect (all objects are always considered untainted), and are now warned deprecation message. https://buildkite.com/rails/rails/builds/65054#5aa2db21-569d-4202-99cd-a8323cab583e/6-8
1 parent b6a9d73 commit 0894fba

File tree

4 files changed

+5
-27
lines changed

4 files changed

+5
-27
lines changed

ext/sqlite3/database.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,16 +213,16 @@ VALUE sqlite3val2rb(sqlite3_value * val)
213213
return rb_float_new(sqlite3_value_double(val));
214214
break;
215215
case SQLITE_TEXT:
216-
return rb_tainted_str_new2((const char *)sqlite3_value_text(val));
216+
return rb_str_new2((const char *)sqlite3_value_text(val));
217217
break;
218218
case SQLITE_BLOB: {
219219
/* Sqlite warns calling sqlite3_value_bytes may invalidate pointer from sqlite3_value_blob,
220220
so we explicitly get the length before getting blob pointer.
221-
Note that rb_str_new and rb_tainted_str_new apparently create string with ASCII-8BIT (BINARY) encoding,
221+
Note that rb_str_new apparently create string with ASCII-8BIT (BINARY) encoding,
222222
which is what we want, as blobs are binary
223223
*/
224224
int len = sqlite3_value_bytes(val);
225-
return rb_tainted_str_new((const char *)sqlite3_value_blob(val), len);
225+
return rb_str_new((const char *)sqlite3_value_blob(val), len);
226226
break;
227227
}
228228
case SQLITE_NULL:

ext/sqlite3/statement.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static VALUE step(VALUE self)
151151
break;
152152
case SQLITE_TEXT:
153153
{
154-
VALUE str = rb_tainted_str_new(
154+
VALUE str = rb_str_new(
155155
(const char *)sqlite3_column_text(stmt, i),
156156
(long)sqlite3_column_bytes(stmt, i)
157157
);
@@ -163,7 +163,7 @@ static VALUE step(VALUE self)
163163
break;
164164
case SQLITE_BLOB:
165165
{
166-
VALUE str = rb_tainted_str_new(
166+
VALUE str = rb_str_new(
167167
(const char *)sqlite3_column_blob(stmt, i),
168168
(long)sqlite3_column_bytes(stmt, i)
169169
);

test/test_integration_resultset.rb

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -105,23 +105,6 @@ def test_next_results_as_hash
105105
assert_equal hash[1], "foo"
106106
end
107107

108-
def test_tainted_results_as_hash
109-
@db.results_as_hash = true
110-
@result.reset( 1 )
111-
row = @result.next
112-
row.each do |_, v|
113-
assert(v.tainted?) if String === v
114-
end
115-
end
116-
117-
def test_tainted_row_values
118-
@result.reset( 1 )
119-
row = @result.next
120-
row.each do |v|
121-
assert(v.tainted?) if String === v
122-
end
123-
end
124-
125108
def test_each
126109
called = 0
127110
@result.reset( 1, 2 )

test/test_statement.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,6 @@ def test_step
198198
assert_equal ['foo'], r
199199
end
200200

201-
def test_tainted
202-
r = @stmt.step
203-
assert r.first.tainted?
204-
end
205-
206201
def test_step_twice
207202
assert_not_nil @stmt.step
208203
assert !@stmt.done?

0 commit comments

Comments
 (0)