PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.1
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.1
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
fluent-cart / vendor / openspout / openspout / src / Common / Helper / Escaper / ODS.php

ODS.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.6.1, at vendor/openspout/openspout/src/Common/Helper/Escaper/ODS.php

57 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\OpenSpout\Common\Helper\Escaper;
4
5 /**
6 * Provides functions to escape and unescape data for ODS files.
7 */
8 class ODS implements EscaperInterface
9 {
10 /**
11 * Escapes the given string to make it compatible with XLSX.
12 *
13 * @param string $string The string to escape
14 *
15 * @return string The escaped string
16 */
17 public function escape($string)
18 {
19 // @NOTE: Using ENT_QUOTES as XML entities ('<', '>', '&') as well as
20 // single/double quotes (for XML attributes) need to be encoded.
21 if (\defined('ENT_DISALLOWED')) {
22 /**
23 * 'ENT_DISALLOWED' ensures that invalid characters in the given document type are replaced.
24 * Otherwise control characters like a vertical tab "\v" will make the XML document unreadable by the XML processor.
25 *
26 * @see https://github.com/box/spout/issues/329
27 */
28 $replacedString = \htmlspecialchars($string, \ENT_QUOTES | \ENT_DISALLOWED, 'UTF-8');
29 } else {
30 // We are on hhvm or any other engine that does not support ENT_DISALLOWED.
31 $escapedString = \htmlspecialchars($string, \ENT_QUOTES, 'UTF-8');
32 // control characters values are from 0 to 1F (hex values) in the ASCII table
33 // some characters should not be escaped though: "\t", "\r" and "\n".
34 $regexPattern = '[\\x00-\\x08' . '\\x0B-\\x0C' . '\\x0E-\\x1F]';
35 $replacedString = \preg_replace("/{$regexPattern}/", '�', $escapedString);
36 }
37 return $replacedString;
38 }
39 /**
40 * Unescapes the given string to make it compatible with XLSX.
41 *
42 * @param string $string The string to unescape
43 *
44 * @return string The unescaped string
45 */
46 public function unescape($string)
47 {
48 // ==============
49 // = WARNING =
50 // ==============
51 // It is assumed that the given string has already had its XML entities decoded.
52 // This is true if the string is coming from a DOMNode (as DOMNode already decode XML entities on creation).
53 // Therefore there is no need to call "htmlspecialchars_decode()".
54 return $string;
55 }
56 }
57