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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed5dccbff7a289d57157e0ce627e31ed233ba316d6989ab14bfc6a9f28d241ec
4
- data.tar.gz: de7de41bb7cd201f866515e3ef730491d435c90610e771dac5f928e1ca2e8688
3
+ metadata.gz: 9f9a2f98b54d8a383ef57ac7c8ef109b3849d07cb35bfa93a431e93c1a216e6d
4
+ data.tar.gz: 774d712999e64ff76f145689a08bbcd6b127fed100671bef264c9522bde9f2e5
5
5
  SHA512:
6
- metadata.gz: 488c6240447f302b3479a20b76e17552648399dc82a465ddd0bf3d59cb058ec095a5ceae57a4f5cfef1a3865f6e765d2fdc4a94d79796f5d654d115982c53755
7
- data.tar.gz: 371014f6ed8074097f1d7fd0c0c9600bbe7a5284248c7e7fdca6db9e4a5e26c4e565e3f20fa2c61612ad3a2ef199a8e8d87dc2103dbb987aa393e53f1f95e00d
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.0"
259
+ version = "3.0.1"
260
260
  source = "registry+https://github.com/rust-lang/crates.io-index"
261
- checksum = "2ae574a677ef0443a0bd3c291f0cab9d1e61a3ad85a1515e3cfc0bc720d5a48e"
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.128"
412
+ version = "0.9.130"
413
413
  source = "registry+https://github.com/rust-lang/crates.io-index"
414
- checksum = "45ca28513560e56cfb79a62b1fce363c73af170a182024ce880c77ee9429920a"
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.128"
421
+ version = "0.9.130"
422
422
  source = "registry+https://github.com/rust-lang/crates.io-index"
423
- checksum = "ce04b2c55eff3a21aaa623fcc655d94373238e72cac6b3e1a3641ff31649f99a"
423
+ checksum = "05be6f9c86fe5482808162826f6c047d093b3670582296c770de1d94f8066694"
424
424
  dependencies = [
425
425
  "bindgen",
426
426
  "lazy_static",
@@ -551,33 +551,18 @@ impl SelmaSanitizer {
551
551
  return true;
552
552
  }
553
553
 
554
- // FIXME: is there a more idiomatic way to do this?
555
- let mut pos: usize = 0;
556
- let mut chars = attr_val.chars();
557
- let len = attr_val.len();
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
- if char == '#' {
574
- return protocols_allowed.contains(&"#".to_string());
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
@@ -7,6 +7,6 @@ module Selma
7
7
  max_allowed_memory_usage: nil,
8
8
  preallocated_parsing_buffer_size: nil,
9
9
  },
10
- }
10
+ }.freeze
11
11
  end
12
12
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Selma
4
- VERSION = "0.5.1"
4
+ VERSION = "0.5.2"
5
5
  end
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.1
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: []