diff --git a/Laminas/Escaper/Escaper.php b/Laminas/Escaper/Escaper.php index d6a02e1..9a3cd16 100755 --- a/Laminas/Escaper/Escaper.php +++ b/Laminas/Escaper/Escaper.php @@ -4,25 +4,6 @@ declare(strict_types=1); namespace Laminas\Escaper; -use function bin2hex; -use function ctype_digit; -use function hexdec; -use function htmlspecialchars; -use function in_array; -use function mb_convert_encoding; -use function ord; -use function preg_match; -use function preg_replace_callback; -use function rawurlencode; -use function sprintf; -use function strlen; -use function strtolower; -use function strtoupper; -use function substr; - -use const ENT_QUOTES; -use const ENT_SUBSTITUTE; - /** * Context specific methods for use in secure output escaping */ @@ -55,7 +36,7 @@ class Escaper /** * Holds the value of the special flags passed as second parameter to - * htmlspecialchars(). + * \htmlspecialchars(). * * @var int */ @@ -143,10 +124,10 @@ class Escaper } $encoding = strtolower($encoding); - if (! in_array($encoding, $this->supportedEncodings)) { + if (! \in_array($encoding, $this->supportedEncodings)) { throw new Exception\InvalidArgumentException( 'Value of \'' . $encoding . '\' passed to ' . static::class - . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()' + . ' constructor parameter is invalid. Provide an encoding supported by \htmlspecialchars()' ); } @@ -174,18 +155,18 @@ class Escaper /** * Escape a string for the HTML Body context where there are very few characters - * of special meaning. Internally this will use htmlspecialchars(). + * of special meaning. Internally this will use \htmlspecialchars(). * * @return string */ public function escapeHtml(string $string) { - return htmlspecialchars($string, $this->htmlSpecialCharsFlags, $this->encoding); + return \htmlspecialchars($string, $this->htmlSpecialCharsFlags, $this->encoding); } /** * Escape a string for the HTML Attribute context. We use an extended set of characters - * to escape that are not covered by htmlspecialchars() to cover cases where an attribute + * to escape that are not covered by \htmlspecialchars() to cover cases where an attribute * might be unquoted or quoted illegally (e.g. backticks are valid quotes for IE). * * @return string @@ -193,11 +174,11 @@ class Escaper public function escapeHtmlAttr(string $string) { $string = $this->toUtf8($string); - if ($string === '' || ctype_digit($string)) { + if ($string === '' || \ctype_digit($string)) { return $string; } - $result = preg_replace_callback('/[^a-z0-9,\.\-_]/iSu', $this->htmlAttrMatcher, $string); + $result = \preg_replace_callback('/[^a-z0-9,\.\-_]/iSu', $this->htmlAttrMatcher, $string); return $this->fromUtf8($result); } @@ -215,11 +196,11 @@ class Escaper public function escapeJs(string $string) { $string = $this->toUtf8($string); - if ($string === '' || ctype_digit($string)) { + if ($string === '' || \ctype_digit($string)) { return $string; } - $result = preg_replace_callback('/[^a-z0-9,\._]/iSu', $this->jsMatcher, $string); + $result = \preg_replace_callback('/[^a-z0-9,\._]/iSu', $this->jsMatcher, $string); return $this->fromUtf8($result); } @@ -232,7 +213,7 @@ class Escaper */ public function escapeUrl(string $string) { - return rawurlencode($string); + return \rawurlencode($string); } /** @@ -244,16 +225,16 @@ class Escaper public function escapeCss(string $string) { $string = $this->toUtf8($string); - if ($string === '' || ctype_digit($string)) { + if ($string === '' || \ctype_digit($string)) { return $string; } - $result = preg_replace_callback('/[^a-z0-9]/iSu', $this->cssMatcher, $string); + $result = \preg_replace_callback('/[^a-z0-9]/iSu', $this->cssMatcher, $string); return $this->fromUtf8($result); } /** - * Callback function for preg_replace_callback that applies HTML Attribute + * Callback function for \preg_replace_callback that applies HTML Attribute * escaping to all matches. * * @param array $matches @@ -262,7 +243,7 @@ class Escaper protected function htmlAttrMatcher($matches) { $chr = $matches[0]; - $ord = ord($chr); + $ord = \ord($chr); /** * The following replaces characters undefined in HTML with the @@ -279,12 +260,12 @@ class Escaper * Check if the current character to escape has a name entity we should * replace it with while grabbing the integer value of the character. */ - if (strlen($chr) > 1) { + if (\strlen($chr) > 1) { $chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8'); } - $hex = bin2hex($chr); - $ord = hexdec($hex); + $hex = \bin2hex($chr); + $ord = \hexdec($hex); if (isset(static::$htmlNamedEntityMap[$ord])) { return '&' . static::$htmlNamedEntityMap[$ord] . ';'; } @@ -294,13 +275,13 @@ class Escaper * for any other characters where a named entity does not exist. */ if ($ord > 255) { - return sprintf('&#x%04X;', $ord); + return \sprintf('&#x%04X;', $ord); } - return sprintf('&#x%02X;', $ord); + return \sprintf('&#x%02X;', $ord); } /** - * Callback function for preg_replace_callback that applies Javascript + * Callback function for \preg_replace_callback that applies Javascript * escaping to all matches. * * @param array $matches @@ -309,21 +290,21 @@ class Escaper protected function jsMatcher($matches) { $chr = $matches[0]; - if (strlen($chr) === 1) { - return sprintf('\\x%02X', ord($chr)); + if (\strlen($chr) === 1) { + return \sprintf('\\x%02X', \ord($chr)); } $chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8'); - $hex = strtoupper(bin2hex($chr)); - if (strlen($hex) <= 4) { - return sprintf('\\u%04s', $hex); + $hex = \strtoupper(\bin2hex($chr)); + if (\strlen($hex) <= 4) { + return \sprintf('\\u%04s', $hex); } - $highSurrogate = substr($hex, 0, 4); - $lowSurrogate = substr($hex, 4, 4); - return sprintf('\\u%04s\\u%04s', $highSurrogate, $lowSurrogate); + $highSurrogate = \substr($hex, 0, 4); + $lowSurrogate = \substr($hex, 4, 4); + return \sprintf('\\u%04s\\u%04s', $highSurrogate, $lowSurrogate); } /** - * Callback function for preg_replace_callback that applies CSS + * Callback function for \preg_replace_callback that applies CSS * escaping to all matches. * * @param array $matches @@ -332,13 +313,13 @@ class Escaper protected function cssMatcher($matches) { $chr = $matches[0]; - if (strlen($chr) === 1) { - $ord = ord($chr); + if (\strlen($chr) === 1) { + $ord = \ord($chr); } else { $chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8'); - $ord = hexdec(bin2hex($chr)); + $ord = \hexdec(\bin2hex($chr)); } - return sprintf('\\%X ', $ord); + return \sprintf('\\%X ', $ord); } /** @@ -358,7 +339,7 @@ class Escaper if (! $this->isUtf8($result)) { throw new Exception\RuntimeException( - sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result) + \sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result) ); } @@ -388,11 +369,11 @@ class Escaper */ protected function isUtf8($string) { - return $string === '' || preg_match('/^./su', $string); + return $string === '' || \preg_match('/^./su', $string); } /** - * Encoding conversion helper which wraps mb_convert_encoding + * Encoding conversion helper which wraps \mb_convert_encoding * * @param string $string * @param string $to @@ -401,7 +382,7 @@ class Escaper */ protected function convertEncoding($string, $to, $from) { - $result = mb_convert_encoding($string, $to, $from); + $result = \mb_convert_encoding($string, $to, $from); if ($result === false) { return ''; // return non-fatal blank string on encoding errors from users diff --git a/Laminas/Escaper/Exception/ExceptionInterface.php b/Laminas/Escaper/Exception/ExceptionInterface.php index 8f5fd89..36facf0 100755 --- a/Laminas/Escaper/Exception/ExceptionInterface.php +++ b/Laminas/Escaper/Exception/ExceptionInterface.php @@ -4,8 +4,6 @@ declare(strict_types=1); namespace Laminas\Escaper\Exception; -use Throwable; - -interface ExceptionInterface extends Throwable +interface ExceptionInterface extends \Throwable { } diff --git a/Laminas/Escaper/LICENSE.md b/Laminas/Escaper/LICENSE.md index 10b40f1..7158649 100755 --- a/Laminas/Escaper/LICENSE.md +++ b/Laminas/Escaper/LICENSE.md @@ -24,3 +24,20 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +Remark by Jingga: + +The source code looks very similar to zend-escaper from ZendFramework, for this +reason we also include the zend-escaper LICENSE: + +Copyright (c) 2005-2019, Zend Technologies USA, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + + Neither the name of Zend Technologies USA, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/PhpOffice/Common/LICENSE b/PhpOffice/Common/LICENSE new file mode 100644 index 0000000..a7b5dd0 --- /dev/null +++ b/PhpOffice/Common/LICENSE @@ -0,0 +1,15 @@ +PHPOffice Common, a shared PHP library for PHPOffice Libraries + +Copyright (c) 2015-2015 PHPOffice. + +PHPOffice Common is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License version 3 as published by +the Free Software Foundation. + +PHPOffice Common is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License version 3 for more details. + +You should have received a copy of the GNU Lesser General Public License version 3 +along with PHPOffice Common. If not, see . \ No newline at end of file diff --git a/PhpOffice/PhpPresentation/LICENSE b/PhpOffice/PhpPresentation/LICENSE new file mode 100644 index 0000000..b69f098 --- /dev/null +++ b/PhpOffice/PhpPresentation/LICENSE @@ -0,0 +1,15 @@ +PHPPresentation, a pure PHP library for writing presentations files. + +Copyright (c) 2010-2015 PHPPresentation. + +PHPPresentation is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License version 3 as published by +the Free Software Foundation. + +PHPPresentation is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License version 3 for more details. + +You should have received a copy of the GNU Lesser General Public License version 3 +along with PHPPresentation. If not, see . \ No newline at end of file diff --git a/PhpOffice/PhpSpreadsheet/LICENSE b/PhpOffice/PhpSpreadsheet/LICENSE new file mode 100644 index 0000000..a3380df --- /dev/null +++ b/PhpOffice/PhpSpreadsheet/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 PhpSpreadsheet Authors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/PhpOffice/PhpWord/LICENSE b/PhpOffice/PhpWord/LICENSE new file mode 100644 index 0000000..99f7a2d --- /dev/null +++ b/PhpOffice/PhpWord/LICENSE @@ -0,0 +1,15 @@ +PHPWord, a pure PHP library for reading and writing word processing documents. + +Copyright (c) 2010-2016 PHPWord. + +PHPWord is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License version 3 as published by +the Free Software Foundation. + +PHPWord is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License version 3 for more details. + +You should have received a copy of the GNU Lesser General Public License version 3 +along with PHPWord. If not, see . \ No newline at end of file diff --git a/README.md b/README.md index eb9bace..afe7588 100755 --- a/README.md +++ b/README.md @@ -1,3 +1,64 @@ # General -This repository contains all external resources for [Karaka](https://github.com/Karaka-Management/Karaka). These resources are an important part for the organization and by using a hard copy reduces the risk of referencing invalid or incompatible resources. \ No newline at end of file +This repository contains all external resources for [Karaka](https://github.com/Karaka-Management/Karaka). These resources are an important part for the organization and by using a hard copy reduces the risk of referencing invalid or incompatible resources. + +```mermaid +flowchart TD + CSS-->Fonts + Fonts-->Icon + Icon-->LineIcons + Icon-->LinearIcons([LinearIcons]) + Icon-->FontAwesome([FontAwesome]) + Fonts-->Text + Text-->Roboto + JS-->Codes + JS-->Charting + JS-->PDF + Codes-->CodeRecognition + CodeRecognition-->Zbar + PHP-->PDF + PHP-->Office + PHP-->Payment + PHP-->Search + Charting-->Chart + Chart-->ChartJs + Chart-->D3 + Chart-->Mermaid + Charting-->Map + Map-->OpenLayers + PDF-->PDFRendering + PDFRendering-->mozilla + PDF-->PDFBuilding + PDFBuilding-->Mpdf + Mpdf-.->setasign + Mpdf-.->MyClabs + Mpdf-.->DeepCopy + Mpdf-.->Http + Mpdf-.->Psr + PDFBuilding-->TCPDF + Payment-->Stripe + Payment-->PayPal + Office-->PhpSpreadsheet + PhpSpreadsheet-.->Psr + PhpSpreadsheet-.->Http + PhpSpreadsheet-.->ZipStream + Office-->PhpPresentation + Office-->PhpWord + PhpWord-.->Laminas + Search-->Elastic +``` + +## mpdf + +### Changes + +* Replaced `../data` path with `/data` path. The problem is that the data is outside of the namespace path which causes problems. In order to fix this the path was changed and the data directory was copied into the namespace directory. +* Replaces `../ttfonts` path with `/ttfonts` path. Same reason as `data` path. +* Replaces `../tmp` path with `/tmp` path. Same reason as `data` path. + +## tcpdf + +### Changes + +* Added global namespacing to many function calls in tcpdf.pdf +* Simplified the constant definition and definition checks in config.php and similar files \ No newline at end of file diff --git a/Zend/Escaper/Escaper.php b/Zend/Escaper/Escaper.php deleted file mode 100755 index 5cec968..0000000 --- a/Zend/Escaper/Escaper.php +++ /dev/null @@ -1,392 +0,0 @@ - 'quot', // quotation mark - 38 => 'amp', // ampersand - 60 => 'lt', // less-than sign - 62 => 'gt', // greater-than sign - ]; - - /** - * Current encoding for escaping. If not UTF-8, we convert strings from this encoding - * pre-escaping and back to this encoding post-escaping. - * - * @var string - */ - protected $encoding = 'utf-8'; - - /** - * Holds the value of the special flags passed as second parameter to - * htmlspecialchars(). - * - * @var int - */ - protected $htmlSpecialCharsFlags; - - /** - * Static Matcher which escapes characters for HTML Attribute contexts - * - * @var callable - */ - protected $htmlAttrMatcher; - - /** - * Static Matcher which escapes characters for Javascript contexts - * - * @var callable - */ - protected $jsMatcher; - - /** - * Static Matcher which escapes characters for CSS Attribute contexts - * - * @var callable - */ - protected $cssMatcher; - - /** - * List of all encoding supported by this class - * - * @var array - */ - protected $supportedEncodings = [ - 'iso-8859-1', 'iso8859-1', 'iso-8859-5', 'iso8859-5', - 'iso-8859-15', 'iso8859-15', 'utf-8', 'cp866', - 'ibm866', '866', 'cp1251', 'windows-1251', - 'win-1251', '1251', 'cp1252', 'windows-1252', - '1252', 'koi8-r', 'koi8-ru', 'koi8r', - 'big5', '950', 'gb2312', '936', - 'big5-hkscs', 'shift_jis', 'sjis', 'sjis-win', - 'cp932', '932', 'euc-jp', 'eucjp', - 'eucjp-win', 'macroman' - ]; - - /** - * Constructor: Single parameter allows setting of global encoding for use by - * the current object. - * - * @param string $encoding - * @throws Exception\InvalidArgumentException - */ - public function __construct($encoding = null) - { - if ($encoding !== null) { - if (! is_string($encoding)) { - throw new Exception\InvalidArgumentException( - get_class($this) . ' constructor parameter must be a string, received ' . gettype($encoding) - ); - } - if ($encoding === '') { - throw new Exception\InvalidArgumentException( - get_class($this) . ' constructor parameter does not allow a blank value' - ); - } - - $encoding = strtolower($encoding); - if (! in_array($encoding, $this->supportedEncodings)) { - throw new Exception\InvalidArgumentException( - 'Value of \'' . $encoding . '\' passed to ' . get_class($this) - . ' constructor parameter is invalid. Provide an encoding supported by htmlspecialchars()' - ); - } - - $this->encoding = $encoding; - } - - // We take advantage of ENT_SUBSTITUTE flag to correctly deal with invalid UTF-8 sequences. - $this->htmlSpecialCharsFlags = ENT_QUOTES | ENT_SUBSTITUTE; - - // set matcher callbacks - $this->htmlAttrMatcher = [$this, 'htmlAttrMatcher']; - $this->jsMatcher = [$this, 'jsMatcher']; - $this->cssMatcher = [$this, 'cssMatcher']; - } - - /** - * Return the encoding that all output/input is expected to be encoded in. - * - * @return string - */ - public function getEncoding() - { - return $this->encoding; - } - - /** - * Escape a string for the HTML Body context where there are very few characters - * of special meaning. Internally this will use htmlspecialchars(). - * - * @param string $string - * @return string - */ - public function escapeHtml($string) - { - return htmlspecialchars($string, $this->htmlSpecialCharsFlags, $this->encoding); - } - - /** - * Escape a string for the HTML Attribute context. We use an extended set of characters - * to escape that are not covered by htmlspecialchars() to cover cases where an attribute - * might be unquoted or quoted illegally (e.g. backticks are valid quotes for IE). - * - * @param string $string - * @return string - */ - public function escapeHtmlAttr($string) - { - $string = $this->toUtf8($string); - if ($string === '' || ctype_digit($string)) { - return $string; - } - - $result = preg_replace_callback('/[^a-z0-9,\.\-_]/iSu', $this->htmlAttrMatcher, $string); - return $this->fromUtf8($result); - } - - /** - * Escape a string for the Javascript context. This does not use json_encode(). An extended - * set of characters are escaped beyond ECMAScript's rules for Javascript literal string - * escaping in order to prevent misinterpretation of Javascript as HTML leading to the - * injection of special characters and entities. The escaping used should be tolerant - * of cases where HTML escaping was not applied on top of Javascript escaping correctly. - * Backslash escaping is not used as it still leaves the escaped character as-is and so - * is not useful in a HTML context. - * - * @param string $string - * @return string - */ - public function escapeJs($string) - { - $string = $this->toUtf8($string); - if ($string === '' || ctype_digit($string)) { - return $string; - } - - $result = preg_replace_callback('/[^a-z0-9,\._]/iSu', $this->jsMatcher, $string); - return $this->fromUtf8($result); - } - - /** - * Escape a string for the URI or Parameter contexts. This should not be used to escape - * an entire URI - only a subcomponent being inserted. The function is a simple proxy - * to rawurlencode() which now implements RFC 3986 since PHP 5.3 completely. - * - * @param string $string - * @return string - */ - public function escapeUrl($string) - { - return rawurlencode($string); - } - - /** - * Escape a string for the CSS context. CSS escaping can be applied to any string being - * inserted into CSS and escapes everything except alphanumerics. - * - * @param string $string - * @return string - */ - public function escapeCss($string) - { - $string = $this->toUtf8($string); - if ($string === '' || ctype_digit($string)) { - return $string; - } - - $result = preg_replace_callback('/[^a-z0-9]/iSu', $this->cssMatcher, $string); - return $this->fromUtf8($result); - } - - /** - * Callback function for preg_replace_callback that applies HTML Attribute - * escaping to all matches. - * - * @param array $matches - * @return string - */ - protected function htmlAttrMatcher($matches) - { - $chr = $matches[0]; - $ord = ord($chr); - - /** - * The following replaces characters undefined in HTML with the - * hex entity for the Unicode replacement character. - */ - if (($ord <= 0x1f && $chr != "\t" && $chr != "\n" && $chr != "\r") - || ($ord >= 0x7f && $ord <= 0x9f) - ) { - return '�'; - } - - /** - * Check if the current character to escape has a name entity we should - * replace it with while grabbing the integer value of the character. - */ - if (strlen($chr) > 1) { - $chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8'); - } - - $hex = bin2hex($chr); - $ord = hexdec($hex); - if (isset(static::$htmlNamedEntityMap[$ord])) { - return '&' . static::$htmlNamedEntityMap[$ord] . ';'; - } - - /** - * Per OWASP recommendations, we'll use upper hex entities - * for any other characters where a named entity does not exist. - */ - if ($ord > 255) { - return sprintf('&#x%04X;', $ord); - } - return sprintf('&#x%02X;', $ord); - } - - /** - * Callback function for preg_replace_callback that applies Javascript - * escaping to all matches. - * - * @param array $matches - * @return string - */ - protected function jsMatcher($matches) - { - $chr = $matches[0]; - if (strlen($chr) == 1) { - return sprintf('\\x%02X', ord($chr)); - } - $chr = $this->convertEncoding($chr, 'UTF-16BE', 'UTF-8'); - $hex = strtoupper(bin2hex($chr)); - if (strlen($hex) <= 4) { - return sprintf('\\u%04s', $hex); - } - $highSurrogate = substr($hex, 0, 4); - $lowSurrogate = substr($hex, 4, 4); - return sprintf('\\u%04s\\u%04s', $highSurrogate, $lowSurrogate); - } - - /** - * Callback function for preg_replace_callback that applies CSS - * escaping to all matches. - * - * @param array $matches - * @return string - */ - protected function cssMatcher($matches) - { - $chr = $matches[0]; - if (strlen($chr) == 1) { - $ord = ord($chr); - } else { - $chr = $this->convertEncoding($chr, 'UTF-32BE', 'UTF-8'); - $ord = hexdec(bin2hex($chr)); - } - return sprintf('\\%X ', $ord); - } - - /** - * Converts a string to UTF-8 from the base encoding. The base encoding is set via this - * class' constructor. - * - * @param string $string - * @throws Exception\RuntimeException - * @return string - */ - protected function toUtf8($string) - { - if ($this->getEncoding() === 'utf-8') { - $result = $string; - } else { - $result = $this->convertEncoding($string, 'UTF-8', $this->getEncoding()); - } - - if (! $this->isUtf8($result)) { - throw new Exception\RuntimeException( - sprintf('String to be escaped was not valid UTF-8 or could not be converted: %s', $result) - ); - } - - return $result; - } - - /** - * Converts a string from UTF-8 to the base encoding. The base encoding is set via this - * class' constructor. - * @param string $string - * @return string - */ - protected function fromUtf8($string) - { - if ($this->getEncoding() === 'utf-8') { - return $string; - } - - return $this->convertEncoding($string, $this->getEncoding(), 'UTF-8'); - } - - /** - * Checks if a given string appears to be valid UTF-8 or not. - * - * @param string $string - * @return bool - */ - protected function isUtf8($string) - { - return ($string === '' || preg_match('/^./su', $string)); - } - - /** - * Encoding conversion helper which wraps iconv and mbstring where they exist or throws - * and exception where neither is available. - * - * @param string $string - * @param string $to - * @param array|string $from - * @throws Exception\RuntimeException - * @return string - */ - protected function convertEncoding($string, $to, $from) - { - if (function_exists('iconv')) { - $result = iconv($from, $to, $string); - } elseif (function_exists('mb_convert_encoding')) { - $result = mb_convert_encoding($string, $to, $from); - } else { - throw new Exception\RuntimeException( - get_class($this) - . ' requires either the iconv or mbstring extension to be installed' - . ' when escaping for non UTF-8 strings.' - ); - } - - if ($result === false) { - return ''; // return non-fatal blank string on encoding errors from users - } - return $result; - } -} diff --git a/Zend/Escaper/Exception/ExceptionInterface.php b/Zend/Escaper/Exception/ExceptionInterface.php deleted file mode 100755 index 7174796..0000000 --- a/Zend/Escaper/Exception/ExceptionInterface.php +++ /dev/null @@ -1,14 +0,0 @@ - + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/zbar/zbar.wasm b/zbar/zbar.wasm new file mode 100644 index 0000000..f127b3e Binary files /dev/null and b/zbar/zbar.wasm differ diff --git a/zbar/zbarIndex.js b/zbar/zbarIndex.js new file mode 100644 index 0000000..7e00361 --- /dev/null +++ b/zbar/zbarIndex.js @@ -0,0 +1,16 @@ +var zbarWasm=function(t){"use strict"; +/*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */function e(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))}function n(t){var e=t.default;if("function"==typeof e){var n=function(){return e.apply(this,arguments)};n.prototype=e.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(t).forEach((function(e){var r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:function(){return t[e]}})})),n}var r={exports:{}};const i=n(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));function o(t,e){for(var n=0,r=t.length-1;r>=0;r--){var i=t[r];"."===i?t.splice(r,1):".."===i?(t.splice(r,1),n++):n&&(t.splice(r,1),n--)}if(e)for(;n--;n)t.unshift("..");return t}var a=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,s=function(t){return a.exec(t).slice(1)};function u(){for(var t="",e=!1,n=arguments.length-1;n>=-1&&!e;n--){var r=n>=0?arguments[n]:"/";if("string"!=typeof r)throw new TypeError("Arguments to path.resolve must be strings");r&&(t=r+"/"+t,e="/"===r.charAt(0))}return(e?"/":"")+(t=o(d(t.split("/"),(function(t){return!!t})),!e).join("/"))||"."}function c(t){var e=f(t),n="/"===y(t,-1);return(t=o(d(t.split("/"),(function(t){return!!t})),!e).join("/"))||e||(t="."),t&&n&&(t+="/"),(e?"/":"")+t}function f(t){return"/"===t.charAt(0)}function l(){var t=Array.prototype.slice.call(arguments,0);return c(d(t,(function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t})).join("/"))}function _(t,e){function n(t){for(var e=0;e=0&&""===t[n];n--);return e>n?[]:t.slice(e,n-e+1)}t=u(t).substr(1),e=u(e).substr(1);for(var r=n(t.split("/")),i=n(e.split("/")),o=Math.min(r.length,i.length),a=o,s=0;s(t=U(t)?new URL(t):m.normalize(t),p.readFileSync(t,e?void 0:"utf8")),c=t=>{var e=s(t,!0);return e.buffer||(e=new Uint8Array(e)),e},u=(t,e,n)=>{t=U(t)?new URL(t):m.normalize(t),p.readFile(t,(function(t,r){t?n(t):e(r.buffer)}))},process.argv.length>1&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",(function(t){if(!(t instanceof H))throw t})),process.on("unhandledRejection",(function(t){throw t})),a.inspect=function(){return"[Emscripten Module object]"}}else(l||_)&&(_?h=self.location.href:"undefined"!=typeof document&&document.currentScript&&(h=document.currentScript.src),n&&(h=n),h=0!==h.indexOf("blob:")?h.substr(0,h.replace(/[?#].*/,"").lastIndexOf("/")+1):"",s=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.send(null),e.responseText},_&&(c=t=>{var e=new XMLHttpRequest;return e.open("GET",t,!1),e.responseType="arraybuffer",e.send(null),new Uint8Array(e.response)}),u=(t,e,n)=>{var r=new XMLHttpRequest;r.open("GET",t,!0),r.responseType="arraybuffer",r.onload=()=>{200==r.status||0==r.status&&r.response?e(r.response):n()},r.onerror=n,r.send(null)});var d,y,g=a.print||console.log.bind(console),B=a.printErr||console.warn.bind(console);Object.assign(a,f),f=null,a.arguments&&a.arguments,a.thisProgram&&a.thisProgram,a.quit&&a.quit,a.wasmBinary&&(d=a.wasmBinary),a.noExitRuntime,"object"!=typeof WebAssembly&&D("no native wasm support detected");var v,E,Z=!1,b="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function I(){var t=y.buffer;a.HEAP8=new Int8Array(t),a.HEAP16=new Int16Array(t),a.HEAP32=new Int32Array(t),a.HEAPU8=v=new Uint8Array(t),a.HEAPU16=new Uint16Array(t),a.HEAPU32=E=new Uint32Array(t),a.HEAPF32=new Float32Array(t),a.HEAPF64=new Float64Array(t)}a.INITIAL_MEMORY;var S,C,w=[],N=[],T=[],O=0,P=null;function D(t){a.onAbort&&a.onAbort(t),B(t="Aborted("+t+")"),Z=!0,t+=". Build with -sASSERTIONS for more info.";var e=new WebAssembly.RuntimeError(t);throw r(e),e}function F(t){return t.startsWith("data:application/octet-stream;base64,")}function U(t){return t.startsWith("file://")}function G(t){try{if(t==S&&d)return new Uint8Array(d);if(c)return c(t);throw"both async and sync fetching of the wasm failed"}catch(t){D(t)}}function H(t){this.name="ExitStatus",this.message="Program terminated with exit("+t+")",this.status=t}function M(t){for(;t.length>0;)t.shift()(a)}function x(t){var e=y.buffer;try{return y.grow(t-e.byteLength+65535>>>16),I(),1}catch(t){}}F(S="zbar.wasm")||(C=S,S=a.locateFile?a.locateFile(C,h):h+C);var j=[null,[],[]];function L(t,e){var n=j[t];0===e||10===e?((1===t?g:B)(function(t,e,n){for(var r=e+n,i=e;t[i]&&!(i>=r);)++i;if(i-e>16&&t.buffer&&b)return b.decode(t.subarray(e,i));for(var o="";e>10,56320|1023&c)}}else o+=String.fromCharCode((31&a)<<6|s)}else o+=String.fromCharCode(a)}return o}(n,0)),n.length=0):n.push(e)}var k,W={d:function(){return!0},e:function(){return Date.now()},c:function(t){var e,n,r=v.length,i=2147483648;if((t>>>=0)>i)return!1;for(var o=1;o<=4;o*=2){var a=r*(1+.2/o);if(a=Math.min(a,t+100663296),x(Math.min(i,(e=Math.max(t,a))+((n=65536)-e%n)%n)))return!0}return!1},f:function(t){return 52},b:function(t,e,n,r,i){return 70},a:function(t,e,n,r){for(var i=0,o=0;o>2],s=E[e+4>>2];e+=8;for(var u=0;u>2]=i,0}};function Y(t){function n(){k||(k=!0,a.calledRun=!0,Z||(M(N),e(a),a.onRuntimeInitialized&&a.onRuntimeInitialized(),function(){if(a.postRun)for("function"==typeof a.postRun&&(a.postRun=[a.postRun]);a.postRun.length;)t=a.postRun.shift(),T.unshift(t);var t;M(T)}()))}O>0||(function(){if(a.preRun)for("function"==typeof a.preRun&&(a.preRun=[a.preRun]);a.preRun.length;)t=a.preRun.shift(),w.unshift(t);var t;M(w)}(),O>0||(a.setStatus?(a.setStatus("Running..."),setTimeout((function(){setTimeout((function(){a.setStatus("")}),1),n()}),1)):n()))}if(function(){var t={a:W};function e(t,e){var n,r=t.exports;a.asm=r,y=a.asm.g,I(),a.asm.s,n=a.asm.h,N.unshift(n),function(t){if(O--,a.monitorRunDependencies&&a.monitorRunDependencies(O),0==O&&P){var e=P;P=null,e()}}()}function n(t){e(t.instance)}function i(e){return function(){if(!d&&(l||_)){if("function"==typeof fetch&&!U(S))return fetch(S,{credentials:"same-origin"}).then((function(t){if(!t.ok)throw"failed to load wasm binary file at '"+S+"'";return t.arrayBuffer()})).catch((function(){return G(S)}));if(u)return new Promise((function(t,e){u(S,(function(e){t(new Uint8Array(e))}),e)}))}return Promise.resolve().then((function(){return G(S)}))}().then((function(e){return WebAssembly.instantiate(e,t)})).then((function(t){return t})).then(e,(function(t){B("failed to asynchronously prepare wasm: "+t),D(t)}))}if(O++,a.monitorRunDependencies&&a.monitorRunDependencies(O),a.instantiateWasm)try{return a.instantiateWasm(t,e)}catch(t){B("Module.instantiateWasm callback failed with error: "+t),r(t)}(d||"function"!=typeof WebAssembly.instantiateStreaming||F(S)||U(S)||A||"function"!=typeof fetch?i(n):fetch(S,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,t).then(n,(function(t){return B("wasm streaming compile failed: "+t),B("falling back to ArrayBuffer instantiation"),i(n)}))}))).catch(r)}(),a.___wasm_call_ctors=function(){return(a.___wasm_call_ctors=a.asm.h).apply(null,arguments)},a._ImageScanner_create=function(){return(a._ImageScanner_create=a.asm.i).apply(null,arguments)},a._ImageScanner_destory=function(){return(a._ImageScanner_destory=a.asm.j).apply(null,arguments)},a._ImageScanner_set_config=function(){return(a._ImageScanner_set_config=a.asm.k).apply(null,arguments)},a._ImageScanner_enable_cache=function(){return(a._ImageScanner_enable_cache=a.asm.l).apply(null,arguments)},a._ImageScanner_recycle_image=function(){return(a._ImageScanner_recycle_image=a.asm.m).apply(null,arguments)},a._ImageScanner_get_results=function(){return(a._ImageScanner_get_results=a.asm.n).apply(null,arguments)},a._ImageScanner_scan=function(){return(a._ImageScanner_scan=a.asm.o).apply(null,arguments)},a._Image_create=function(){return(a._Image_create=a.asm.p).apply(null,arguments)},a._Image_destory=function(){return(a._Image_destory=a.asm.q).apply(null,arguments)},a._Image_get_symbols=function(){return(a._Image_get_symbols=a.asm.r).apply(null,arguments)},a._free=function(){return(a._free=a.asm.t).apply(null,arguments)},a._malloc=function(){return(a._malloc=a.asm.u).apply(null,arguments)},P=function t(){k||Y(),k||(P=t)},a.preInit)for("function"==typeof a.preInit&&(a.preInit=[a.preInit]);a.preInit.length>0;)a.preInit.pop()();return Y(),o.ready});t.exports=r}(r);const g=r.exports;let B;const v=e(void 0,void 0,void 0,(function*(){if(B=yield g(),!B)throw Error("WASM was not loaded");return B})),E=()=>e(void 0,void 0,void 0,(function*(){return yield v}));var Z,b,I;t.ZBarSymbolType=void 0,(Z=t.ZBarSymbolType||(t.ZBarSymbolType={}))[Z.ZBAR_NONE=0]="ZBAR_NONE",Z[Z.ZBAR_PARTIAL=1]="ZBAR_PARTIAL",Z[Z.ZBAR_EAN2=2]="ZBAR_EAN2",Z[Z.ZBAR_EAN5=5]="ZBAR_EAN5",Z[Z.ZBAR_EAN8=8]="ZBAR_EAN8",Z[Z.ZBAR_UPCE=9]="ZBAR_UPCE",Z[Z.ZBAR_ISBN10=10]="ZBAR_ISBN10",Z[Z.ZBAR_UPCA=12]="ZBAR_UPCA",Z[Z.ZBAR_EAN13=13]="ZBAR_EAN13",Z[Z.ZBAR_ISBN13=14]="ZBAR_ISBN13",Z[Z.ZBAR_COMPOSITE=15]="ZBAR_COMPOSITE",Z[Z.ZBAR_I25=25]="ZBAR_I25",Z[Z.ZBAR_DATABAR=34]="ZBAR_DATABAR",Z[Z.ZBAR_DATABAR_EXP=35]="ZBAR_DATABAR_EXP",Z[Z.ZBAR_CODABAR=38]="ZBAR_CODABAR",Z[Z.ZBAR_CODE39=39]="ZBAR_CODE39",Z[Z.ZBAR_PDF417=57]="ZBAR_PDF417",Z[Z.ZBAR_QRCODE=64]="ZBAR_QRCODE",Z[Z.ZBAR_SQCODE=80]="ZBAR_SQCODE",Z[Z.ZBAR_CODE93=93]="ZBAR_CODE93",Z[Z.ZBAR_CODE128=128]="ZBAR_CODE128",Z[Z.ZBAR_SYMBOL=255]="ZBAR_SYMBOL",Z[Z.ZBAR_ADDON2=512]="ZBAR_ADDON2",Z[Z.ZBAR_ADDON5=1280]="ZBAR_ADDON5",Z[Z.ZBAR_ADDON=1792]="ZBAR_ADDON",t.ZBarConfigType=void 0,(b=t.ZBarConfigType||(t.ZBarConfigType={}))[b.ZBAR_CFG_ENABLE=0]="ZBAR_CFG_ENABLE",b[b.ZBAR_CFG_ADD_CHECK=1]="ZBAR_CFG_ADD_CHECK",b[b.ZBAR_CFG_EMIT_CHECK=2]="ZBAR_CFG_EMIT_CHECK",b[b.ZBAR_CFG_ASCII=3]="ZBAR_CFG_ASCII",b[b.ZBAR_CFG_BINARY=4]="ZBAR_CFG_BINARY",b[b.ZBAR_CFG_NUM=5]="ZBAR_CFG_NUM",b[b.ZBAR_CFG_MIN_LEN=32]="ZBAR_CFG_MIN_LEN",b[b.ZBAR_CFG_MAX_LEN=33]="ZBAR_CFG_MAX_LEN",b[b.ZBAR_CFG_UNCERTAINTY=64]="ZBAR_CFG_UNCERTAINTY",b[b.ZBAR_CFG_POSITION=128]="ZBAR_CFG_POSITION",b[b.ZBAR_CFG_TEST_INVERTED=129]="ZBAR_CFG_TEST_INVERTED",b[b.ZBAR_CFG_X_DENSITY=256]="ZBAR_CFG_X_DENSITY",b[b.ZBAR_CFG_Y_DENSITY=257]="ZBAR_CFG_Y_DENSITY",t.ZBarOrientation=void 0,(I=t.ZBarOrientation||(t.ZBarOrientation={}))[I.ZBAR_ORIENT_UNKNOWN=-1]="ZBAR_ORIENT_UNKNOWN",I[I.ZBAR_ORIENT_UP=0]="ZBAR_ORIENT_UP",I[I.ZBAR_ORIENT_RIGHT=1]="ZBAR_ORIENT_RIGHT",I[I.ZBAR_ORIENT_DOWN=2]="ZBAR_ORIENT_DOWN",I[I.ZBAR_ORIENT_LEFT=3]="ZBAR_ORIENT_LEFT";class S{constructor(t,e){this.ptr=t,this.inst=e}checkAlive(){if(!this.ptr)throw Error("Call after destroyed")}getPointer(){return this.checkAlive(),this.ptr}}class C{constructor(t,e){this.ptr=t,this.ptr32=t>>2,this.buf=e,this.HEAP8=new Int8Array(e),this.HEAPU32=new Uint32Array(e),this.HEAP32=new Int32Array(e)}}class w extends C{get type(){return this.HEAPU32[this.ptr32]}get data(){const t=this.HEAPU32[this.ptr32+4],e=this.HEAPU32[this.ptr32+5];return Int8Array.from(this.HEAP8.subarray(e,e+t))}get points(){const t=this.HEAPU32[this.ptr32+7],e=this.HEAPU32[this.ptr32+8]>>2,n=[];for(let r=0;r>16;return new this(e._Image_create(t,n,808466521,s,a,i),e)}))}destroy(){this.checkAlive(),this.inst._Image_destory(this.ptr),this.ptr=0}getSymbols(){this.checkAlive();const t=this.inst._Image_get_symbols(this.ptr);return T.createSymbolsFromPtr(t,this.inst.HEAPU8.buffer)}}class P extends S{static create(){return e(this,void 0,void 0,(function*(){const t=yield E();return new this(t._ImageScanner_create(),t)}))}destroy(){this.checkAlive(),this.inst._ImageScanner_destory(this.ptr),this.ptr=0}setConfig(t,e,n){return this.checkAlive(),this.inst._ImageScanner_set_config(this.ptr,t,e,n)}enableCache(t=!0){this.checkAlive(),this.inst._ImageScanner_enable_cache(this.ptr,t)}recycleImage(t){this.checkAlive(),this.inst._ImageScanner_recycle_image(this.ptr,t.getPointer())}getResults(){this.checkAlive();const t=this.inst._ImageScanner_get_results(this.ptr);return T.createSymbolsFromPtr(t,this.inst.HEAPU8.buffer)}scan(t){return this.checkAlive(),this.inst._ImageScanner_scan(this.ptr,t.getPointer())}}const D=()=>e(void 0,void 0,void 0,(function*(){const e=yield P.create();return e.setConfig(t.ZBarSymbolType.ZBAR_NONE,t.ZBarConfigType.ZBAR_CFG_BINARY,1),e}));let F;const U=(t,n)=>e(void 0,void 0,void 0,(function*(){void 0===n&&(n=F||(yield D()),F=n);const e=n.scan(t);if(e<0)throw Error("Scan Failed");return 0===e?[]:t.getSymbols()})),G=(t,n,r,i)=>e(void 0,void 0,void 0,(function*(){const e=yield O.createFromRGBABuffer(n,r,t),o=yield U(e,i);return e.destroy(),o}));return t.ZBarImage=O,t.ZBarScanner=P,t.ZBarSymbol=T,t.getDefaultScanner=D,t.getInstance=E,t.scanGrayBuffer=(t,n,r,i)=>e(void 0,void 0,void 0,(function*(){const e=yield O.createFromGrayBuffer(n,r,t),o=yield U(e,i);return e.destroy(),o})),t.scanImageData=(t,n)=>e(void 0,void 0,void 0,(function*(){return yield G(t.data.buffer,t.width,t.height,n)})),t.scanRGBABuffer=G,Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),t}({}); +//# sourceMappingURL=index.js.map