selma 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +6 -6
- data/ext/selma/src/sanitizer.rs +10 -25
- data/lib/selma/config.rb +1 -1
- data/lib/selma/sanitizer/config/default.rb +1 -1
- data/lib/selma/version.rb +1 -1
- metadata +1 -29
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f9a2f98b54d8a383ef57ac7c8ef109b3849d07cb35bfa93a431e93c1a216e6d
|
|
4
|
+
data.tar.gz: 774d712999e64ff76f145689a08bbcd6b127fed100671bef264c9522bde9f2e5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 87907675ef6bd1b0bc54196f451edc99c4527f25cb14a0d3cc223dbe5f4671e68f5787487348b1c7a80e152bd515bc0cc8e43df57f997a36541115753c66c267
|
|
7
|
+
data.tar.gz: f4bc7741b7a05506b8259e4c9e961d4230c340a32c98be96ba09ad67303e86d4925e0132001940aabcde55dc536348d41a85d1c0d0e290b2cfb68a0e9f82c4de
|
data/Cargo.lock
CHANGED
|
@@ -256,9 +256,9 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897"
|
|
|
256
256
|
|
|
257
257
|
[[package]]
|
|
258
258
|
name = "lol_html"
|
|
259
|
-
version = "3.0.
|
|
259
|
+
version = "3.0.1"
|
|
260
260
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
261
|
-
checksum = "
|
|
261
|
+
checksum = "5adbb62638edf7e6bc88835cd3ea388bdd53382af42045da0e414ea78aa0c91a"
|
|
262
262
|
dependencies = [
|
|
263
263
|
"bitflags",
|
|
264
264
|
"cfg-if",
|
|
@@ -409,18 +409,18 @@ dependencies = [
|
|
|
409
409
|
|
|
410
410
|
[[package]]
|
|
411
411
|
name = "rb-sys"
|
|
412
|
-
version = "0.9.
|
|
412
|
+
version = "0.9.130"
|
|
413
413
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
414
|
-
checksum = "
|
|
414
|
+
checksum = "02faf625bb10ba893e3ae620f19c9fb1b5f8fcae0fe4eb86bb3f2230fad75edb"
|
|
415
415
|
dependencies = [
|
|
416
416
|
"rb-sys-build",
|
|
417
417
|
]
|
|
418
418
|
|
|
419
419
|
[[package]]
|
|
420
420
|
name = "rb-sys-build"
|
|
421
|
-
version = "0.9.
|
|
421
|
+
version = "0.9.130"
|
|
422
422
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
423
|
-
checksum = "
|
|
423
|
+
checksum = "05be6f9c86fe5482808162826f6c047d093b3670582296c770de1d94f8066694"
|
|
424
424
|
dependencies = [
|
|
425
425
|
"bindgen",
|
|
426
426
|
"lazy_static",
|
data/ext/selma/src/sanitizer.rs
CHANGED
|
@@ -551,33 +551,18 @@ impl SelmaSanitizer {
|
|
|
551
551
|
return true;
|
|
552
552
|
}
|
|
553
553
|
|
|
554
|
-
//
|
|
555
|
-
|
|
556
|
-
let
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
for (i, c) in attr_val.chars().enumerate() {
|
|
560
|
-
if c != ':' && c != '/' && c != '#' && pos + 1 < len {
|
|
561
|
-
pos = i + 1;
|
|
562
|
-
} else {
|
|
563
|
-
break;
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
let char = chars.nth(pos).unwrap();
|
|
568
|
-
|
|
569
|
-
if char == '/' {
|
|
570
|
-
return protocols_allowed.contains(&"/".to_string());
|
|
571
|
-
}
|
|
554
|
+
// The protocol is everything before the first `:`; a `/` or `#` before
|
|
555
|
+
// that means there is no protocol and the URL is relative.
|
|
556
|
+
let Some(idx) = attr_val.find([':', '/', '#']) else {
|
|
557
|
+
return false;
|
|
558
|
+
};
|
|
572
559
|
|
|
573
|
-
|
|
574
|
-
|
|
560
|
+
match attr_val.as_bytes()[idx] {
|
|
561
|
+
b'/' => protocols_allowed.contains(&"/".to_string()),
|
|
562
|
+
b'#' => protocols_allowed.contains(&"#".to_string()),
|
|
563
|
+
// Allow protocol name to be case-insensitive
|
|
564
|
+
_ => protocols_allowed.contains(&attr_val[..idx].to_lowercase()),
|
|
575
565
|
}
|
|
576
|
-
|
|
577
|
-
// Allow protocol name to be case-insensitive
|
|
578
|
-
let protocol = attr_val[0..pos].to_lowercase();
|
|
579
|
-
|
|
580
|
-
protocols_allowed.contains(&protocol.to_lowercase())
|
|
581
566
|
}
|
|
582
567
|
|
|
583
568
|
fn sanitize_class_attribute(
|
data/lib/selma/config.rb
CHANGED
|
@@ -5,7 +5,7 @@ module Selma
|
|
|
5
5
|
module Config
|
|
6
6
|
# although there are many more protocol types, eg., ftp, xmpp, etc.,
|
|
7
7
|
# these are the only ones that are allowed by default
|
|
8
|
-
VALID_PROTOCOLS = ["http", "https", "mailto", :relative]
|
|
8
|
+
VALID_PROTOCOLS = ["http", "https", "mailto", :relative].freeze
|
|
9
9
|
|
|
10
10
|
DEFAULT = freeze_config(
|
|
11
11
|
# Whether or not to allow HTML comments. Allowing comments is strongly
|
data/lib/selma/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: selma
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Garen J. Torikian
|
|
@@ -23,34 +23,6 @@ dependencies:
|
|
|
23
23
|
- - "~>"
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0.9'
|
|
26
|
-
- !ruby/object:Gem::Dependency
|
|
27
|
-
name: rake
|
|
28
|
-
requirement: !ruby/object:Gem::Requirement
|
|
29
|
-
requirements:
|
|
30
|
-
- - "~>"
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: '13.0'
|
|
33
|
-
type: :development
|
|
34
|
-
prerelease: false
|
|
35
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
-
requirements:
|
|
37
|
-
- - "~>"
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: '13.0'
|
|
40
|
-
- !ruby/object:Gem::Dependency
|
|
41
|
-
name: rake-compiler
|
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - "~>"
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '1.2'
|
|
47
|
-
type: :development
|
|
48
|
-
prerelease: false
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - "~>"
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '1.2'
|
|
54
26
|
email:
|
|
55
27
|
- gjtorikian@gmail.com
|
|
56
28
|
executables: []
|