[pkg-nagios-changes] [Git][nagios-team/pkg-icingaweb2][master] 2 commits: Add patch to update JShrink for PHP 8.

Bas Couwenberg gitlab at salsa.debian.org
Fri Dec 18 06:57:10 GMT 2020



Bas Couwenberg pushed to branch master at Debian Nagios Maintainer Group / pkg-icingaweb2


Commits:
54a3c018 by Bas Couwenberg at 2020-12-18T07:43:19+01:00
Add patch to update JShrink for PHP 8.

- - - - -
5568de2d by Bas Couwenberg at 2020-12-18T07:43:55+01:00
Set distribution to experimental.

- - - - -


3 changed files:

- debian/changelog
- + debian/patches/jshrink-php8.patch
- debian/patches/series


Changes:

=====================================
debian/changelog
=====================================
@@ -1,3 +1,10 @@
+icingaweb2 (2.8.2-2~exp2) experimental; urgency=medium
+
+  * Team upload.
+  * Add patch to update JShrink for PHP 8.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Fri, 18 Dec 2020 07:43:44 +0100
+
 icingaweb2 (2.8.2-2~exp1) experimental; urgency=medium
 
   * Team upload.


=====================================
debian/patches/jshrink-php8.patch
=====================================
@@ -0,0 +1,185 @@
+Description: Update JShink for PHP 8.
+Origin: https://raw.githubusercontent.com/tedious/JShrink/ab780a6114b466940f66d0f1ef735564f2990b18/src/JShrink/Minifier.php
+Bug: https://github.com/tedious/JShrink/issues/96
+Bug-Debian: https://bugs.debian.org/977337
+
+--- a/library/vendor/JShrink/Minifier.php
++++ b/library/vendor/JShrink/Minifier.php
+@@ -39,6 +39,13 @@ class Minifier
+     protected $input;
+ 
+     /**
++     * Length of input javascript.
++     *
++     * @var int
++     */
++    protected $len = 0;
++
++    /**
+      * The location of the character (in the input string) that is next to be
+      * processed.
+      *
+@@ -77,7 +84,7 @@ class Minifier
+     /**
+      * These characters are used to define strings.
+      */
+-    protected $stringDelimiters = ['\'', '"', '`'];
++    protected $stringDelimiters = ['\'' => true, '"' => true, '`' => true];
+ 
+     /**
+      * Contains the default options for minification. This array is merged with
+@@ -86,7 +93,7 @@ class Minifier
+      *
+      * @var array
+      */
+-    protected static $defaultOptions = array('flaggedComments' => true);
++    protected static $defaultOptions = ['flaggedComments' => true];
+ 
+     /**
+      * Contains lock ids which are used to replace certain code patterns and
+@@ -94,7 +101,7 @@ class Minifier
+      *
+      * @var array
+      */
+-    protected $locks = array();
++    protected $locks = [];
+ 
+     /**
+      * Takes a string containing javascript and removes unneeded characters in
+@@ -105,7 +112,7 @@ class Minifier
+      * @throws \Exception
+      * @return bool|string
+      */
+-    public static function minify($js, $options = array())
++    public static function minify($js, $options = [])
+     {
+         try {
+             ob_start();
+@@ -157,15 +164,16 @@ class Minifier
+     protected function initialize($js, $options)
+     {
+         $this->options = array_merge(static::$defaultOptions, $options);
+-        $js = str_replace("\r\n", "\n", $js);
+-        $js = str_replace('/**/', '', $js);
+-        $this->input = str_replace("\r", "\n", $js);
++        $this->input = str_replace(["\r\n", '/**/', "\r"], ["\n", "", "\n"], $js);
+ 
+         // We add a newline to the end of the script to make it easier to deal
+         // with comments at the bottom of the script- this prevents the unclosed
+         // comment error that can otherwise occur.
+         $this->input .= PHP_EOL;
+ 
++        // save input length to skip calculation every time
++        $this->len = strlen($this->input);
++
+         // Populate "a" with a new line, "b" with the first character, before
+         // entering the loop
+         $this->a = "\n";
+@@ -173,6 +181,18 @@ class Minifier
+     }
+ 
+     /**
++     * Characters that can't stand alone preserve the newline.
++     *
++     * @var array
++     */
++    protected $noNewLineCharacters = [
++        '(' => true,
++        '-' => true,
++        '+' => true,
++        '[' => true,
++        '@' => true];
++
++    /**
+      * The primary action occurs here. This function loops through the input string,
+      * outputting anything that's relevant and discarding anything that is not.
+      */
+@@ -183,7 +203,7 @@ class Minifier
+                 // new lines
+                 case "\n":
+                     // if the next line is something that can't stand alone preserve the newline
+-                    if ($this->b !== false && strpos('(-+[@', $this->b) !== false) {
++                    if ($this->b !== false && isset($this->noNewLineCharacters[$this->b])) {
+                         echo $this->a;
+                         $this->saveString();
+                         break;
+@@ -226,7 +246,7 @@ class Minifier
+                                 break;
+                             }
+ 
+-                                // no break
++                        // no break
+                         default:
+                             // check for some regex that breaks stuff
+                             if ($this->a === '/' && ($this->b === '\'' || $this->b === '"')) {
+@@ -243,7 +263,7 @@ class Minifier
+             // do reg check of doom
+             $this->b = $this->getReal();
+ 
+-            if (($this->b == '/' && strpos('(,=:[!&|?*+-%', $this->a) !== false)) {
++            if (($this->b == '/' && strpos('(,=:[!&|?', $this->a) !== false)) {
+                 $this->saveRegex();
+             }
+         }
+@@ -257,6 +277,7 @@ class Minifier
+     protected function clean()
+     {
+         unset($this->input);
++        $this->len = 0;
+         $this->index = 0;
+         $this->a = $this->b = '';
+         unset($this->c);
+@@ -276,7 +297,7 @@ class Minifier
+             unset($this->c);
+         } else {
+             // Otherwise we start pulling from the input.
+-            $char = substr($this->input, $this->index, 1);
++            $char = $this->index < $this->len ? $this->input[$this->index] : false;
+ 
+             // If the next character doesn't exist return false.
+             if (isset($char) && $char === false) {
+@@ -289,7 +310,7 @@ class Minifier
+ 
+         // Normalize all whitespace except for the newline character into a
+         // standard space.
+-        if ($char !== "\n" && ord($char) < 32) {
++        if ($char !== "\n" && $char < "\x20") {
+             return ' ';
+         }
+ 
+@@ -340,7 +361,7 @@ class Minifier
+      */
+     protected function processOneLineComments($startIndex)
+     {
+-        $thirdCommentString = substr($this->input, $this->index, 1);
++        $thirdCommentString = $this->index < $this->len ? $this->input[$this->index] : false;
+ 
+         // kill rest of line
+         $this->getNext("\n");
+@@ -429,7 +450,7 @@ class Minifier
+         $this->index = $pos;
+ 
+         // Return the first character of that string.
+-        return substr($this->input, $this->index, 1);
++        return $this->index < $this->len ? $this->input[$this->index] : false;
+     }
+ 
+     /**
+@@ -447,7 +468,7 @@ class Minifier
+         $this->a = $this->b;
+ 
+         // If this isn't a string we don't need to do anything.
+-        if (!in_array($this->a, $this->stringDelimiters)) {
++        if (!isset($this->stringDelimiters[$this->a])) {
+             return;
+         }
+ 
+@@ -557,7 +578,7 @@ class Minifier
+         /* lock things like <code>"asd" + ++x;</code> */
+         $lock = '"LOCK---' . crc32(time()) . '"';
+ 
+-        $matches = array();
++        $matches = [];
+         preg_match('/([+-])(\s+)([+-])/S', $js, $matches);
+         if (empty($matches)) {
+             return $js;


=====================================
debian/patches/series
=====================================
@@ -3,3 +3,4 @@
 0003-ApplicationBootstrap-setupErrorHandling-migrate-erro.patch
 0004-DashboardConfig-listConfigFilesForUser-silence-error.patch
 0005-Version-getGitHead-silence-errors-from-file_get_cont.patch
+jshrink-php8.patch



View it on GitLab: https://salsa.debian.org/nagios-team/pkg-icingaweb2/-/compare/b34cbef94eaf70b45f1dea2e8476b9fcdfab2e79...5568de2d6e037606fd050677be50fec0f8d6ea8a

-- 
View it on GitLab: https://salsa.debian.org/nagios-team/pkg-icingaweb2/-/compare/b34cbef94eaf70b45f1dea2e8476b9fcdfab2e79...5568de2d6e037606fd050677be50fec0f8d6ea8a
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-nagios-changes/attachments/20201218/2fbf3913/attachment-0001.html>


More information about the pkg-nagios-changes mailing list