<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From: Craig Duncan &lt;git@duncanc.co.uk&gt;
Date: Tue, 28 Mar 2017 22:39:01 +0100
Subject: [PATCH] Don't protect newlines before opening braces

--- a/src/JShrink/Minifier.php
+++ b/src/JShrink/Minifier.php
@@ -181,7 +181,7 @@ class Minifier
                 // new lines
                 case "\n":
                     // if the next line is something that can't stand alone preserve the newline
-                    if ($this-&gt;b !== false &amp;&amp; strpos('(-+{[@', $this-&gt;b) !== false) {
+                    if ($this-&gt;b !== false &amp;&amp; strpos('(-+[@', $this-&gt;b) !== false) {
                         echo $this-&gt;a;
                         $this-&gt;saveString();
                         break;


From: Craig Duncan &lt;git@duncanc.co.uk&gt;
Date: Tue, 28 Mar 2017 22:24:40 +0100
Subject: [PATCH] Ensure that comments following other comments are handled

--- a/src/JShrink/Minifier.php
+++ b/src/JShrink/Minifier.php
@@ -312,10 +312,14 @@ class Minifier
         $this-&gt;c = $this-&gt;getChar();
 
         if ($this-&gt;c === '/') {
-            return $this-&gt;processOneLineComments($startIndex);
+            $this-&gt;processOneLineComments($startIndex);
+
+            return $this-&gt;getReal();
 
         } elseif ($this-&gt;c === '*') {
-            return $this-&gt;processMultiLineComments($startIndex);
+            $this-&gt;processMultiLineComments($startIndex);
+
+            return $this-&gt;getReal();
         }
 
         return $char;
@@ -325,8 +329,8 @@ class Minifier
      * Removed one line comments, with the exception of some very specific types of
      * conditional comments.
      *
-     * @param  int    $startIndex The index point where "getReal" function started
-     * @return string
+     * @param  int  $startIndex The index point where "getReal" function started
+     * @return void
      */
     protected function processOneLineComments($startIndex)
     {
@@ -335,17 +339,12 @@ class Minifier
         // kill rest of line
         $this-&gt;getNext("\n");
 
+        unset($this-&gt;c);
+
         if ($thirdCommentString == '@') {
             $endPoint = $this-&gt;index - $startIndex;
-            unset($this-&gt;c);
-            $char = "\n" . substr($this-&gt;input, $startIndex, $endPoint);
-        } else {
-            // first one is contents of $this-&gt;c
-            $this-&gt;getChar();
-            $char = $this-&gt;getChar();
+            $this-&gt;c = "\n" . substr($this-&gt;input, $startIndex, $endPoint);
         }
-
-        return $char;
     }
 
     /**
@@ -353,7 +352,7 @@ class Minifier
      * Conditional comments and "license" style blocks are preserved.
      *
      * @param  int               $startIndex The index point where "getReal" function started
-     * @return bool|string       False if there's no character
+     * @return void
      * @throws \RuntimeException Unclosed comments will throw an error
      */
     protected function processMultiLineComments($startIndex)
@@ -387,7 +386,9 @@ class Minifier
                 $endPoint = ($this-&gt;index - 1) - $startIndex;
                 echo substr($this-&gt;input, $startIndex, $endPoint);
 
-                return $char;
+                $this-&gt;c = $char;
+
+                return;
             }
 
         } else {
@@ -398,10 +399,7 @@ class Minifier
             throw new \RuntimeException('Unclosed multiline comment at position: ' . ($this-&gt;index - 2));
 
         // if we're here c is part of the comment and therefore tossed
-        if(isset($this-&gt;c))
-            unset($this-&gt;c);
-
-        return $char;
+        $this-&gt;c = $char;
     }
 
     /**


From: Robert Hafner &lt;tedivm@tedivm.com&gt;
Date: Thu, 7 Dec 2017 16:03:40 -0800
Subject: [PATCH] Add support for template literals

--- a/src/JShrink/Minifier.php
+++ b/src/JShrink/Minifier.php
@@ -74,6 +74,11 @@ class Minifier
      */
     protected $options;
 
+    /**
+     * These characters are used to define strings.
+     */
+    protected $stringDelimiters = ['\'', '"', '`'];
+
     /**
      * Contains the default options for minification. This array is merged with
      * the one passed in by the user to create the request specific set of
@@ -442,7 +447,7 @@ class Minifier
         $this-&gt;a = $this-&gt;b;
 
         // If this isn't a string we don't need to do anything.
-        if ($this-&gt;a !== "'" &amp;&amp; $this-&gt;a !== '"') {
+        if (!in_array($this-&gt;a, $this-&gt;stringDelimiters)) {
             return;
         }
 
@@ -471,7 +476,11 @@ class Minifier
                 // character, so those will be treated just fine using the switch
                 // block below.
                 case "\n":
-                    throw new \RuntimeException('Unclosed string at position: ' . $startpos );
+                    if ($stringType === '`') {
+                        echo $this-&gt;a;
+                    } else {
+                        throw new \RuntimeException('Unclosed string at position: ' . $startpos );
+                    }
                     break;
 
                 // Escaped characters get picked up here. If it's an escaped new line it's not really needed


From: Robert Hafner &lt;tedivm@tedivm.com&gt;
Date: Thu, 7 Dec 2017 16:48:36 -0800
Subject: [PATCH] upgrade dependencies, php requirements, formatting

--- a/src/JShrink/Minifier.php
+++ b/src/JShrink/Minifier.php
@@ -120,9 +120,7 @@ class Minifier
             unset($jshrink);
 
             return $js;
-
         } catch (\Exception $e) {
-
             if (isset($jshrink)) {
                 // Since the breakdownScript function probably wasn't finished
                 // we clean it out before discarding it.
@@ -181,7 +179,6 @@ class Minifier
     protected function loop()
     {
         while ($this-&gt;a !== false &amp;&amp; !is_null($this-&gt;a) &amp;&amp; $this-&gt;a !== '') {
-
             switch ($this-&gt;a) {
                 // new lines
                 case "\n":
@@ -194,14 +191,17 @@ class Minifier
 
                     // if B is a space we skip the rest of the switch block and go down to the
                     // string/regex check below, resetting $this-&gt;b with getReal
-                    if($this-&gt;b === ' ')
+                    if ($this-&gt;b === ' ') {
                         break;
+                    }
 
                 // otherwise we treat the newline like a space
 
+                // no break
                 case ' ':
-                    if(static::isAlphaNumeric($this-&gt;b))
+                    if (static::isAlphaNumeric($this-&gt;b)) {
                         echo $this-&gt;a;
+                    }
 
                     $this-&gt;saveString();
                     break;
@@ -222,9 +222,11 @@ class Minifier
                             break;
 
                         case ' ':
-                            if(!static::isAlphaNumeric($this-&gt;a))
+                            if (!static::isAlphaNumeric($this-&gt;a)) {
                                 break;
+                            }
 
+                                // no break
                         default:
                             // check for some regex that breaks stuff
                             if ($this-&gt;a === '/' &amp;&amp; ($this-&gt;b === '\'' || $this-&gt;b === '"')) {
@@ -241,8 +243,9 @@ class Minifier
             // do reg check of doom
             $this-&gt;b = $this-&gt;getReal();
 
-            if(($this-&gt;b == '/' &amp;&amp; strpos('(,=:[!&amp;|?', $this-&gt;a) !== false))
+            if (($this-&gt;b == '/' &amp;&amp; strpos('(,=:[!&amp;|?', $this-&gt;a) !== false)) {
                 $this-&gt;saveRegex();
+            }
         }
     }
 
@@ -272,7 +275,7 @@ class Minifier
             $char = $this-&gt;c;
             unset($this-&gt;c);
 
-        // Otherwise we start pulling from the input.
+            // Otherwise we start pulling from the input.
         } else {
             $char = substr($this-&gt;input, $this-&gt;index, 1);
 
@@ -287,9 +290,9 @@ class Minifier
 
         // Normalize all whitespace except for the newline character into a
         // standard space.
-        if($char !== "\n" &amp;&amp; ord($char) &lt; 32)
-
+        if ($char !== "\n" &amp;&amp; ord($char) &lt; 32) {
             return ' ';
+        }
 
         return $char;
     }
@@ -320,7 +323,6 @@ class Minifier
             $this-&gt;processOneLineComments($startIndex);
 
             return $this-&gt;getReal();
-
         } elseif ($this-&gt;c === '*') {
             $this-&gt;processMultiLineComments($startIndex);
 
@@ -367,14 +369,13 @@ class Minifier
 
         // kill everything up to the next */ if it's there
         if ($this-&gt;getNext('*/')) {
-
             $this-&gt;getChar(); // get *
             $this-&gt;getChar(); // get /
             $char = $this-&gt;getChar(); // get next real character
 
             // Now we reinsert conditional comments and YUI-style licensing comments
             if (($this-&gt;options['flaggedComments'] &amp;&amp; $thirdCommentString === '!')
-                || ($thirdCommentString === '@') ) {
+                || ($thirdCommentString === '@')) {
 
                 // If conditional comments or flagged comments are not the first thing in the script
                 // we need to echo a and fill it with a space before moving on.
@@ -395,13 +396,13 @@ class Minifier
 
                 return;
             }
-
         } else {
             $char = false;
         }
 
-        if($char === false)
+        if ($char === false) {
             throw new \RuntimeException('Unclosed multiline comment at position: ' . ($this-&gt;index - 2));
+        }
 
         // if we're here c is part of the comment and therefore tossed
         $this-&gt;c = $char;
@@ -421,9 +422,9 @@ class Minifier
         $pos = strpos($this-&gt;input, $string, $this-&gt;index);
 
         // If it's not there return false.
-        if($pos === false)
-
+        if ($pos === false) {
             return false;
+        }
 
         // Adjust position of index to jump ahead to the asked for string
         $this-&gt;index = $pos;
@@ -479,7 +480,7 @@ class Minifier
                     if ($stringType === '`') {
                         echo $this-&gt;a;
                     } else {
-                        throw new \RuntimeException('Unclosed string at position: ' . $startpos );
+                        throw new \RuntimeException('Unclosed string at position: ' . $startpos);
                     }
                     break;
 
@@ -520,16 +521,18 @@ class Minifier
         echo $this-&gt;a . $this-&gt;b;
 
         while (($this-&gt;a = $this-&gt;getChar()) !== false) {
-            if($this-&gt;a === '/')
+            if ($this-&gt;a === '/') {
                 break;
+            }
 
             if ($this-&gt;a === '\\') {
                 echo $this-&gt;a;
                 $this-&gt;a = $this-&gt;getChar();
             }
 
-            if($this-&gt;a === "\n")
+            if ($this-&gt;a === "\n") {
                 throw new \RuntimeException('Unclosed regex pattern at position: ' . $this-&gt;index);
+            }
 
             echo $this-&gt;a;
         }
@@ -590,5 +593,4 @@ class Minifier
 
         return $js;
     }
-
 }


From: Alex &lt;aprogs@2281272.no-reply.drupal.org&gt;
Date: Sat, 30 Jun 2018 12:50:18 +0300
Subject: [PATCH] Fixed infinite loop when reading invalid JavaScript.

--- a/src/JShrink/Minifier.php
+++ b/src/JShrink/Minifier.php
@@ -459,11 +459,8 @@ class Minifier
         echo $this-&gt;a;
 
         // Loop until the string is done
-        while (true) {
-
-            // Grab the very next character and load it into a
-            $this-&gt;a = $this-&gt;getChar();
-
+        // Grab the very next character and load it into a
+        while ($this-&gt;a = $this-&gt;getChar()) {
             switch ($this-&gt;a) {
 
                 // If the string opener (single or double quote) is used


From: Alex &lt;aprogs@2281272.no-reply.drupal.org&gt;
Date: Sat, 30 Jun 2018 12:59:50 +0300
Subject: [PATCH] Updated loop condition to strictly validate function result.

--- a/src/JShrink/Minifier.php
+++ b/src/JShrink/Minifier.php
@@ -460,7 +460,7 @@ class Minifier
 
         // Loop until the string is done
         // Grab the very next character and load it into a
-        while ($this-&gt;a = $this-&gt;getChar()) {
+        while (($this-&gt;a = $this-&gt;getChar()) !== FALSE) {
             switch ($this-&gt;a) {
 
                 // If the string opener (single or double quote) is used


From: Alex &lt;aprogs@2281272.no-reply.drupal.org&gt;
Date: Mon, 2 Jul 2018 17:38:39 +0300
Subject: [PATCH] Fixed code formatting notices.

--- a/src/JShrink/Minifier.php
+++ b/src/JShrink/Minifier.php
@@ -274,9 +274,8 @@ class Minifier
         if (isset($this-&gt;c)) {
             $char = $this-&gt;c;
             unset($this-&gt;c);
-
-            // Otherwise we start pulling from the input.
         } else {
+            // Otherwise we start pulling from the input.
             $char = substr($this-&gt;input, $this-&gt;index, 1);
 
             // If the next character doesn't exist return false.
@@ -460,7 +459,7 @@ class Minifier
 
         // Loop until the string is done
         // Grab the very next character and load it into a
-        while (($this-&gt;a = $this-&gt;getChar()) !== FALSE) {
+        while (($this-&gt;a = $this-&gt;getChar()) !== false) {
             switch ($this-&gt;a) {
 
                 // If the string opener (single or double quote) is used


From: Antti Hukkanen &lt;antti.hukkanen@mainiotech.fi&gt;
Date: Fri, 7 Jun 2019 00:24:25 +0300
Subject: [PATCH] Detect regular expression after arithmetic operation

--- a/src/JShrink/Minifier.php
+++ b/src/JShrink/Minifier.php
@@ -243,7 +243,7 @@ class Minifier
             // do reg check of doom
             $this-&gt;b = $this-&gt;getReal();
 
-            if (($this-&gt;b == '/' &amp;&amp; strpos('(,=:[!&amp;|?', $this-&gt;a) !== false)) {
+            if (($this-&gt;b == '/' &amp;&amp; strpos('(,=:[!&amp;|?*+-%&amp;/', $this-&gt;a) !== false)) {
                 $this-&gt;saveRegex();
             }
         }


From: Antti Hukkanen &lt;antti.hukkanen@mainiotech.fi&gt;
Date: Fri, 7 Jun 2019 00:37:27 +0300
Subject: [PATCH] Remove reduntant slash from the regular expression character match

--- a/src/JShrink/Minifier.php
+++ b/src/JShrink/Minifier.php
@@ -243,7 +243,7 @@ class Minifier
             // do reg check of doom
             $this-&gt;b = $this-&gt;getReal();
 
-            if (($this-&gt;b == '/' &amp;&amp; strpos('(,=:[!&amp;|?*+-%&amp;/', $this-&gt;a) !== false)) {
+            if (($this-&gt;b == '/' &amp;&amp; strpos('(,=:[!&amp;|?*+-%&amp;', $this-&gt;a) !== false)) {
                 $this-&gt;saveRegex();
             }
         }


From: Antti Hukkanen &lt;antti.hukkanen@mainiotech.fi&gt;
Date: Fri, 7 Jun 2019 00:39:02 +0300
Subject: [PATCH] Remove duplicate ampresand from the regular expression char match

--- a/src/JShrink/Minifier.php
+++ b/src/JShrink/Minifier.php
@@ -243,7 +243,7 @@ class Minifier
             // do reg check of doom
             $this-&gt;b = $this-&gt;getReal();
 
-            if (($this-&gt;b == '/' &amp;&amp; strpos('(,=:[!&amp;|?*+-%&amp;', $this-&gt;a) !== false)) {
+            if (($this-&gt;b == '/' &amp;&amp; strpos('(,=:[!&amp;|?*+-%', $this-&gt;a) !== false)) {
                 $this-&gt;saveRegex();
             }
         }

</pre></body></html>