diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index 4ff2c1cc8ee..6a67c8cb2b5 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -2452,6 +2452,13 @@ class lessc_parser { } } + /** + * Parse a string + * + * @param string $buffer String to parse + * @throws exception + * @return NULL|stdclass + */ public function parse($buffer) { $this->count = 0; $this->line = 1; @@ -2473,13 +2480,17 @@ class lessc_parser { while (false !== $this->parseChunk()); if ($this->count != strlen($this->buffer)) - $this->throwError(); + { + $this->throwError('parse error count '.$this->count.' != len buffer '.strlen($this->buffer)); + } - // TODO report where the block was opened - if ( !property_exists($this->env, 'parent') || !is_null($this->env->parent) ) - throw new exception('parse error: unclosed block'); + // TODO report where the block was opened + if (!property_exists($this->env, 'parent') || !is_null($this->env->parent)) + { + throw new exception('parse error: unclosed block'); + } - return $this->env; + return $this->env; } /** diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 52dad20c640..994426412ba 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5662,24 +5662,29 @@ function dol_htmlentities($string, $flags = null, $encoding = 'UTF-8', $double_e * If not, it will we considered not HTML encoded even if it is by FPDF. * Example, if string contains euro symbol that has ascii code 128 * - * @param string $s String to check - * @return int 0 if bad iso, 1 if good iso + * @param string $s String to check + * @param string $clean Clean if it is not an ISO. Warning, if file is utf8, you will get a bad formated file. + * @return int|string 0 if bad iso, 1 if good iso, Or the clean string if $clean is 1 */ -function dol_string_is_good_iso($s) +function dol_string_is_good_iso($s, $clean = 0) { $len=dol_strlen($s); + $out= ''; $ok=1; - for($scursor=0;$scursor<$len;$scursor++) + for($scursor = 0; $scursor < $len; $scursor++) { $ordchar=ord($s[$scursor]); //print $scursor.'-'.$ordchar.'
'; if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) { $ok=0; break; } - if ($ordchar > 126 && $ordchar < 160) { $ok=0; break; } + elseif ($ordchar > 126 && $ordchar < 160) { $ok=0; break; } + elseif ($clean) { + $out.= $s[$scursor]; + } } + if ($clean) return $out; return $ok; } - /** * Return nb of lines of a clear text * diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 004033474f7..ae07c4c0c0c 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -667,6 +667,13 @@ if ($action == 'addcontainer') else { // Clean some comment + //$tmpgeturl['content'] = dol_string_is_good_iso($tmpgeturl['content'], 1); + //$tmpgeturl['content'] = utf8_encode(utf8_decode($tmpgeturl['content'])); + //$tmpgeturl['content'] = mb_convert_encoding($tmpgeturl['content'], 'UTF-8', 'UTF-8'); + //$tmpgeturl['content'] = remove_bs($tmpgeturl['content']); + //$tmpgeturl['content'] = str_replace('$screen-md-max', 'auto', $tmpgeturl['content']); + + //var_dump($tmpgeturl['content']);exit; $tmpgeturl['content'] = preg_replace('/\/\*\s+CSS content[a-z\s]*\s+\*\//', '', $tmpgeturl['content']); //dol_mkdir(dirname($filetosave)); @@ -694,7 +701,7 @@ if ($action == 'addcontainer') //$pagecsscontent.=$tmpgeturl['content']."\n"; } catch (exception $e) { //echo "failed to compile lessc"; - dol_syslog("Failed to compile the CSS ".$urltograbbis." that we caught, with lessc: ".$e->getMessage(), LOG_WARNING); + dol_syslog("Failed to compile the CSS from URL ".$urltograbbis." with lessc: ".$e->getMessage(), LOG_WARNING); $pagecsscontent.=$tmpgeturl['content']."\n"; }