From d8eed2e072d1f17ca3913de11e2e2a832881a635 Mon Sep 17 00:00:00 2001 From: Schneider Roland Date: Fri, 2 Dec 2022 22:25:01 +0100 Subject: [PATCH] fix pdf download, add www-data permissions to cutler image --- environments/cutlergyor/apache2/Dockerfile | 2 + patches/vendor/mpdf/mpdf/classes/cssmgr.php | 1722 ++++++ .../vendor/mpdf/mpdf/classes/ttfontsuni.php | 4732 +++++++++++++++++ 3 files changed, 6456 insertions(+) create mode 100644 patches/vendor/mpdf/mpdf/classes/cssmgr.php create mode 100644 patches/vendor/mpdf/mpdf/classes/ttfontsuni.php diff --git a/environments/cutlergyor/apache2/Dockerfile b/environments/cutlergyor/apache2/Dockerfile index f5ef5d0..b3e2153 100644 --- a/environments/cutlergyor/apache2/Dockerfile +++ b/environments/cutlergyor/apache2/Dockerfile @@ -82,3 +82,5 @@ RUN find /config/common/ -maxdepth 2 -type f -name '*-local.php' -exec cp {} / && find /config/rest/ -maxdepth 2 -type f -name '*-local.php' -exec cp {} /var/www/html/cutler/rest/config/ \; +RUN chown -R www-data.www.data /var/www/html/cutler +RUN chmod -R 777 /var/www/html/cutler/frontend/web/uploads/ \ No newline at end of file diff --git a/patches/vendor/mpdf/mpdf/classes/cssmgr.php b/patches/vendor/mpdf/mpdf/classes/cssmgr.php new file mode 100644 index 0000000..b56535c --- /dev/null +++ b/patches/vendor/mpdf/mpdf/classes/cssmgr.php @@ -0,0 +1,1722 @@ +mpdf = $mpdf; + $this->tablecascadeCSS = array(); + $this->CSS=array(); + $this->cascadeCSS = array(); + $this->tbCSSlvl = 0; +} + +function ReadCSS($html) { + preg_match_all('/]*media=["\']([^"\'>]*)["\'].*?<\/style>/is',$html,$m); + for($i=0; $impdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) { + $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html); + } + } + preg_match_all('/]*media=["\']([^"\'>]*)["\'].*?>/is',$html,$m); + for($i=0; $impdf->CSSselectMedia && !preg_match('/('.trim($this->mpdf->CSSselectMedia).'|all)/i',$m[1][$i])) { + $html = preg_replace('/'.preg_quote($m[0][$i],'/').'/','',$html); + } + } + + // mPDF 5.5.02 + // Remove Comment tags inside CSS as ', $html); + preg_match_all('/(.*?)<\/style>/si',$html,$m); + if (count($m[1])) { + for($i=0;$i)/s',' ',$m[1][$i]); + $sub = '>'.preg_replace('|/\*.*?\*/|s',' ',$sub).''; + $html = str_replace('>'.$m[1][$i].'', $sub, $html); + } + } + + + $html = preg_replace('//i','',$html); + $html = preg_replace('/<\!\-\-.*?\-\->/s',' ',$html); + + $match = 0; // no match for instance + $regexp = ''; // This helps debugging: showing what is the REAL string being processed + $CSSext = array(); + + //CSS inside external files + $regexp = '/]*rel=["\']stylesheet["\'][^>]*href=["\']([^>"\']*)["\'].*?>/si'; + $x = preg_match_all($regexp,$html,$cxt); + if ($x) { + $match += $x; + $CSSext = $cxt[1]; + } + $regexp = '/]*href=["\']([^>"\']*)["\'][^>]*?rel=["\']stylesheet["\'].*?>/si'; + $x = preg_match_all($regexp,$html,$cxt); + if ($x) { + $match += $x; + $CSSext = array_merge($CSSext,$cxt[1]); + } + + // look for @import stylesheets + //$regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css)[\'\"]{0,1}\)/si'; + $regexp = '/@import url\([\'\"]{0,1}([^\)]*?\.css(\?\S+)?)[\'\"]{0,1}\)/si'; + $x = preg_match_all($regexp,$html,$cxt); + if ($x) { + $match += $x; + $CSSext = array_merge($CSSext,$cxt[1]); + } + + // look for @import without the url() + //$regexp = '/@import [\'\"]{0,1}([^;]*?\.css)[\'\"]{0,1}/si'; + $regexp = '/@import [\'\"]{0,1}([^;]*?\.css(\?\S+)?)[\'\"]{0,1}/si'; + $x = preg_match_all($regexp,$html,$cxt); + if ($x) { + $match += $x; + $CSSext = array_merge($CSSext,$cxt[1]); + } + + $ind = 0; + $CSSstr = ''; + + if (!is_array($this->cascadeCSS)) $this->cascadeCSS = array(); + + while($match){ + $path = $CSSext[$ind]; + + $path = htmlspecialchars_decode($path); // mPDF 6 + + $this->mpdf->GetFullPath($path); + $CSSextblock = $this->mpdf->_get_file($path); + if ($CSSextblock) { + // look for embedded @import stylesheets in other stylesheets + // and fix url paths (including background-images) relative to stylesheet + //$regexpem = '/@import url\([\'\"]{0,1}(.*?\.css)[\'\"]{0,1}\)/si'; + $regexpem = '/@import url\([\'\"]{0,1}(.*?\.css(\?\S+)?)[\'\"]{0,1}\)/si'; + $xem = preg_match_all($regexpem,$CSSextblock,$cxtem); + $cssBasePath = preg_replace('/\/[^\/]*$/','',$path) . '/'; + if ($xem) { + foreach($cxtem[1] AS $cxtembedded) { + // path is relative to original stlyesheet!! + $this->mpdf->GetFullPath($cxtembedded, $cssBasePath ); + $match++; + $CSSext[] = $cxtembedded; + } + } + $regexpem = '/(background[^;]*url\s*\(\s*[\'\"]{0,1})([^\)\'\"]*)([\'\"]{0,1}\s*\))/si'; + $xem = preg_match_all($regexpem,$CSSextblock,$cxtem); + if ($xem) { + for ($i=0;$impdf->GetFullPath($embedded, $cssBasePath ); + $CSSextblock = preg_replace('/'.preg_quote($cxtem[0][$i],'/').'/', ($cxtem[1][$i].$embedded.$cxtem[3][$i]), $CSSextblock); + } + } + } + $CSSstr .= ' '.$CSSextblock; + } + $match--; + $ind++; + } //end of match + + $match = 0; // reset value, if needed + // CSS as