selma 0.4.1 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e5b5e70ce5e954bbd53e8df94b58facb21a78174562f001ce328f9d3ba4b09a3
4
- data.tar.gz: 4360c58ce183593b8b5ec8c2bc2a15090aa5ed86f3e8a69b5975111274e01749
3
+ metadata.gz: a29ac9fb9f7bbc7ee99e9e4623eaabc643ba45b7704abb2e56447678d330cdeb
4
+ data.tar.gz: 5951e00f9578423a30bcd776c6ed0eec757198982b07e47a970114d233cdec79
5
5
  SHA512:
6
- metadata.gz: 9528b3320b2bbe90bf17ee1cffe17e6ab65f58ebae1c8edda77f61d2c4b8e8c08782b4bf11cbbaae50610c44aa0dc69c58ca70c4c943a96af84285db167929bd
7
- data.tar.gz: 8cf5ebd4259fa09b07b7908a2de795746a45cf7fc25eb3243affe373e0c90a04760cd2d8798367ffc3abe343e5b499a9253b2f01ac195843a067c8cbc88701a5
6
+ metadata.gz: cd24427d87ea37ce92ced5ce7cc5e0ce8600422176da18180d3043db6da455de93542da935a475b4c32cde28511bbc4de4b3648aa671f8ca085d645bfbdcb11a
7
+ data.tar.gz: 76875117c04b1fa5a5dba4fd53526caa4980a3249130b1783073d59cc2d9efc698b0437650241e66bc6d8b4cf01062f2b97692ec8a0b35b2e631c8faa41ed813
@@ -304,7 +304,7 @@ impl SelmaRewriter {
304
304
  }
305
305
  };
306
306
 
307
- let handlers = &binding.handlers;
307
+ let handlers: &Vec<Handler> = &binding.handlers;
308
308
 
309
309
  match Self::perform_handler_rewrite(
310
310
  self,
@@ -372,6 +372,9 @@ impl SelmaRewriter {
372
372
  // TODO: this should ideally be done ahead of time on `initialize`, not on every `#rewrite` call
373
373
  let mut element_content_handlers: Vec<(Cow<Selector>, ElementContentHandlers)> = vec![];
374
374
 
375
+ // have sanitization happen first
376
+ element_content_handlers.extend(sanitizer_element_content_handlers);
377
+
375
378
  handlers.iter().for_each(|handler| {
376
379
  let element_stack: Rc<RefCell<Vec<String>>> = Rc::new(RefCell::new(vec![]));
377
380
 
@@ -439,37 +442,23 @@ impl SelmaRewriter {
439
442
 
440
443
  let closure_element_stack = element_stack.clone();
441
444
 
442
- el.end_tag_handlers()
443
- .unwrap()
444
- .push(Box::new(move |_end_tag| {
445
- let mut stack = closure_element_stack.as_ref().borrow_mut();
446
- stack.pop();
445
+ if let Some(end_tag_handlers) = el.end_tag_handlers() {
446
+ end_tag_handlers.push(Box::new(move |_end_tag| {
447
+ closure_element_stack.as_ref().borrow_mut().pop();
447
448
  Ok(())
448
449
  }));
450
+ }
449
451
 
450
452
  Ok(())
451
453
  }));
452
454
  });
453
455
 
454
- let rewritten_html = Self::run_rewrite(
456
+ Self::run_rewrite(
455
457
  self,
456
458
  sanitizer_document_content_handlers,
457
459
  element_content_handlers,
458
460
  html.as_bytes(),
459
- );
460
-
461
- // sanitization must happen separately, because text chunks
462
- // could potentially have rewritten the html. ideally we'd
463
- // be able to sanitize around the `process_text_handlers` call
464
- match rewritten_html {
465
- Ok(rewritten_html) => Self::run_rewrite(
466
- self,
467
- vec![],
468
- sanitizer_element_content_handlers,
469
- rewritten_html.as_slice(),
470
- ),
471
- Err(err) => Err(err),
472
- }
461
+ )
473
462
  }
474
463
 
475
464
  fn run_rewrite(
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.4.1"
4
+ VERSION = "0.4.3"
5
5
  end
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.1
4
+ version: 0.4.3
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: 2024-07-15 00:00:00.000000000 Z
11
+ date: 2024-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb_sys