parity-RedCloth 4.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gemtest +0 -0
- data/.rspec +1 -0
- data/CHANGELOG +265 -0
- data/COPYING +18 -0
- data/Gemfile +7 -0
- data/README.rdoc +215 -0
- data/Rakefile +18 -0
- data/bin/redcloth +28 -0
- data/doc/textile_reference.html +631 -0
- data/ext/redcloth_scan/extconf.rb +6 -0
- data/ext/redcloth_scan/redcloth.h +220 -0
- data/ext/redcloth_scan/redcloth_attributes.c +650 -0
- data/ext/redcloth_scan/redcloth_inline.c +8153 -0
- data/ext/redcloth_scan/redcloth_scan.c +24407 -0
- data/lib/case_sensitive_require/RedCloth.rb +6 -0
- data/lib/redcloth/erb_extension.rb +27 -0
- data/lib/redcloth/formatters/base.rb +63 -0
- data/lib/redcloth/formatters/html.rb +352 -0
- data/lib/redcloth/formatters/latex.rb +331 -0
- data/lib/redcloth/formatters/latex_entities.yml +2414 -0
- data/lib/redcloth/textile_doc.rb +113 -0
- data/lib/redcloth/version.rb +34 -0
- data/lib/redcloth.rb +45 -0
- data/lib/tasks/pureruby.rake +17 -0
- data/redcloth.gemspec +54 -0
- data/spec/benchmark_spec.rb +15 -0
- data/spec/custom_tags_spec.rb +50 -0
- data/spec/erb_spec.rb +10 -0
- data/spec/extension_spec.rb +26 -0
- data/spec/fixtures/basic.yml +1028 -0
- data/spec/fixtures/code.yml +257 -0
- data/spec/fixtures/definitions.yml +82 -0
- data/spec/fixtures/extra_whitespace.yml +64 -0
- data/spec/fixtures/filter_html.yml +177 -0
- data/spec/fixtures/filter_pba.yml +20 -0
- data/spec/fixtures/html.yml +348 -0
- data/spec/fixtures/images.yml +279 -0
- data/spec/fixtures/instiki.yml +38 -0
- data/spec/fixtures/links.yml +291 -0
- data/spec/fixtures/lists.yml +462 -0
- data/spec/fixtures/poignant.yml +89 -0
- data/spec/fixtures/sanitize_html.yml +42 -0
- data/spec/fixtures/table.yml +434 -0
- data/spec/fixtures/textism.yml +509 -0
- data/spec/fixtures/threshold.yml +762 -0
- data/spec/formatters/class_filtered_html_spec.rb +7 -0
- data/spec/formatters/filtered_html_spec.rb +7 -0
- data/spec/formatters/html_no_breaks_spec.rb +9 -0
- data/spec/formatters/html_spec.rb +13 -0
- data/spec/formatters/id_filtered_html_spec.rb +7 -0
- data/spec/formatters/latex_spec.rb +13 -0
- data/spec/formatters/lite_mode_html_spec.rb +7 -0
- data/spec/formatters/no_span_caps_html_spec.rb +7 -0
- data/spec/formatters/sanitized_html_spec.rb +7 -0
- data/spec/formatters/style_filtered_html_spec.rb +7 -0
- data/spec/parser_spec.rb +102 -0
- data/spec/spec_helper.rb +36 -0
- data/tasks/compile.rake +47 -0
- data/tasks/gems.rake +37 -0
- data/tasks/ragel_extension_task.rb +127 -0
- data/tasks/release.rake +15 -0
- data/tasks/rspec.rake +13 -0
- data/tasks/rvm.rake +79 -0
- metadata +239 -0
@@ -0,0 +1,462 @@
|
|
1
|
+
---
|
2
|
+
name: code in bullet list
|
3
|
+
in: "* command run: @time ruby run-tests.rb > toto@"
|
4
|
+
html: "<ul>\n\t<li>command run: <code>time ruby run-tests.rb > toto</code></li>\n</ul>"
|
5
|
+
--- # Bret Pettichord, Thanks.
|
6
|
+
name: hard break in list
|
7
|
+
in: |-
|
8
|
+
* first line
|
9
|
+
* second
|
10
|
+
line
|
11
|
+
* third line
|
12
|
+
html: |-
|
13
|
+
<ul>
|
14
|
+
<li>first line</li>
|
15
|
+
<li>second<br />
|
16
|
+
line</li>
|
17
|
+
<li>third line</li>
|
18
|
+
</ul>
|
19
|
+
---
|
20
|
+
name: mixed nesting
|
21
|
+
in: |-
|
22
|
+
* bullet
|
23
|
+
*# number
|
24
|
+
*# number
|
25
|
+
*#* bullet
|
26
|
+
*# number
|
27
|
+
*# number with
|
28
|
+
a break
|
29
|
+
* bullet
|
30
|
+
** okay
|
31
|
+
html: |-
|
32
|
+
<ul>
|
33
|
+
<li>bullet
|
34
|
+
<ol>
|
35
|
+
<li>number</li>
|
36
|
+
<li>number
|
37
|
+
<ul>
|
38
|
+
<li>bullet</li>
|
39
|
+
</ul></li>
|
40
|
+
<li>number</li>
|
41
|
+
<li>number with<br />
|
42
|
+
a break</li>
|
43
|
+
</ol></li>
|
44
|
+
<li>bullet
|
45
|
+
<ul>
|
46
|
+
<li>okay</li>
|
47
|
+
</ul></li>
|
48
|
+
</ul>
|
49
|
+
---
|
50
|
+
name: list continuation
|
51
|
+
in: |-
|
52
|
+
# one
|
53
|
+
# two
|
54
|
+
# three
|
55
|
+
|
56
|
+
# one
|
57
|
+
# two
|
58
|
+
# three
|
59
|
+
|
60
|
+
#_ four
|
61
|
+
# five
|
62
|
+
# six
|
63
|
+
html: |-
|
64
|
+
<ol>
|
65
|
+
<li>one</li>
|
66
|
+
<li>two</li>
|
67
|
+
<li>three</li>
|
68
|
+
</ol>
|
69
|
+
<ol>
|
70
|
+
<li>one</li>
|
71
|
+
<li>two</li>
|
72
|
+
<li>three</li>
|
73
|
+
</ol>
|
74
|
+
<ol start="4">
|
75
|
+
<li>four</li>
|
76
|
+
<li>five</li>
|
77
|
+
<li>six</li>
|
78
|
+
</ol>
|
79
|
+
valid_html: false
|
80
|
+
comment: there's not a good, valid alternative to the start attribute
|
81
|
+
---
|
82
|
+
name: continue after break
|
83
|
+
in: |-
|
84
|
+
# one
|
85
|
+
# two
|
86
|
+
# three
|
87
|
+
|
88
|
+
test
|
89
|
+
|
90
|
+
#_ four
|
91
|
+
# five
|
92
|
+
# six
|
93
|
+
|
94
|
+
test
|
95
|
+
|
96
|
+
#_ seven
|
97
|
+
# eight
|
98
|
+
# nine
|
99
|
+
html: |-
|
100
|
+
<ol>
|
101
|
+
<li>one</li>
|
102
|
+
<li>two</li>
|
103
|
+
<li>three</li>
|
104
|
+
</ol>
|
105
|
+
<p>test</p>
|
106
|
+
<ol start="4">
|
107
|
+
<li>four</li>
|
108
|
+
<li>five</li>
|
109
|
+
<li>six</li>
|
110
|
+
</ol>
|
111
|
+
<p>test</p>
|
112
|
+
<ol start="7">
|
113
|
+
<li>seven</li>
|
114
|
+
<li>eight</li>
|
115
|
+
<li>nine</li>
|
116
|
+
</ol>
|
117
|
+
valid_html: false
|
118
|
+
comment: there's not a good, valid alternative to the start attribute
|
119
|
+
---
|
120
|
+
name: continue list when prior list contained nested list
|
121
|
+
in: |-
|
122
|
+
# one
|
123
|
+
# two
|
124
|
+
# three
|
125
|
+
|
126
|
+
#_ four
|
127
|
+
# five
|
128
|
+
## sub-note
|
129
|
+
## another sub-note
|
130
|
+
# six
|
131
|
+
|
132
|
+
#_ seven
|
133
|
+
# eight
|
134
|
+
# nine
|
135
|
+
html: |-
|
136
|
+
<ol>
|
137
|
+
<li>one</li>
|
138
|
+
<li>two</li>
|
139
|
+
<li>three</li>
|
140
|
+
</ol>
|
141
|
+
<ol start="4">
|
142
|
+
<li>four</li>
|
143
|
+
<li>five
|
144
|
+
<ol>
|
145
|
+
<li>sub-note</li>
|
146
|
+
<li>another sub-note</li>
|
147
|
+
</ol></li>
|
148
|
+
<li>six</li>
|
149
|
+
</ol>
|
150
|
+
<ol start="7">
|
151
|
+
<li>seven</li>
|
152
|
+
<li>eight</li>
|
153
|
+
<li>nine</li>
|
154
|
+
</ol>
|
155
|
+
valid_html: false
|
156
|
+
comment: there's not a good, valid alternative to the start attribute
|
157
|
+
---
|
158
|
+
name: list start number
|
159
|
+
in: |-
|
160
|
+
#293 two ninety three
|
161
|
+
# two ninety four
|
162
|
+
# two ninety five
|
163
|
+
|
164
|
+
#9 nine
|
165
|
+
# ten
|
166
|
+
# eleven
|
167
|
+
html: |-
|
168
|
+
<ol start="293">
|
169
|
+
<li>two ninety three</li>
|
170
|
+
<li>two ninety four</li>
|
171
|
+
<li>two ninety five</li>
|
172
|
+
</ol>
|
173
|
+
<ol start="9">
|
174
|
+
<li>nine</li>
|
175
|
+
<li>ten</li>
|
176
|
+
<li>eleven</li>
|
177
|
+
</ol>
|
178
|
+
valid_html: false
|
179
|
+
comment: there's not a good, valid alternative to the start attribute
|
180
|
+
---
|
181
|
+
name: continue list after started list
|
182
|
+
in: |-
|
183
|
+
#9 nine
|
184
|
+
# ten
|
185
|
+
# eleven
|
186
|
+
|
187
|
+
#_ twelve
|
188
|
+
# thirteen
|
189
|
+
# fourteen
|
190
|
+
html: |-
|
191
|
+
<ol start="9">
|
192
|
+
<li>nine</li>
|
193
|
+
<li>ten</li>
|
194
|
+
<li>eleven</li>
|
195
|
+
</ol>
|
196
|
+
<ol start="12">
|
197
|
+
<li>twelve</li>
|
198
|
+
<li>thirteen</li>
|
199
|
+
<li>fourteen</li>
|
200
|
+
</ol>
|
201
|
+
valid_html: false
|
202
|
+
comment: there's not a good, valid alternative to the start attribute
|
203
|
+
---
|
204
|
+
name: end notes
|
205
|
+
in: |-
|
206
|
+
h2. End Notes
|
207
|
+
|
208
|
+
# End Notes should be a numbered list
|
209
|
+
# Like this
|
210
|
+
# They must have anchors in the text
|
211
|
+
|
212
|
+
h2. See Also
|
213
|
+
|
214
|
+
* See Also notes should be bullets
|
215
|
+
* Like this
|
216
|
+
|
217
|
+
html: |-
|
218
|
+
<h2>End Notes</h2>
|
219
|
+
<ol>
|
220
|
+
<li>End Notes should be a numbered list</li>
|
221
|
+
<li>Like this</li>
|
222
|
+
<li>They must have anchors in the text</li>
|
223
|
+
</ol>
|
224
|
+
<h2>See Also</h2>
|
225
|
+
<ul>
|
226
|
+
<li>See Also notes should be bullets</li>
|
227
|
+
<li>Like this</li>
|
228
|
+
</ul>
|
229
|
+
---
|
230
|
+
name: ordered list immediately following paragraph
|
231
|
+
desc: Normally a paragraph and a list that follows it should be separated by two newlines. Textile-2.0.0 recognizes the list even when separated by only one newline, but creates invalid XHTML by placing the list inside the paragraph. RedCloth recognizes the pattern for backward compatibility, but creates valid XHTML.
|
232
|
+
in: |-
|
233
|
+
A simple example.
|
234
|
+
# One
|
235
|
+
# Two
|
236
|
+
html: |-
|
237
|
+
<p>A simple example.</p>
|
238
|
+
<ol>
|
239
|
+
<li>One</li>
|
240
|
+
<li>Two</li>
|
241
|
+
</ol>
|
242
|
+
---
|
243
|
+
name: unordered list immediately following paragraph
|
244
|
+
in: |-
|
245
|
+
A simple example.
|
246
|
+
* One
|
247
|
+
* Two
|
248
|
+
html: |-
|
249
|
+
<p>A simple example.</p>
|
250
|
+
<ul>
|
251
|
+
<li>One</li>
|
252
|
+
<li>Two</li>
|
253
|
+
</ul>
|
254
|
+
---
|
255
|
+
name: ordered list immediately following extended block
|
256
|
+
in: |-
|
257
|
+
div.. Here it comes.
|
258
|
+
|
259
|
+
A simple example.
|
260
|
+
# One
|
261
|
+
# Two
|
262
|
+
html: |-
|
263
|
+
<div>Here it comes.</div>
|
264
|
+
<div>A simple example.</div>
|
265
|
+
<ol>
|
266
|
+
<li>One</li>
|
267
|
+
<li>Two</li>
|
268
|
+
</ol>
|
269
|
+
---
|
270
|
+
name: unordered list immediately following extended block
|
271
|
+
in: |-
|
272
|
+
div.. Here it comes.
|
273
|
+
|
274
|
+
A simple example.
|
275
|
+
* One
|
276
|
+
* Two
|
277
|
+
html: |-
|
278
|
+
<div>Here it comes.</div>
|
279
|
+
<div>A simple example.</div>
|
280
|
+
<ul>
|
281
|
+
<li>One</li>
|
282
|
+
<li>Two</li>
|
283
|
+
</ul>
|
284
|
+
---
|
285
|
+
name: unordered list with leading spaces
|
286
|
+
in: " * notice the leading space\n * RedCloth 3.0.4 used to accept it\n * Now we do too"
|
287
|
+
html: |-
|
288
|
+
<ul>
|
289
|
+
<li>notice the leading space</li>
|
290
|
+
<li>RedCloth 3.0.4 used to accept it</li>
|
291
|
+
<li>Now we do too</li>
|
292
|
+
</ul>
|
293
|
+
---
|
294
|
+
name: ordered list with leading spaces
|
295
|
+
in: " # notice the leading space\n # RedCloth 3.0.4 used to accept it\n # Now we do too"
|
296
|
+
html: |-
|
297
|
+
<ol>
|
298
|
+
<li>notice the leading space</li>
|
299
|
+
<li>RedCloth 3.0.4 used to accept it</li>
|
300
|
+
<li>Now we do too</li>
|
301
|
+
</ol>
|
302
|
+
---
|
303
|
+
name: unordered with classes
|
304
|
+
in: |-
|
305
|
+
*(class-one) one
|
306
|
+
*(class-two) two
|
307
|
+
*(class-three) three
|
308
|
+
html: |-
|
309
|
+
<ul>
|
310
|
+
<li class="class-one">one</li>
|
311
|
+
<li class="class-two">two</li>
|
312
|
+
<li class="class-three">three</li>
|
313
|
+
</ul>
|
314
|
+
---
|
315
|
+
name: unordered with alignments
|
316
|
+
in: |-
|
317
|
+
*< one
|
318
|
+
*> two
|
319
|
+
*<> three
|
320
|
+
*= four
|
321
|
+
html: |-
|
322
|
+
<ul>
|
323
|
+
<li style="text-align:left;">one</li>
|
324
|
+
<li style="text-align:right;">two</li>
|
325
|
+
<li style="text-align:justify;">three</li>
|
326
|
+
<li style="text-align:center;">four</li>
|
327
|
+
</ul>
|
328
|
+
---
|
329
|
+
name: with attributes that apply to the whole list
|
330
|
+
in: |-
|
331
|
+
(class#id)# one
|
332
|
+
# two
|
333
|
+
# three
|
334
|
+
html: |-
|
335
|
+
<ol class="class" id="id">
|
336
|
+
<li>one</li>
|
337
|
+
<li>two</li>
|
338
|
+
<li>three</li>
|
339
|
+
</ol>
|
340
|
+
---
|
341
|
+
name: with id on the list
|
342
|
+
in: |-
|
343
|
+
(#my-id)# one
|
344
|
+
# two
|
345
|
+
# three
|
346
|
+
html: |-
|
347
|
+
<ol id="my-id">
|
348
|
+
<li>one</li>
|
349
|
+
<li>two</li>
|
350
|
+
<li>three</li>
|
351
|
+
</ol>
|
352
|
+
---
|
353
|
+
name: with class on the list
|
354
|
+
in: |-
|
355
|
+
(my-class)# one
|
356
|
+
# two
|
357
|
+
# three
|
358
|
+
html: |-
|
359
|
+
<ol class="my-class">
|
360
|
+
<li>one</li>
|
361
|
+
<li>two</li>
|
362
|
+
<li>three</li>
|
363
|
+
</ol>
|
364
|
+
---
|
365
|
+
name: with id on the list item
|
366
|
+
in: |-
|
367
|
+
# one
|
368
|
+
#(#my-item) two
|
369
|
+
# three
|
370
|
+
html: |-
|
371
|
+
<ol>
|
372
|
+
<li>one</li>
|
373
|
+
<li id="my-item">two</li>
|
374
|
+
<li>three</li>
|
375
|
+
</ol>
|
376
|
+
---
|
377
|
+
name: with attributes that apply to the first list item
|
378
|
+
in: |-
|
379
|
+
#(class#id) one
|
380
|
+
# two
|
381
|
+
# three
|
382
|
+
html: |-
|
383
|
+
<ol>
|
384
|
+
<li class="class" id="id">one</li>
|
385
|
+
<li>two</li>
|
386
|
+
<li>three</li>
|
387
|
+
</ol>
|
388
|
+
---
|
389
|
+
name: changed from textism basics
|
390
|
+
desc: "This was in Textism basics, but when I changed the format of list styles, I removed it"
|
391
|
+
in: |-
|
392
|
+
{color:blue}# one
|
393
|
+
# two
|
394
|
+
# three
|
395
|
+
html: |-
|
396
|
+
<ol style="color:blue;">
|
397
|
+
<li>one</li>
|
398
|
+
<li>two</li>
|
399
|
+
<li>three</li>
|
400
|
+
</ol>
|
401
|
+
---
|
402
|
+
name: changed from threshold list attributes
|
403
|
+
desc: "Was: 'Attributes applied to the first list item will apply to the list itself.' but then we changed it"
|
404
|
+
in: |-
|
405
|
+
*{color:red} Item one
|
406
|
+
* Item two
|
407
|
+
* Item three
|
408
|
+
html: |-
|
409
|
+
<ul>
|
410
|
+
<li style="color:red;">Item one</li>
|
411
|
+
<li>Item two</li>
|
412
|
+
<li>Item three</li>
|
413
|
+
</ul>
|
414
|
+
---
|
415
|
+
name: with one padding-left increment
|
416
|
+
in: "(# one"
|
417
|
+
html: |-
|
418
|
+
<ol style="padding-left:1em;">
|
419
|
+
<li>one</li>
|
420
|
+
</ol>
|
421
|
+
---
|
422
|
+
name: with one padding-left increment and class
|
423
|
+
in: "((myclass)# one"
|
424
|
+
html: |-
|
425
|
+
<ol style="padding-left:1em;" class="myclass">
|
426
|
+
<li>one</li>
|
427
|
+
</ol>
|
428
|
+
---
|
429
|
+
name: with two padding-left increments
|
430
|
+
in: "((# two"
|
431
|
+
html: |-
|
432
|
+
<ol style="padding-left:2em;">
|
433
|
+
<li>two</li>
|
434
|
+
</ol>
|
435
|
+
---
|
436
|
+
name: with one padding-right increment
|
437
|
+
in: ")# one"
|
438
|
+
html: |-
|
439
|
+
<ol style="padding-right:1em;">
|
440
|
+
<li>one</li>
|
441
|
+
</ol>
|
442
|
+
---
|
443
|
+
name: with padding-left and padding-right increments
|
444
|
+
in: "()# two"
|
445
|
+
html: |-
|
446
|
+
<ol style="padding-left:1em;padding-right:1em;">
|
447
|
+
<li>two</li>
|
448
|
+
</ol>
|
449
|
+
---
|
450
|
+
name: with padding-left and padding-right increments switched
|
451
|
+
in: ")(# two"
|
452
|
+
html: |-
|
453
|
+
<ol style="padding-left:1em;padding-right:1em;">
|
454
|
+
<li>two</li>
|
455
|
+
</ol>
|
456
|
+
---
|
457
|
+
name: with padding-left and padding-right increments and class
|
458
|
+
in: "()(myclass)# two"
|
459
|
+
html: |-
|
460
|
+
<ol style="padding-left:1em;padding-right:1em;" class="myclass">
|
461
|
+
<li>two</li>
|
462
|
+
</ol>
|
@@ -0,0 +1,89 @@
|
|
1
|
+
--- # Tests from the (Poignant Guide)
|
2
|
+
in: >
|
3
|
+
h3. False
|
4
|
+
|
5
|
+
|
6
|
+
!<i/blix-neg.gif(Shape of a cat.)!
|
7
|
+
|
8
|
+
|
9
|
+
_The cat Trady Blix. Frozen in emptiness. Immaculate whiskers rigid. Placid
|
10
|
+
eyes of lake. Tail of warm icicle. Sponsored by a Very Powerful Pause Button._
|
11
|
+
|
12
|
+
|
13
|
+
The darkness surrounding Blix can be called *negative space*. Hang on to that phrase.
|
14
|
+
Let it suggest that the emptiness has a negative connotation. In a similar way,
|
15
|
+
@nil@ has a slightly sour note that it whistles.
|
16
|
+
|
17
|
+
|
18
|
+
Generally speaking, everything in Ruby has a positive charge to it. This spark
|
19
|
+
flows through strings, numbers, regexps, all of it. Only two keywords wear a
|
20
|
+
shady cloak: @nil@ and @false@ draggin us down.
|
21
|
+
|
22
|
+
|
23
|
+
You can test that charge with an @if@ keyword. It looks very much like the
|
24
|
+
@do@ blocks we saw in the last chapter, in that both end with an @end@.
|
25
|
+
|
26
|
+
|
27
|
+
<pre>
|
28
|
+
if plastic_cup
|
29
|
+
print "Plastic cup is on the up 'n' up!"
|
30
|
+
end
|
31
|
+
</pre>
|
32
|
+
|
33
|
+
|
34
|
+
If @plastic_cup@ contains either @nil@ or @false@, you won't see anything print
|
35
|
+
to the screen. They're not on the @if@ guest list. So @if@ isn't going to run
|
36
|
+
any of the code it's protecting.
|
37
|
+
|
38
|
+
|
39
|
+
But @nil@ and @false@ need not walk away in shame. They may be of questionable
|
40
|
+
character, but @unless@ runs a smaller establishment that caters to the bedraggled.
|
41
|
+
The @unless@ keyword has a policy of only allowing those with a negative charge in.
|
42
|
+
Who are: @nil@ and @false@.
|
43
|
+
|
44
|
+
|
45
|
+
<pre>
|
46
|
+
unless plastic_cup
|
47
|
+
print "Plastic cup is on the down low."
|
48
|
+
end
|
49
|
+
</pre>
|
50
|
+
|
51
|
+
|
52
|
+
You can also use @if@ and @unless@ at the end of a single line of code, if that's
|
53
|
+
all that is being protected.
|
54
|
+
|
55
|
+
|
56
|
+
<pre>
|
57
|
+
print "Yeah, plastic cup is up again!" if plastic_cup
|
58
|
+
print "Hardly. It's down." unless plastic_cup
|
59
|
+
</pre>
|
60
|
+
|
61
|
+
|
62
|
+
Now that you've met @false@, I'm sure you can see what's on next.
|
63
|
+
|
64
|
+
html: |-
|
65
|
+
<h3>False</h3>
|
66
|
+
<p style="float:left;"><img src="i/blix-neg.gif" title="Shape of a cat." alt="Shape of a cat." /></p>
|
67
|
+
<p><em>The cat Trady Blix. Frozen in emptiness. Immaculate whiskers rigid. Placid eyes of lake. Tail of warm icicle. Sponsored by a Very Powerful Pause Button.</em></p>
|
68
|
+
<p>The darkness surrounding Blix can be called <strong>negative space</strong>. Hang on to that phrase. Let it suggest that the emptiness has a negative connotation. In a similar way, <code>nil</code> has a slightly sour note that it whistles.</p>
|
69
|
+
<p>Generally speaking, everything in Ruby has a positive charge to it. This spark flows through strings, numbers, regexps, all of it. Only two keywords wear a shady cloak: <code>nil</code> and <code>false</code> draggin us down.</p>
|
70
|
+
<p>You can test that charge with an <code>if</code> keyword. It looks very much like the <code>do</code> blocks we saw in the last chapter, in that both end with an <code>end</code>.</p>
|
71
|
+
<pre>
|
72
|
+
if plastic_cup
|
73
|
+
print "Plastic cup is on the up 'n' up!"
|
74
|
+
end
|
75
|
+
</pre>
|
76
|
+
<p>If <code>plastic_cup</code> contains either <code>nil</code> or <code>false</code>, you won’t see anything print to the screen. They’re not on the <code>if</code> guest list. So <code>if</code> isn’t going to run any of the code it’s protecting.</p>
|
77
|
+
<p>But <code>nil</code> and <code>false</code> need not walk away in shame. They may be of questionable character, but <code>unless</code> runs a smaller establishment that caters to the bedraggled. The <code>unless</code> keyword has a policy of only allowing those with a negative charge in. Who are: <code>nil</code> and <code>false</code>.</p>
|
78
|
+
<pre>
|
79
|
+
unless plastic_cup
|
80
|
+
print "Plastic cup is on the down low."
|
81
|
+
end
|
82
|
+
</pre>
|
83
|
+
<p>You can also use <code>if</code> and <code>unless</code> at the end of a single line of code, if that’s all that is being protected.</p>
|
84
|
+
<pre>
|
85
|
+
print "Yeah, plastic cup is up again!" if plastic_cup
|
86
|
+
print "Hardly. It's down." unless plastic_cup
|
87
|
+
</pre>
|
88
|
+
<p>Now that you’ve met <code>false</code>, I’m sure you can see what’s on next.</p>
|
89
|
+
|
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
in: Just a little harmless xss <script src=http://ha.ckers.org/xss.js>stuff</script>.
|
3
|
+
sanitized_html: <p>Just a little harmless xss stuff.</p>
|
4
|
+
---
|
5
|
+
in: Here's a bad image <img src="JaVaScRiPt:alert('XSS');" />
|
6
|
+
sanitized_html: <p>Here’s a bad image <img /></p>
|
7
|
+
---
|
8
|
+
in: Just some random > and < characters, but also a <br/> tag.
|
9
|
+
sanitized_html: <p>Just some random > and < characters, but also a <br/> tag.</p>
|
10
|
+
---
|
11
|
+
name: processes text beginning with space
|
12
|
+
in: ' This began with a space and ends with some XSS: <script type="text/javascript">alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");</script>'
|
13
|
+
sanitized_html: 'This began with a space and ends with some <span class="caps">XSS</span>: alert(“Hai. I`m in ya PC. Makin ya <span class="caps">XSS</span> viruzz! KThxBye”);'
|
14
|
+
---
|
15
|
+
name: processes text in notextile tags
|
16
|
+
in: |-
|
17
|
+
<notextile>
|
18
|
+
The bad tags should be <b>missing</b>: <script type="text/javascript">alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");</script>
|
19
|
+
</notextile>
|
20
|
+
sanitized_html: |-
|
21
|
+
The bad tags should be <b>missing</b>: alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");
|
22
|
+
---
|
23
|
+
name: processes text in inline notextile tags
|
24
|
+
in: |-
|
25
|
+
The bad tags should be <b>missing</b>: <notextile><script type="text/javascript">alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");</script></notextile>
|
26
|
+
sanitized_html: |-
|
27
|
+
<p>The bad tags should be <b>missing</b>: alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");</p>
|
28
|
+
---
|
29
|
+
name: removes script tags
|
30
|
+
in: |-
|
31
|
+
<script type="text/javascript">
|
32
|
+
alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");
|
33
|
+
</script>
|
34
|
+
sanitized_html: "alert(“Hai. I`m in ya PC. Makin ya <span class=\"caps\">XSS</span> viruzz! KThxBye”);"
|
35
|
+
---
|
36
|
+
name: removes nested script tags
|
37
|
+
in: |-
|
38
|
+
<script type="text/javascript"><script>
|
39
|
+
alert("Hai. I`m in ya PC. Makin ya XSS viruzz! KThxBye");
|
40
|
+
</script></script>
|
41
|
+
sanitized_html: |-
|
42
|
+
alert(“Hai. I`m in ya PC. Makin ya <span class="caps">XSS</span> viruzz! KThxBye”);
|