File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -623,7 +623,13 @@ protected function parse(): void
623623 $ this ->root ->setHtmlSpecialCharsDecode ($ this ->options ->htmlSpecialCharsDecode );
624624 $ activeNode = $ this ->root ;
625625 while ( ! is_null ($ activeNode )) {
626- $ str = $ this ->content ->copyUntil ('< ' );
626+ if ($ activeNode && $ activeNode ->tag ->name () === 'script '
627+ && $ this ->options ->get ('cleanupInput ' ) != true
628+ ) {
629+ $ str = $ this ->content ->copyUntil ('</ ' );
630+ } else {
631+ $ str = $ this ->content ->copyUntil ('< ' );
632+ }
627633 if ($ str == '' ) {
628634 $ info = $ this ->parseTag ();
629635 if ( ! $ info ['status ' ]) {
Original file line number Diff line number Diff line change @@ -12,6 +12,18 @@ public function tearDown()
1212 Mockery::close ();
1313 }
1414
15+ /**
16+ * <![CDATA[ should not be modified when cleanupInput is set to false
17+ */
18+ public function testParsingCData ()
19+ {
20+ $ html = "<script type= \"text/javascript \">/* <![CDATA[ */var et_core_api_spam_recaptcha = '';/* ]]> */</script> " ;
21+ $ dom = new Dom ();
22+ $ dom ->setOptions (['cleanupInput ' => false ,]);
23+ $ dom ->load ($ html );
24+ $ this ->assertSame ($ html , $ dom ->root ->outerHtml ());
25+ }
26+
1527 public function testLoad ()
1628 {
1729 $ dom = new Dom ;
You can’t perform that action at this time.
0 commit comments