selma 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Cargo.lock +133 -75
- data/Cargo.toml +2 -0
- data/README.md +108 -24
- data/ext/selma/Cargo.toml +3 -1
- data/ext/selma/src/rewriter.rs +5 -4
- data/ext/selma/src/sanitizer.rs +20 -13
- data/ext/selma/src/tags.rs +1 -1
- data/lib/selma/sanitizer/config/default.rb +1 -1
- data/lib/selma/sanitizer/config/relaxed.rb +1 -0
- data/lib/selma/sanitizer.rb +6 -1
- data/lib/selma/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69919cfb80c694b6f77e4e29e29c66d7b482d96ec83a9f47d3a3711d0b636924
|
4
|
+
data.tar.gz: 66f9f62677e3f25391180eb9e952852a351cae1d165b2427fe9c537f05884121
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb26ee26a928c9aa30c6f71e78914317213552c21729c6ffb46712859eac21b4ddc67709584e4af9ac2a0e4e5b98acce5e5fdbdfd921afdd124faac647b0db05
|
7
|
+
data.tar.gz: 9ed49314dc03d3d8f7c6a3b67da8e77536a13a8efd04a8d519796751832527339d291722ac7cb3e44dab9224c2294e70378e0c37d79c97aa3f924506567a990d
|
data/Cargo.lock
CHANGED
@@ -4,13 +4,14 @@ version = 3
|
|
4
4
|
|
5
5
|
[[package]]
|
6
6
|
name = "ahash"
|
7
|
-
version = "0.8.
|
7
|
+
version = "0.8.7"
|
8
8
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
9
|
-
checksum = "
|
9
|
+
checksum = "77c3a9648d43b9cd48db467b3f87fdd6e146bcc88ab0180006cef2179fe11d01"
|
10
10
|
dependencies = [
|
11
11
|
"cfg-if",
|
12
12
|
"once_cell",
|
13
13
|
"version_check",
|
14
|
+
"zerocopy",
|
14
15
|
]
|
15
16
|
|
16
17
|
[[package]]
|
@@ -24,11 +25,11 @@ dependencies = [
|
|
24
25
|
|
25
26
|
[[package]]
|
26
27
|
name = "bindgen"
|
27
|
-
version = "0.
|
28
|
+
version = "0.69.1"
|
28
29
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
29
|
-
checksum = "
|
30
|
+
checksum = "9ffcebc3849946a7170a05992aac39da343a90676ab392c51a4280981d6379c2"
|
30
31
|
dependencies = [
|
31
|
-
"bitflags 2.4.
|
32
|
+
"bitflags 2.4.1",
|
32
33
|
"cexpr",
|
33
34
|
"clang-sys",
|
34
35
|
"lazy_static",
|
@@ -39,7 +40,7 @@ dependencies = [
|
|
39
40
|
"regex",
|
40
41
|
"rustc-hash",
|
41
42
|
"shlex",
|
42
|
-
"syn 2.0.
|
43
|
+
"syn 2.0.46",
|
43
44
|
]
|
44
45
|
|
45
46
|
[[package]]
|
@@ -50,9 +51,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
|
50
51
|
|
51
52
|
[[package]]
|
52
53
|
name = "bitflags"
|
53
|
-
version = "2.4.
|
54
|
+
version = "2.4.1"
|
54
55
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
55
|
-
checksum = "
|
56
|
+
checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
|
56
57
|
|
57
58
|
[[package]]
|
58
59
|
name = "byteorder"
|
@@ -77,9 +78,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
|
77
78
|
|
78
79
|
[[package]]
|
79
80
|
name = "clang-sys"
|
80
|
-
version = "1.
|
81
|
+
version = "1.7.0"
|
81
82
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
82
|
-
checksum = "
|
83
|
+
checksum = "67523a3b4be3ce1989d607a828d036249522dd9c1c8de7f4dd2dae43a37369d1"
|
83
84
|
dependencies = [
|
84
85
|
"glob",
|
85
86
|
"libc",
|
@@ -116,7 +117,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
116
117
|
checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"
|
117
118
|
dependencies = [
|
118
119
|
"quote",
|
119
|
-
"syn 2.0.
|
120
|
+
"syn 2.0.46",
|
120
121
|
]
|
121
122
|
|
122
123
|
[[package]]
|
@@ -164,22 +165,22 @@ checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca"
|
|
164
165
|
|
165
166
|
[[package]]
|
166
167
|
name = "enum-iterator"
|
167
|
-
version = "1.
|
168
|
+
version = "2.1.0"
|
168
169
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
169
|
-
checksum = "
|
170
|
+
checksum = "c280b9e6b3ae19e152d8e31cf47f18389781e119d4013a2a2bb0180e5facc635"
|
170
171
|
dependencies = [
|
171
172
|
"enum-iterator-derive",
|
172
173
|
]
|
173
174
|
|
174
175
|
[[package]]
|
175
176
|
name = "enum-iterator-derive"
|
176
|
-
version = "1.
|
177
|
+
version = "1.4.0"
|
177
178
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
178
|
-
checksum = "
|
179
|
+
checksum = "a1ab991c1362ac86c61ab6f556cff143daa22e5a15e4e189df818b2fd19fe65b"
|
179
180
|
dependencies = [
|
180
181
|
"proc-macro2",
|
181
182
|
"quote",
|
182
|
-
"syn 2.0.
|
183
|
+
"syn 2.0.46",
|
183
184
|
]
|
184
185
|
|
185
186
|
[[package]]
|
@@ -246,18 +247,18 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
|
246
247
|
|
247
248
|
[[package]]
|
248
249
|
name = "libc"
|
249
|
-
version = "0.2.
|
250
|
+
version = "0.2.151"
|
250
251
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
251
|
-
checksum = "
|
252
|
+
checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
|
252
253
|
|
253
254
|
[[package]]
|
254
255
|
name = "libloading"
|
255
|
-
version = "0.
|
256
|
+
version = "0.8.1"
|
256
257
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
257
|
-
checksum = "
|
258
|
+
checksum = "c571b676ddfc9a8c12f1f3d3085a7b163966a8fd8098a90640953ce5f6170161"
|
258
259
|
dependencies = [
|
259
260
|
"cfg-if",
|
260
|
-
"
|
261
|
+
"windows-sys",
|
261
262
|
]
|
262
263
|
|
263
264
|
[[package]]
|
@@ -268,11 +269,11 @@ checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
|
|
268
269
|
|
269
270
|
[[package]]
|
270
271
|
name = "lol_html"
|
271
|
-
version = "1.2.
|
272
|
+
version = "1.2.1"
|
272
273
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
273
|
-
checksum = "
|
274
|
+
checksum = "a4629ff9c2deeb7aad9b2d0f379fc41937a02f3b739f007732c46af40339dee5"
|
274
275
|
dependencies = [
|
275
|
-
"bitflags 2.4.
|
276
|
+
"bitflags 2.4.1",
|
276
277
|
"cfg-if",
|
277
278
|
"cssparser",
|
278
279
|
"encoding_rs",
|
@@ -281,16 +282,15 @@ dependencies = [
|
|
281
282
|
"lazycell",
|
282
283
|
"memchr",
|
283
284
|
"mime",
|
284
|
-
"safemem",
|
285
285
|
"selectors",
|
286
286
|
"thiserror",
|
287
287
|
]
|
288
288
|
|
289
289
|
[[package]]
|
290
290
|
name = "magnus"
|
291
|
-
version = "0.6.
|
291
|
+
version = "0.6.4"
|
292
292
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
293
|
-
checksum = "
|
293
|
+
checksum = "b1597ef40aa8c36be098249e82c9a20cf7199278ac1c1a1a995eeead6a184479"
|
294
294
|
dependencies = [
|
295
295
|
"magnus-macros",
|
296
296
|
"rb-sys",
|
@@ -306,7 +306,7 @@ checksum = "5968c820e2960565f647819f5928a42d6e874551cab9d88d75e3e0660d7f71e3"
|
|
306
306
|
dependencies = [
|
307
307
|
"proc-macro2",
|
308
308
|
"quote",
|
309
|
-
"syn 2.0.
|
309
|
+
"syn 2.0.46",
|
310
310
|
]
|
311
311
|
|
312
312
|
[[package]]
|
@@ -317,9 +317,9 @@ checksum = "2532096657941c2fea9c289d370a250971c689d4f143798ff67113ec042024a5"
|
|
317
317
|
|
318
318
|
[[package]]
|
319
319
|
name = "memchr"
|
320
|
-
version = "2.
|
320
|
+
version = "2.7.1"
|
321
321
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
322
|
-
checksum = "
|
322
|
+
checksum = "523dc4f511e55ab87b694dc30d0f820d60906ef06413f93d4d7a1385599cc149"
|
323
323
|
|
324
324
|
[[package]]
|
325
325
|
name = "mime"
|
@@ -351,9 +351,9 @@ dependencies = [
|
|
351
351
|
|
352
352
|
[[package]]
|
353
353
|
name = "once_cell"
|
354
|
-
version = "1.
|
354
|
+
version = "1.19.0"
|
355
355
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
356
|
-
checksum = "
|
356
|
+
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
357
357
|
|
358
358
|
[[package]]
|
359
359
|
name = "peeking_take_while"
|
@@ -435,18 +435,18 @@ checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068"
|
|
435
435
|
|
436
436
|
[[package]]
|
437
437
|
name = "proc-macro2"
|
438
|
-
version = "1.0.
|
438
|
+
version = "1.0.74"
|
439
439
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
440
|
-
checksum = "
|
440
|
+
checksum = "2de98502f212cfcea8d0bb305bd0f49d7ebdd75b64ba0a68f937d888f4e0d6db"
|
441
441
|
dependencies = [
|
442
442
|
"unicode-ident",
|
443
443
|
]
|
444
444
|
|
445
445
|
[[package]]
|
446
446
|
name = "quote"
|
447
|
-
version = "1.0.
|
447
|
+
version = "1.0.35"
|
448
448
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
449
|
-
checksum = "
|
449
|
+
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
450
450
|
dependencies = [
|
451
451
|
"proc-macro2",
|
452
452
|
]
|
@@ -504,18 +504,18 @@ dependencies = [
|
|
504
504
|
|
505
505
|
[[package]]
|
506
506
|
name = "rb-sys"
|
507
|
-
version = "0.9.
|
507
|
+
version = "0.9.85"
|
508
508
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
509
|
-
checksum = "
|
509
|
+
checksum = "05b780e6858b0b0eced1d55d0f097c024b77a37b41f83bd35341130f78e37c51"
|
510
510
|
dependencies = [
|
511
511
|
"rb-sys-build",
|
512
512
|
]
|
513
513
|
|
514
514
|
[[package]]
|
515
515
|
name = "rb-sys-build"
|
516
|
-
version = "0.9.
|
516
|
+
version = "0.9.85"
|
517
517
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
518
|
-
checksum = "
|
518
|
+
checksum = "44957a3bc513dad1b0f20bdd0ee3b82e729a59da44086a6b40d8bc71958a6db8"
|
519
519
|
dependencies = [
|
520
520
|
"bindgen",
|
521
521
|
"lazy_static",
|
@@ -523,7 +523,7 @@ dependencies = [
|
|
523
523
|
"quote",
|
524
524
|
"regex",
|
525
525
|
"shell-words",
|
526
|
-
"syn 2.0.
|
526
|
+
"syn 2.0.46",
|
527
527
|
]
|
528
528
|
|
529
529
|
[[package]]
|
@@ -534,9 +534,9 @@ checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
|
|
534
534
|
|
535
535
|
[[package]]
|
536
536
|
name = "regex"
|
537
|
-
version = "1.10.
|
537
|
+
version = "1.10.2"
|
538
538
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
539
|
-
checksum = "
|
539
|
+
checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343"
|
540
540
|
dependencies = [
|
541
541
|
"aho-corasick",
|
542
542
|
"memchr",
|
@@ -546,9 +546,9 @@ dependencies = [
|
|
546
546
|
|
547
547
|
[[package]]
|
548
548
|
name = "regex-automata"
|
549
|
-
version = "0.4.
|
549
|
+
version = "0.4.3"
|
550
550
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
551
|
-
checksum = "
|
551
|
+
checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f"
|
552
552
|
dependencies = [
|
553
553
|
"aho-corasick",
|
554
554
|
"memchr",
|
@@ -557,9 +557,9 @@ dependencies = [
|
|
557
557
|
|
558
558
|
[[package]]
|
559
559
|
name = "regex-syntax"
|
560
|
-
version = "0.8.
|
560
|
+
version = "0.8.2"
|
561
561
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
562
|
-
checksum = "
|
562
|
+
checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f"
|
563
563
|
|
564
564
|
[[package]]
|
565
565
|
name = "rustc-hash"
|
@@ -576,12 +576,6 @@ dependencies = [
|
|
576
576
|
"semver",
|
577
577
|
]
|
578
578
|
|
579
|
-
[[package]]
|
580
|
-
name = "safemem"
|
581
|
-
version = "0.3.3"
|
582
|
-
source = "registry+https://github.com/rust-lang/crates.io-index"
|
583
|
-
checksum = "ef703b7cb59335eae2eb93ceb664c0eb7ea6bf567079d843e09420219668e072"
|
584
|
-
|
585
579
|
[[package]]
|
586
580
|
name = "selectors"
|
587
581
|
version = "0.22.0"
|
@@ -614,9 +608,9 @@ dependencies = [
|
|
614
608
|
|
615
609
|
[[package]]
|
616
610
|
name = "semver"
|
617
|
-
version = "1.0.
|
611
|
+
version = "1.0.21"
|
618
612
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
619
|
-
checksum = "
|
613
|
+
checksum = "b97ed7a9823b74f99c7742f5336af7be5ecd3eeafcb1507d1fa93347b1d589b0"
|
620
614
|
|
621
615
|
[[package]]
|
622
616
|
name = "seq-macro"
|
@@ -654,9 +648,9 @@ checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
|
|
654
648
|
|
655
649
|
[[package]]
|
656
650
|
name = "smallvec"
|
657
|
-
version = "1.11.
|
651
|
+
version = "1.11.2"
|
658
652
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
659
|
-
checksum = "
|
653
|
+
checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"
|
660
654
|
|
661
655
|
[[package]]
|
662
656
|
name = "stable_deref_trait"
|
@@ -677,9 +671,9 @@ dependencies = [
|
|
677
671
|
|
678
672
|
[[package]]
|
679
673
|
name = "syn"
|
680
|
-
version = "2.0.
|
674
|
+
version = "2.0.46"
|
681
675
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
682
|
-
checksum = "
|
676
|
+
checksum = "89456b690ff72fddcecf231caedbe615c59480c93358a93dfae7fc29e3ebbf0e"
|
683
677
|
dependencies = [
|
684
678
|
"proc-macro2",
|
685
679
|
"quote",
|
@@ -694,22 +688,22 @@ checksum = "8eaa81235c7058867fa8c0e7314f33dcce9c215f535d1913822a2b3f5e289f3c"
|
|
694
688
|
|
695
689
|
[[package]]
|
696
690
|
name = "thiserror"
|
697
|
-
version = "1.0.
|
691
|
+
version = "1.0.56"
|
698
692
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
699
|
-
checksum = "
|
693
|
+
checksum = "d54378c645627613241d077a3a79db965db602882668f9136ac42af9ecb730ad"
|
700
694
|
dependencies = [
|
701
695
|
"thiserror-impl",
|
702
696
|
]
|
703
697
|
|
704
698
|
[[package]]
|
705
699
|
name = "thiserror-impl"
|
706
|
-
version = "1.0.
|
700
|
+
version = "1.0.56"
|
707
701
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
708
|
-
checksum = "
|
702
|
+
checksum = "fa0faa943b50f3db30a20aa7e265dbc66076993efed8463e8de414e5d06d3471"
|
709
703
|
dependencies = [
|
710
704
|
"proc-macro2",
|
711
705
|
"quote",
|
712
|
-
"syn 2.0.
|
706
|
+
"syn 2.0.46",
|
713
707
|
]
|
714
708
|
|
715
709
|
[[package]]
|
@@ -731,23 +725,87 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
731
725
|
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
732
726
|
|
733
727
|
[[package]]
|
734
|
-
name = "
|
735
|
-
version = "0.
|
728
|
+
name = "windows-sys"
|
729
|
+
version = "0.48.0"
|
736
730
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
737
|
-
checksum = "
|
731
|
+
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
738
732
|
dependencies = [
|
739
|
-
"
|
740
|
-
"winapi-x86_64-pc-windows-gnu",
|
733
|
+
"windows-targets",
|
741
734
|
]
|
742
735
|
|
743
736
|
[[package]]
|
744
|
-
name = "
|
745
|
-
version = "0.
|
737
|
+
name = "windows-targets"
|
738
|
+
version = "0.48.5"
|
739
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
740
|
+
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
741
|
+
dependencies = [
|
742
|
+
"windows_aarch64_gnullvm",
|
743
|
+
"windows_aarch64_msvc",
|
744
|
+
"windows_i686_gnu",
|
745
|
+
"windows_i686_msvc",
|
746
|
+
"windows_x86_64_gnu",
|
747
|
+
"windows_x86_64_gnullvm",
|
748
|
+
"windows_x86_64_msvc",
|
749
|
+
]
|
750
|
+
|
751
|
+
[[package]]
|
752
|
+
name = "windows_aarch64_gnullvm"
|
753
|
+
version = "0.48.5"
|
746
754
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
747
|
-
checksum = "
|
755
|
+
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
748
756
|
|
749
757
|
[[package]]
|
750
|
-
name = "
|
751
|
-
version = "0.
|
758
|
+
name = "windows_aarch64_msvc"
|
759
|
+
version = "0.48.5"
|
760
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
761
|
+
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
762
|
+
|
763
|
+
[[package]]
|
764
|
+
name = "windows_i686_gnu"
|
765
|
+
version = "0.48.5"
|
766
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
767
|
+
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
768
|
+
|
769
|
+
[[package]]
|
770
|
+
name = "windows_i686_msvc"
|
771
|
+
version = "0.48.5"
|
752
772
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
753
|
-
checksum = "
|
773
|
+
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
774
|
+
|
775
|
+
[[package]]
|
776
|
+
name = "windows_x86_64_gnu"
|
777
|
+
version = "0.48.5"
|
778
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
779
|
+
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
780
|
+
|
781
|
+
[[package]]
|
782
|
+
name = "windows_x86_64_gnullvm"
|
783
|
+
version = "0.48.5"
|
784
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
785
|
+
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
786
|
+
|
787
|
+
[[package]]
|
788
|
+
name = "windows_x86_64_msvc"
|
789
|
+
version = "0.48.5"
|
790
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
791
|
+
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
792
|
+
|
793
|
+
[[package]]
|
794
|
+
name = "zerocopy"
|
795
|
+
version = "0.7.32"
|
796
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
797
|
+
checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be"
|
798
|
+
dependencies = [
|
799
|
+
"zerocopy-derive",
|
800
|
+
]
|
801
|
+
|
802
|
+
[[package]]
|
803
|
+
name = "zerocopy-derive"
|
804
|
+
version = "0.7.32"
|
805
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
806
|
+
checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
|
807
|
+
dependencies = [
|
808
|
+
"proc-macro2",
|
809
|
+
"quote",
|
810
|
+
"syn 2.0.46",
|
811
|
+
]
|
data/Cargo.toml
CHANGED
data/README.md
CHANGED
@@ -76,7 +76,7 @@ attributes: {
|
|
76
76
|
|
77
77
|
# URL handling protocols to allow in specific attributes. By default, no
|
78
78
|
# protocols are allowed. Use :relative in place of a protocol if you want
|
79
|
-
# to allow relative URLs sans protocol.
|
79
|
+
# to allow relative URLs sans protocol. Set to `:all` to allow any protocol.
|
80
80
|
protocols: {
|
81
81
|
"a" => { "href" => ["http", "https", "mailto", :relative] },
|
82
82
|
"img" => { "href" => ["http", "https"] },
|
@@ -103,7 +103,11 @@ Here's an example which rewrites the `href` attribute on `a` and the `src` attri
|
|
103
103
|
|
104
104
|
```ruby
|
105
105
|
class MatchAttribute
|
106
|
-
SELECTOR = Selma::Selector(match_element: %(a[href^="http:"], img[src^="http:"]"))
|
106
|
+
SELECTOR = Selma::Selector.new(match_element: %(a[href^="http:"], img[src^="http:"]"))
|
107
|
+
|
108
|
+
def selector
|
109
|
+
SELECTOR
|
110
|
+
end
|
107
111
|
|
108
112
|
def handle_element(element)
|
109
113
|
if element.tag_name == "a"
|
@@ -178,38 +182,118 @@ The `element` argument in `handle_element` has the following methods:
|
|
178
182
|
|
179
183
|
## Benchmarks
|
180
184
|
|
185
|
+
When `bundle exec rake benchmark`, two different benchmarks are calculated. Here are those results on my machine.
|
186
|
+
|
187
|
+
### Benchmarks for just the sanitization process
|
188
|
+
|
189
|
+
Comparing Selma against popular Ruby sanitization gems:
|
190
|
+
|
191
|
+
<!-- prettier-ignore-start -->
|
181
192
|
<details>
|
182
193
|
<pre>
|
183
|
-
ruby test/benchmark.rb
|
184
|
-
ruby test/benchmark.rb
|
185
194
|
Warming up --------------------------------------
|
186
|
-
sanitize-
|
187
|
-
|
188
|
-
|
195
|
+
sanitize-sm 15.000 i/100ms
|
196
|
+
selma-sm 126.000 i/100ms
|
197
|
+
Calculating -------------------------------------
|
198
|
+
sanitize-sm 155.074 (± 1.9%) i/s - 4.665k in 30.092214s
|
199
|
+
selma-sm 1.290k (± 1.3%) i/s - 38.808k in 30.085333s
|
200
|
+
|
201
|
+
Comparison:
|
202
|
+
selma-sm: 1290.1 i/s
|
203
|
+
sanitize-sm: 155.1 i/s - 8.32x slower
|
204
|
+
|
205
|
+
input size = 86686 bytes, 0.09 MB
|
206
|
+
|
207
|
+
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
|
208
|
+
Warming up --------------------------------------
|
209
|
+
sanitize-md 3.000 i/100ms
|
210
|
+
selma-md 33.000 i/100ms
|
189
211
|
Calculating -------------------------------------
|
190
|
-
sanitize-
|
191
|
-
|
192
|
-
|
212
|
+
sanitize-md 40.321 (± 5.0%) i/s - 1.206k in 30.004711s
|
213
|
+
selma-md 337.417 (± 1.5%) i/s - 10.131k in 30.032772s
|
214
|
+
|
215
|
+
Comparison:
|
216
|
+
selma-md: 337.4 i/s
|
217
|
+
sanitize-md: 40.3 i/s - 8.37x slower
|
218
|
+
|
219
|
+
input size = 7172510 bytes, 7.17 MB
|
220
|
+
|
221
|
+
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
|
193
222
|
Warming up --------------------------------------
|
194
|
-
sanitize-
|
195
|
-
|
196
|
-
selma-document-medium
|
197
|
-
22.000 i/100ms
|
223
|
+
sanitize-lg 1.000 i/100ms
|
224
|
+
selma-lg 1.000 i/100ms
|
198
225
|
Calculating -------------------------------------
|
199
|
-
sanitize-
|
200
|
-
|
201
|
-
|
202
|
-
|
226
|
+
sanitize-lg 0.144 (± 0.0%) i/s - 5.000 in 34.772526s
|
227
|
+
selma-lg 4.026 (± 0.0%) i/s - 121.000 in 30.067415s
|
228
|
+
|
229
|
+
Comparison:
|
230
|
+
selma-lg: 4.0 i/s
|
231
|
+
sanitize-lg: 0.1 i/s - 27.99x slower
|
232
|
+
</pre>
|
233
|
+
</details>
|
234
|
+
<!-- prettier-ignore-end -->
|
235
|
+
|
236
|
+
### Benchmarks for just the rewriting process
|
237
|
+
|
238
|
+
Comparing Selma against popular Ruby HTML parsing gems:
|
239
|
+
|
240
|
+
<!-- prettier-ignore-start -->
|
241
|
+
<details>
|
242
|
+
<pre>
|
243
|
+
|
244
|
+
input size = 25309 bytes, 0.03 MB
|
245
|
+
|
246
|
+
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
|
247
|
+
Warming up --------------------------------------
|
248
|
+
nokogiri-sm 79.000 i/100ms
|
249
|
+
nokolexbor-sm 285.000 i/100ms
|
250
|
+
selma-sm 244.000 i/100ms
|
251
|
+
Calculating -------------------------------------
|
252
|
+
nokogiri-sm 807.790 (± 3.1%) i/s - 24.253k in 30.056301s
|
253
|
+
nokolexbor-sm 2.880k (± 6.4%) i/s - 86.070k in 30.044766s
|
254
|
+
selma-sm 2.508k (± 1.2%) i/s - 75.396k in 30.068792s
|
255
|
+
|
256
|
+
Comparison:
|
257
|
+
nokolexbor-sm: 2880.3 i/s
|
258
|
+
selma-sm: 2507.8 i/s - 1.15x slower
|
259
|
+
nokogiri-sm: 807.8 i/s - 3.57x slower
|
260
|
+
|
261
|
+
input size = 86686 bytes, 0.09 MB
|
262
|
+
|
263
|
+
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
|
264
|
+
Warming up --------------------------------------
|
265
|
+
nokogiri-md 8.000 i/100ms
|
266
|
+
nokolexbor-md 43.000 i/100ms
|
267
|
+
selma-md 39.000 i/100ms
|
268
|
+
Calculating -------------------------------------
|
269
|
+
nokogiri-md 87.367 (± 3.4%) i/s - 2.624k in 30.061642s
|
270
|
+
nokolexbor-md 438.782 (± 3.9%) i/s - 13.158k in 30.031163s
|
271
|
+
selma-md 392.591 (± 3.1%) i/s - 11.778k in 30.031391s
|
272
|
+
|
273
|
+
Comparison:
|
274
|
+
nokolexbor-md: 438.8 i/s
|
275
|
+
selma-md: 392.6 i/s - 1.12x slower
|
276
|
+
nokogiri-md: 87.4 i/s - 5.02x slower
|
277
|
+
|
278
|
+
input size = 7172510 bytes, 7.17 MB
|
279
|
+
|
280
|
+
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [arm64-darwin23]
|
203
281
|
Warming up --------------------------------------
|
204
|
-
|
205
|
-
|
206
|
-
selma-
|
282
|
+
nokogiri-lg 1.000 i/100ms
|
283
|
+
nokolexbor-lg 1.000 i/100ms
|
284
|
+
selma-lg 1.000 i/100ms
|
207
285
|
Calculating -------------------------------------
|
208
|
-
|
209
|
-
|
210
|
-
selma-
|
286
|
+
nokogiri-lg 0.895 (± 0.0%) i/s - 27.000 in 30.300832s
|
287
|
+
nokolexbor-lg 2.163 (± 0.0%) i/s - 65.000 in 30.085656s
|
288
|
+
selma-lg 5.867 (± 0.0%) i/s - 176.000 in 30.006240s
|
289
|
+
|
290
|
+
Comparison:
|
291
|
+
selma-lg: 5.9 i/s
|
292
|
+
nokolexbor-lg: 2.2 i/s - 2.71x slower
|
293
|
+
nokogiri-lg: 0.9 i/s - 6.55x slower
|
211
294
|
</pre>
|
212
295
|
</details>
|
296
|
+
<!-- prettier-ignore-end -->
|
213
297
|
|
214
298
|
## Contributing
|
215
299
|
|
data/ext/selma/Cargo.toml
CHANGED
data/ext/selma/src/rewriter.rs
CHANGED
@@ -42,9 +42,9 @@ pub struct SelmaRewriter(std::cell::RefCell<Rewriter>);
|
|
42
42
|
type RewriterValues = (Option<Option<Obj<SelmaSanitizer>>>, Option<RArray>);
|
43
43
|
|
44
44
|
impl SelmaRewriter {
|
45
|
-
const SELMA_ON_END_TAG: &str = "on_end_tag";
|
46
|
-
const SELMA_HANDLE_ELEMENT: &str = "handle_element";
|
47
|
-
const SELMA_HANDLE_TEXT_CHUNK: &str = "handle_text_chunk";
|
45
|
+
const SELMA_ON_END_TAG: &'static str = "on_end_tag";
|
46
|
+
const SELMA_HANDLE_ELEMENT: &'static str = "handle_element";
|
47
|
+
const SELMA_HANDLE_TEXT_CHUNK: &'static str = "handle_text_chunk";
|
48
48
|
|
49
49
|
/// @yard
|
50
50
|
/// @def new(sanitizer: Selma::Sanitizer.new(Selma::Sanitizer::Config::DEFAULT), handlers: [])
|
@@ -56,13 +56,14 @@ impl SelmaRewriter {
|
|
56
56
|
|
57
57
|
let sanitizer = match rb_sanitizer {
|
58
58
|
None => {
|
59
|
+
// no `sanitizer:` provided, use default
|
59
60
|
let default_sanitizer = SelmaSanitizer::new(&[])?;
|
60
61
|
let wrapped_sanitizer = Obj::wrap(default_sanitizer);
|
61
62
|
wrapped_sanitizer.funcall::<&str, (), Value>("setup", ())?;
|
62
63
|
Some(wrapped_sanitizer.get().to_owned())
|
63
64
|
}
|
64
65
|
Some(sanitizer_value) => match sanitizer_value {
|
65
|
-
None => None,
|
66
|
+
None => None, // no `sanitizer:` provided, use default
|
66
67
|
Some(sanitizer) => {
|
67
68
|
sanitizer.funcall::<&str, (), Value>("setup", ())?;
|
68
69
|
Some(sanitizer.get().to_owned())
|
data/ext/selma/src/sanitizer.rs
CHANGED
@@ -211,20 +211,23 @@ impl SelmaSanitizer {
|
|
211
211
|
}
|
212
212
|
Some(protocol_list) => protocol_list.push(allowed_protocol.to_string()),
|
213
213
|
}
|
214
|
-
} else if allowed_protocol.is_kind_of(class::symbol())
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
214
|
+
} else if allowed_protocol.is_kind_of(class::symbol()) {
|
215
|
+
let protocol_config = allowed_protocol.inspect();
|
216
|
+
if protocol_config == ":relative" {
|
217
|
+
match protocol_list {
|
218
|
+
None => {
|
219
|
+
protocol_sanitizers.insert(
|
220
|
+
attr_name.to_string(),
|
221
|
+
vec!["#".to_string(), "/".to_string()],
|
222
|
+
);
|
223
|
+
}
|
224
|
+
Some(protocol_list) => {
|
225
|
+
protocol_list.push("#".to_string());
|
226
|
+
protocol_list.push("/".to_string());
|
227
|
+
}
|
227
228
|
}
|
229
|
+
} else if protocol_config == ":all" {
|
230
|
+
protocol_sanitizers.insert(attr_name.to_string(), vec!["all".to_string()]);
|
228
231
|
}
|
229
232
|
}
|
230
233
|
}
|
@@ -388,6 +391,10 @@ impl SelmaSanitizer {
|
|
388
391
|
}
|
389
392
|
|
390
393
|
fn has_allowed_protocol(protocols_allowed: &[String], attr_val: &String) -> bool {
|
394
|
+
if protocols_allowed.contains(&"all".to_string()) {
|
395
|
+
return true;
|
396
|
+
}
|
397
|
+
|
391
398
|
// FIXME: is there a more idiomatic way to do this?
|
392
399
|
let mut pos: usize = 0;
|
393
400
|
let mut chars = attr_val.chars();
|
data/ext/selma/src/tags.rs
CHANGED
@@ -205,7 +205,7 @@ impl Tag {
|
|
205
205
|
|| tag.index == HTMLTag::XMP as usize
|
206
206
|
}
|
207
207
|
|
208
|
-
pub const ESCAPEWORTHY_TAGS_CSS: &str =
|
208
|
+
pub const ESCAPEWORTHY_TAGS_CSS: &'static str =
|
209
209
|
"title, textarea, style, xmp, iframe, noembed, noframes, script, plaintext";
|
210
210
|
|
211
211
|
pub fn html_tags() -> Vec<HTMLTag> {
|
@@ -28,7 +28,7 @@ module Selma
|
|
28
28
|
|
29
29
|
# URL handling protocols to allow in specific attributes. By default, no
|
30
30
|
# protocols are allowed. Use :relative in place of a protocol if you want
|
31
|
-
# to allow relative URLs sans protocol.
|
31
|
+
# to allow relative URLs sans protocol. Set to `:all` to allow any protocol.
|
32
32
|
protocols: {},
|
33
33
|
|
34
34
|
# An Array of element names whose contents will be removed. The contents
|
data/lib/selma/sanitizer.rb
CHANGED
@@ -66,7 +66,12 @@ module Selma
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def allow_protocol(element, attr, protos)
|
69
|
-
|
69
|
+
if protos.is_a?(Array)
|
70
|
+
raise ArgumentError, "`:all` must be passed outside of an array" if protos.include?(:all)
|
71
|
+
else
|
72
|
+
protos = [protos]
|
73
|
+
end
|
74
|
+
|
70
75
|
set_allowed_protocols(element, attr, protos)
|
71
76
|
end
|
72
77
|
|
data/lib/selma/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen J. Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rb_sys
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: 3.3.22
|
113
113
|
requirements: []
|
114
|
-
rubygems_version: 3.
|
114
|
+
rubygems_version: 3.5.3
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
117
|
summary: Selma selects and matches HTML nodes using CSS rules. Backed by Rust's lol_html
|