@@ -224,8 +224,7 @@ def %(args)
224
224
*args = args
225
225
ret = Rubinius ::Sprinter . get ( self ) . call ( *args )
226
226
227
- ret . taint if tainted?
228
- return ret
227
+ Rubinius ::Type . infect ret , self
229
228
end
230
229
231
230
def *( num )
@@ -413,8 +412,9 @@ def crypt(other_str)
413
412
end
414
413
415
414
hash = __crypt__ ( other_str )
416
- hash . taint if tainted? || other_str . tainted?
417
- hash
415
+
416
+ Rubinius ::Type . infect hash , self
417
+ Rubinius ::Type . infect hash , other_str
418
418
end
419
419
420
420
def delete ( *strings )
@@ -1338,32 +1338,28 @@ def sub(pattern, replacement=undefined)
1338
1338
raise ArgumentError , "invalid byte sequence in #{ encoding } "
1339
1339
end
1340
1340
1341
+ ret = byteslice ( 0 , 0 ) # Empty string and string subclass
1342
+
1341
1343
if undefined . equal? replacement
1342
1344
unless block_given?
1343
1345
raise ArgumentError , "method '#{ __method__ } ': given 1, expected 2"
1344
1346
end
1345
1347
use_yield = true
1346
- tainted = false
1347
1348
else
1348
- tainted = replacement . tainted?
1349
- untrusted = replacement . untrusted?
1350
-
1351
1349
unless replacement . kind_of? ( String )
1352
1350
hash = Rubinius ::Type . check_convert_type ( replacement , Hash , :to_hash )
1353
1351
replacement = StringValue ( replacement ) unless hash
1354
- tainted ||= replacement . tainted?
1355
- untrusted ||= replacement . untrusted?
1356
1352
end
1357
1353
use_yield = false
1354
+
1355
+ Rubinius ::Type . infect ret , replacement
1358
1356
end
1359
1357
1360
1358
pattern = Rubinius ::Type . coerce_to_regexp ( pattern , true ) unless pattern . kind_of? Regexp
1361
1359
match = pattern . match_from ( self , 0 )
1362
1360
1363
1361
Regexp . last_match = match
1364
1362
1365
- ret = byteslice ( 0 , 0 ) # Empty string and string subclass
1366
-
1367
1363
if match
1368
1364
ret . append match . pre_match
1369
1365
@@ -1375,25 +1371,21 @@ def sub(pattern, replacement=undefined)
1375
1371
else
1376
1372
val = hash [ match . to_s ]
1377
1373
end
1378
- untrusted = true if val . untrusted?
1379
1374
val = val . to_s unless val . kind_of? ( String )
1380
1375
1381
- tainted ||= val . tainted?
1376
+ Rubinius :: Type . infect ret , val
1382
1377
1383
1378
ret . append val
1384
1379
else
1385
1380
replacement . to_sub_replacement ( ret , match )
1386
1381
end
1387
1382
1383
+ Rubinius ::Type . infect ret , val
1388
1384
ret . append ( match . post_match )
1389
- tainted ||= val . tainted?
1390
1385
else
1391
1386
ret = dup
1392
1387
end
1393
1388
1394
- ret . taint if tainted
1395
- ret . untrust if untrusted
1396
-
1397
1389
ret
1398
1390
end
1399
1391
@@ -1405,34 +1397,31 @@ def sub!(pattern, replacement=undefined)
1405
1397
raise ArgumentError , "invalid byte sequence in #{ encoding } "
1406
1398
end
1407
1399
1400
+ ret = byteslice ( 0 , 0 ) # Empty string and string subclass
1401
+
1408
1402
if undefined . equal? replacement
1409
1403
unless block_given?
1410
1404
raise ArgumentError , "method '#{ __method__ } ': given 1, expected 2"
1411
1405
end
1412
1406
Rubinius . check_frozen
1413
1407
use_yield = true
1414
- tainted = false
1415
1408
else
1416
1409
Rubinius . check_frozen
1417
- tainted = replacement . tainted?
1418
- untrusted = replacement . untrusted?
1419
1410
1420
1411
unless replacement . kind_of? ( String )
1421
1412
hash = Rubinius ::Type . check_convert_type ( replacement , Hash , :to_hash )
1422
1413
replacement = StringValue ( replacement ) unless hash
1423
- tainted ||= replacement . tainted?
1424
- untrusted ||= replacement . untrusted?
1425
1414
end
1426
1415
use_yield = false
1416
+
1417
+ Rubinius ::Type . infect ret , replacement
1427
1418
end
1428
1419
1429
1420
pattern = Rubinius ::Type . coerce_to_regexp ( pattern , true ) unless pattern . kind_of? Regexp
1430
1421
match = pattern . match_from ( self , 0 )
1431
1422
1432
1423
Regexp . last_match = match
1433
1424
1434
- ret = byteslice ( 0 , 0 ) # Empty string and string subclass
1435
-
1436
1425
if match
1437
1426
ret . append match . pre_match
1438
1427
@@ -1444,25 +1433,22 @@ def sub!(pattern, replacement=undefined)
1444
1433
else
1445
1434
val = hash [ match . to_s ]
1446
1435
end
1447
- untrusted = true if val . untrusted?
1448
1436
val = val . to_s unless val . kind_of? ( String )
1449
1437
1450
- tainted ||= val . tainted?
1438
+ Rubinius :: Type . infect ret , val
1451
1439
1452
1440
ret . append val
1453
1441
else
1454
1442
replacement . to_sub_replacement ( ret , match )
1455
1443
end
1456
1444
1445
+ Rubinius ::Type . infect ret , val
1446
+
1457
1447
ret . append ( match . post_match )
1458
- tainted ||= val . tainted?
1459
1448
else
1460
1449
return nil
1461
1450
end
1462
1451
1463
- ret . taint if tainted
1464
- ret . untrust if untrusted
1465
-
1466
1452
replace ( ret )
1467
1453
self
1468
1454
end
@@ -1852,23 +1838,21 @@ def gsub(pattern, replacement=undefined)
1852
1838
raise ArgumentError , "invalid byte sequence in #{ encoding } "
1853
1839
end
1854
1840
1841
+ ret = byteslice ( 0 , 0 ) # Empty string and string subclass
1842
+
1855
1843
if undefined . equal? replacement
1856
1844
unless block_given?
1857
1845
return to_enum ( :gsub , pattern , replacement )
1858
1846
end
1859
1847
use_yield = true
1860
- tainted = false
1861
1848
else
1862
- tainted = replacement . tainted?
1863
- untrusted = replacement . untrusted?
1864
-
1865
1849
unless replacement . kind_of? ( String )
1866
1850
hash = Rubinius ::Type . check_convert_type ( replacement , Hash , :to_hash )
1867
1851
replacement = StringValue ( replacement ) unless hash
1868
- tainted ||= replacement . tainted?
1869
- untrusted ||= replacement . untrusted?
1870
1852
end
1871
1853
use_yield = false
1854
+
1855
+ Rubinius ::Type . infect ret , replacement
1872
1856
end
1873
1857
1874
1858
pattern = Rubinius ::Type . coerce_to_regexp ( pattern , true ) unless pattern . kind_of? Regexp
@@ -1886,7 +1870,6 @@ def gsub(pattern, replacement=undefined)
1886
1870
1887
1871
last_match = nil
1888
1872
1889
- ret = byteslice ( 0 , 0 ) # Empty string and string subclass
1890
1873
offset = match . full . at ( 0 ) if match
1891
1874
1892
1875
while match
@@ -1902,10 +1885,9 @@ def gsub(pattern, replacement=undefined)
1902
1885
else
1903
1886
val = hash [ match . to_s ]
1904
1887
end
1905
- untrusted = true if val . untrusted?
1906
1888
val = val . to_s unless val . kind_of? ( String )
1907
1889
1908
- tainted ||= val . tainted?
1890
+ Rubinius :: Type . infect ret , val
1909
1891
1910
1892
ret . append val
1911
1893
@@ -1916,7 +1898,7 @@ def gsub(pattern, replacement=undefined)
1916
1898
replacement . to_sub_replacement ( ret , match )
1917
1899
end
1918
1900
1919
- tainted ||= val . tainted?
1901
+ Rubinius :: Type . infect ret , val
1920
1902
1921
1903
last_end = match . full . at ( 1 )
1922
1904
@@ -1945,9 +1927,6 @@ def gsub(pattern, replacement=undefined)
1945
1927
ret . append str
1946
1928
end
1947
1929
1948
- ret . taint if tainted
1949
- ret . untrust if untrusted
1950
-
1951
1930
ret
1952
1931
end
1953
1932
@@ -1959,25 +1938,24 @@ def gsub!(pattern, replacement=undefined)
1959
1938
raise ArgumentError , "invalid byte sequence in #{ encoding } "
1960
1939
end
1961
1940
1941
+ ret = byteslice ( 0 , 0 ) # Empty string and string subclass
1942
+
1962
1943
if undefined . equal? replacement
1963
1944
unless block_given?
1964
1945
return to_enum ( :gsub , pattern , replacement )
1965
1946
end
1966
1947
Rubinius . check_frozen
1967
1948
use_yield = true
1968
- tainted = false
1969
1949
else
1970
1950
Rubinius . check_frozen
1971
- tainted = replacement . tainted?
1972
- untrusted = replacement . untrusted?
1973
1951
1974
1952
unless replacement . kind_of? ( String )
1975
1953
hash = Rubinius ::Type . check_convert_type ( replacement , Hash , :to_hash )
1976
1954
replacement = StringValue ( replacement ) unless hash
1977
- tainted ||= replacement . tainted?
1978
- untrusted ||= replacement . untrusted?
1979
1955
end
1980
1956
use_yield = false
1957
+
1958
+ Rubinius ::Type . infect ret , replacement
1981
1959
end
1982
1960
1983
1961
pattern = Rubinius ::Type . coerce_to_regexp ( pattern , true ) unless pattern . kind_of? Regexp
@@ -1996,7 +1974,6 @@ def gsub!(pattern, replacement=undefined)
1996
1974
1997
1975
last_match = nil
1998
1976
1999
- ret = byteslice ( 0 , 0 ) # Empty string and string subclass
2000
1977
offset = match . full . at ( 0 )
2001
1978
2002
1979
while match
@@ -2012,10 +1989,9 @@ def gsub!(pattern, replacement=undefined)
2012
1989
else
2013
1990
val = hash [ match . to_s ]
2014
1991
end
2015
- untrusted = true if val . untrusted?
2016
1992
val = val . to_s unless val . kind_of? ( String )
2017
1993
2018
- tainted ||= val . tainted?
1994
+ Rubinius :: Type . infect ret , val
2019
1995
2020
1996
ret . append val
2021
1997
@@ -2026,7 +2002,7 @@ def gsub!(pattern, replacement=undefined)
2026
2002
replacement . to_sub_replacement ( ret , match )
2027
2003
end
2028
2004
2029
- tainted ||= val . tainted?
2005
+ Rubinius :: Type . infect ret , val
2030
2006
2031
2007
last_end = match . full . at ( 1 )
2032
2008
@@ -2055,9 +2031,6 @@ def gsub!(pattern, replacement=undefined)
2055
2031
ret . append str
2056
2032
end
2057
2033
2058
- ret . taint if tainted
2059
- ret . untrust if untrusted
2060
-
2061
2034
replace ( ret )
2062
2035
self
2063
2036
end
@@ -2314,7 +2287,9 @@ def center(width, padding=" ")
2314
2287
m . copy_from self , 0 , bs , left
2315
2288
end
2316
2289
2317
- str . taint if tainted? or padding . tainted?
2290
+ Rubinius ::Type . infect str , self
2291
+ Rubinius ::Type . infect str , padding
2292
+
2318
2293
str . force_encoding enc
2319
2294
end
2320
2295
@@ -2363,7 +2338,9 @@ def ljust(width, padding=" ")
2363
2338
m . copy_from self , 0 , bs , 0
2364
2339
end
2365
2340
2366
- str . taint if tainted? or padding . tainted?
2341
+ Rubinius ::Type . infect str , self
2342
+ Rubinius ::Type . infect str , padding
2343
+
2367
2344
str . force_encoding enc
2368
2345
end
2369
2346
@@ -2398,7 +2375,9 @@ def rjust(width, padding=" ")
2398
2375
2399
2376
m . copy_from self , 0 , bs , bytes
2400
2377
2401
- str . taint if tainted? or padding . tainted?
2378
+ Rubinius ::Type . infect str , self
2379
+ Rubinius ::Type . infect str , padding
2380
+
2402
2381
str . force_encoding enc
2403
2382
end
2404
2383
0 commit comments