Skip to content

Commit 7827aeb

Browse files
committedNov 22, 2013
Move out taint filters from String bugs
1 parent 1459f04 commit 7827aeb

File tree

2 files changed

+39
-26
lines changed

2 files changed

+39
-26
lines changed
 

Diff for: ‎spec/opal/filters/bugs/string.rb

-26
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,19 @@
1010
fails "String#[] calls to_int on the given index"
1111
fails "String#[] raises a TypeError if the given index is nil"
1212
fails "String#[] raises a TypeError if the given index can't be converted to an Integer"
13-
fails "String#[] with index, length always taints resulting strings when self is tainted"
1413
fails "String#[] with index, length returns nil if the length is negative"
1514
fails "String#[] with index, length calls to_int on the given index and the given length"
1615
fails "String#[] with index, length calls to_int on the given index and the given length"
1716
fails "String#[] with index, length raises a TypeError when idx or length can't be converted to an integer"
1817
fails "String#[] with index, length raises a TypeError when the given index or the given length is nil"
1918
fails "String#[] with Range returns nil if the beginning of the range falls outside of self"
20-
fails "String#[] with Range always taints resulting strings when self is tainted"
2119
fails "String#[] with Range calls to_int on range arguments"
2220
fails "String#[] with Range calls to_int on range arguments"
2321
fails "String#[] with Range handles repeated application"
2422
fails "String#[] with Regexp returns the matching portion of self"
2523
fails "String#[] with Regexp returns nil if there is no match"
26-
fails "String#[] with Regexp always taints resulting strings when self or regexp is tainted"
2724
fails "String#[] with Regexp sets $~ to MatchData when there is a match and nil when there's none"
2825
fails "String#[] with Regexp, index returns the capture for the given index"
29-
fails "String#[] with Regexp, index always taints resulting strings when self or regexp is tainted"
3026
fails "String#[] with Regexp, index returns nil if there is no match"
3127
fails "String#[] with Regexp, index returns nil if there is no capture for the given index"
3228
fails "String#[] with Regexp, index calls to_int on the given index"
@@ -35,7 +31,6 @@
3531
fails "String#[] with Regexp, index raises a TypeError when the given index is nil"
3632
fails "String#[] with Regexp, index sets $~ to MatchData when there is a match and nil when there's none"
3733
fails "String#[] with String returns other_str if it occurs in self"
38-
fails "String#[] with String taints resulting strings when other is tainted"
3934
fails "String#[] with String returns nil if there is no match"
4035
fails "String#[] with String doesn't call to_str on its argument"
4136
fails "String#[] with String returns a subclass instance when given a subclass instance"
@@ -45,7 +40,6 @@
4540
fails "String#end_with? converts its argument using :to_str"
4641
fails "String#end_with? returns true if other is empty"
4742

48-
fails "String#each_line taints substrings that are passed to the block if self is tainted"
4943
fails "String#each_line passes self as a whole to the block if the separator is nil"
5044
fails "String#each_line yields paragraphs (broken by 2 or more successive newlines) when passed ''"
5145
fails "String#each_line uses $/ as the separator when none is given"
@@ -71,7 +65,6 @@
7165
fails "String#gsub with pattern and replacement replaces \\+ with the last paren that actually matched"
7266
fails "String#gsub with pattern and replacement treats \\+ as an empty string if there was no captures"
7367
fails "String#gsub with pattern and replacement maps \\\\ in replacement to \\"
74-
fails "String#gsub with pattern and replacement taints the result if the original string or replacement is tainted"
7568
fails "String#gsub with pattern and replacement handles pattern collapse without $KCODE"
7669
fails "String#gsub with pattern and replacement untrusts the result if the original string or replacement is untrusted"
7770
fails "String#gsub with pattern and replacement raises a TypeError when replacement can't be converted to a string"
@@ -89,8 +82,6 @@
8982
fails "String#gsub with pattern and Hash doesn't interpolate special sequences like \\1 for the block's return value"
9083
fails "String#gsub with pattern and Hash untrusts the result if the original string is untrusted"
9184
fails "String#gsub with pattern and Hash untrusts the result if a hash value is untrusted"
92-
fails "String#gsub with pattern and Hash taints the result if the original string is tainted"
93-
fails "String#gsub with pattern and Hash taints the result if a hash value is tainted"
9485
fails "String#gsub with pattern and block sets $~ for access from the block"
9586
fails "String#gsub with pattern and block restores $~ after leaving the block"
9687
fails "String#gsub with pattern and block sets $~ to MatchData of last match and nil when there's none for access from outside"
@@ -109,7 +100,6 @@
109100
fails "String#lines should split on the default record separator and return enumerator if not block is given"
110101
fails "String#lines splits using default newline separator when none is specified"
111102
fails "String#lines splits self using the supplied record separator and passes each substring to the block"
112-
fails "String#lines taints substrings that are passed to the block if self is tainted"
113103
fails "String#lines passes self as a whole to the block if the separator is nil"
114104
fails "String#lines yields paragraphs (broken by 2 or more successive newlines) when passed ''"
115105
fails "String#lines yields subclass instances for subclasses"
@@ -123,13 +113,11 @@
123113
fails "String#lines returns an array when no block given"
124114

125115
fails "String#lstrip returns a copy of self with leading whitespace removed"
126-
fails "String#lstrip taints the result when self is tainted"
127116

128117
fails "String#next returns the successor by increasing the rightmost alphanumeric (digit => digit, letter => letter with same case)"
129118
fails "String#next increases the next best alphanumeric (jumping over non-alphanumerics) if there is a carry"
130119
fails "String#next increases the next best character if there is a carry for non-alphanumerics"
131120
fails "String#next adds an additional character (just left to the last increased one) if there is a carry and no character left to increase"
132-
fails "String#next taints the result if self is tainted"
133121

134122
fails "String#partition with String accepts regexp"
135123
fails "String#partition with String sets global vars if regexp used"
@@ -154,29 +142,24 @@
154142

155143
fails "String#rstrip returns a copy of self with trailing whitespace removed"
156144
fails "String#rstrip returns a copy of self with all trailing whitespace and NULL bytes removed"
157-
fails "String#rstrip taints the result when self is tainted"
158145

159146
fails "String#slice calls to_int on the given index"
160147
fails "String#slice calls to_int on the given index"
161148
fails "String#slice raises a TypeError if the given index is nil"
162149
fails "String#slice raises a TypeError if the given index can't be converted to an Integer"
163-
fails "String#slice with index, length always taints resulting strings when self is tainted"
164150
fails "String#slice with index, length returns nil if the length is negative"
165151
fails "String#slice with index, length calls to_int on the given index and the given length"
166152
fails "String#slice with index, length calls to_int on the given index and the given length"
167153
fails "String#slice with index, length raises a TypeError when idx or length can't be converted to an integer"
168154
fails "String#slice with index, length raises a TypeError when the given index or the given length is nil"
169155
fails "String#slice with Range returns nil if the beginning of the range falls outside of self"
170-
fails "String#slice with Range always taints resulting strings when self is tainted"
171156
fails "String#slice with Range calls to_int on range arguments"
172157
fails "String#slice with Range calls to_int on range arguments"
173158
fails "String#slice with Range handles repeated application"
174159
fails "String#slice with Regexp returns the matching portion of self"
175160
fails "String#slice with Regexp returns nil if there is no match"
176-
fails "String#slice with Regexp always taints resulting strings when self or regexp is tainted"
177161
fails "String#slice with Regexp sets $~ to MatchData when there is a match and nil when there's none"
178162
fails "String#slice with Regexp, index returns the capture for the given index"
179-
fails "String#slice with Regexp, index always taints resulting strings when self or regexp is tainted"
180163
fails "String#slice with Regexp, index returns nil if there is no match"
181164
fails "String#slice with Regexp, index returns nil if there is no capture for the given index"
182165
fails "String#slice with Regexp, index calls to_int on the given index"
@@ -185,7 +168,6 @@
185168
fails "String#slice with Regexp, index raises a TypeError when the given index is nil"
186169
fails "String#slice with Regexp, index sets $~ to MatchData when there is a match and nil when there's none"
187170
fails "String#slice with String returns other_str if it occurs in self"
188-
fails "String#slice with String taints resulting strings when other is tainted"
189171
fails "String#slice with String returns nil if there is no match"
190172
fails "String#slice with String doesn't call to_str on its argument"
191173
fails "String#slice with String returns a subclass instance when given a subclass instance"
@@ -201,7 +183,6 @@
201183
fails "String#split with String tries converting limit to an integer via to_int"
202184
fails "String#split with String returns subclass instances based on self"
203185
fails "String#split with String does not call constructor on created subclass instances"
204-
fails "String#split with String taints the resulting strings if self is tainted"
205186
fails "String#split with Regexp divides self on regexp matches"
206187
fails "String#split with Regexp treats negative limits as no limit"
207188
fails "String#split with Regexp suppresses trailing empty fields when limit isn't given or 0"
@@ -216,9 +197,6 @@
216197
fails "String#split with Regexp returns a type error if limit can't be converted to an integer"
217198
fails "String#split with Regexp returns subclass instances based on self"
218199
fails "String#split with Regexp does not call constructor on created subclass instances"
219-
fails "String#split with Regexp taints the resulting strings if self is tainted"
220-
fails "String#split with Regexp taints an empty string if self is tainted"
221-
fails "String#split with Regexp doesn't taints the resulting strings if the Regexp is tainted"
222200
fails "String#split with Regexp retains the encoding of the source string"
223201
fails "String#split with Regexp returns an ArgumentError if an invalid UTF-8 string is supplied"
224202

@@ -227,7 +205,6 @@
227205

228206
fails "String#strip returns a new string with leading and trailing whitespace removed"
229207
fails "String#strip returns a copy of self with trailing NULL bytes and whitespace"
230-
fails "String#strip taints the result when self is tainted"
231208

232209
fails "String#sub with pattern, replacement supports \\G which matches at the beginning of the string"
233210
fails "String#sub with pattern, replacement replaces \\1 sequences with the regexp's corresponding capture"
@@ -238,7 +215,6 @@
238215
fails "String#sub with pattern, replacement replaces \\+ with the last paren that actually matched"
239216
fails "String#sub with pattern, replacement treats \\+ as an empty string if there was no captures"
240217
fails "String#sub with pattern, replacement maps \\\\ in replacement to \\"
241-
fails "String#sub with pattern, replacement taints the result if the original string or replacement is tainted"
242218
fails "String#sub with pattern, replacement tries to convert pattern to a string using to_str"
243219
fails "String#sub with pattern, replacement tries to convert pattern to a string using to_str"
244220
fails "String#sub with pattern, replacement raises a TypeError when pattern can't be converted to a string"
@@ -249,13 +225,11 @@
249225
fails "String#sub with pattern and block sets $~ for access from the block"
250226
fails "String#sub with pattern and block sets $~ to MatchData of last match and nil when there's none for access from outside"
251227
fails "String#sub with pattern and block doesn't raise a RuntimeError if the string is modified while substituting"
252-
fails "String#sub with pattern and block taints the result if the original string or replacement is tainted"
253228

254229
fails "String#succ returns the successor by increasing the rightmost alphanumeric (digit => digit, letter => letter with same case)"
255230
fails "String#succ increases the next best alphanumeric (jumping over non-alphanumerics) if there is a carry"
256231
fails "String#succ increases the next best character if there is a carry for non-alphanumerics"
257232
fails "String#succ adds an additional character (just left to the last increased one) if there is a carry and no character left to increase"
258-
fails "String#succ taints the result if self is tainted"
259233

260234
fails "String#sum returns a basic n-bit checksum of the characters in self"
261235
fails "String#sum tries to convert n to an integer using to_int"

Diff for: ‎spec/opal/filters/unsupported/tainted.rb

+39
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@
6060

6161
fails "Hash#reject taints the resulting hash"
6262

63+
fails "String#[] with index, length always taints resulting strings when self is tainted"
64+
fails "String#[] with Range always taints resulting strings when self is tainted"
65+
fails "String#[] with Regexp always taints resulting strings when self or regexp is tainted"
66+
fails "String#[] with Regexp, index always taints resulting strings when self or regexp is tainted"
67+
fails "String#[] with String taints resulting strings when other is tainted"
68+
6369
fails "String#capitalize taints resulting string when self is tainted"
6470

6571
fails "String#downcase taints result when self is tainted"
@@ -77,16 +83,49 @@
7783

7884
fails "String#chop taints result when self is tainted"
7985

86+
fails "String#each_line taints substrings that are passed to the block if self is tainted"
87+
88+
fails "String#gsub with pattern and replacement taints the result if the original string or replacement is tainted"
89+
fails "String#gsub with pattern and Hash taints the result if the original string is tainted"
90+
fails "String#gsub with pattern and Hash taints the result if a hash value is tainted"
91+
92+
fails "String#lines taints substrings that are passed to the block if self is tainted"
93+
8094
fails "String#ljust with length, padding taints result when self or padstr is tainted"
8195
fails "String#ljust with length, padding when padding is tainted and self is untainted returns a tainted string if and only if length is longer than self"
8296

97+
fails "String#lstrip taints the result when self is tainted"
98+
99+
fails "String#next taints the result if self is tainted"
100+
83101
fails "String#reverse taints the result if self is tainted"
84102

85103
fails "String#rjust with length, padding taints result when self or padstr is tainted"
86104
fails "String#rjust with length, padding when padding is tainted and self is untainted returns a tainted string if and only if length is longer than self"
87105

106+
107+
fails "String#rstrip taints the result when self is tainted"
108+
109+
fails "String#slice with index, length always taints resulting strings when self is tainted"
110+
fails "String#slice with Range always taints resulting strings when self is tainted"
111+
fails "String#slice with Regexp always taints resulting strings when self or regexp is tainted"
112+
fails "String#slice with Regexp, index always taints resulting strings when self or regexp is tainted"
113+
fails "String#slice with String taints resulting strings when other is tainted"
114+
115+
fails "String#split with String taints the resulting strings if self is tainted"
116+
fails "String#split with Regexp taints the resulting strings if self is tainted"
117+
fails "String#split with Regexp taints an empty string if self is tainted"
118+
fails "String#split with Regexp doesn't taints the resulting strings if the Regexp is tainted"
119+
120+
fails "String#strip taints the result when self is tainted"
121+
88122
fails "String#swapcase taints resulting string when self is tainted"
89123

124+
fails "String#sub with pattern, replacement taints the result if the original string or replacement is tainted"
125+
fails "String#sub with pattern and block taints the result if the original string or replacement is tainted"
126+
127+
fails "String#succ taints the result if self is tainted"
128+
90129
fails "String#to_s taints the result when self is tainted"
91130

92131
fails "String#to_str taints the result when self is tainted"

0 commit comments

Comments
 (0)
Please sign in to comment.