diff --git a/package.json b/package.json index 694c011c2a..11cf923f00 100644 --- a/package.json +++ b/package.json @@ -30,11 +30,11 @@ }, "dependencies": { "@popperjs/core": "^2.11.8", - "autocompleter": "^8.0.4", + "autocompleter": "^9.3.2", "bootstrap": "^5.3.3", "bootstrap-datepicker": "^1.10.0", "bootstrap-icons": "^1.11.3", - "chart.js": "^4.4.4", + "chart.js": "^4.4.6", "handlebars": "4.7.8", "highlight.js": "^11.10.0", "masonry-layout": "^4.2.2", @@ -47,7 +47,7 @@ "@babel/preset-env": "^7.26.0", "@commitlint/cli": "^19.5.0", "@commitlint/config-conventional": "^19.5.0", - "@testing-library/jest-dom": "^6.6.2", + "@testing-library/jest-dom": "^6.6.3", "@types/node": "^20.16.5", "autoprefixer": "^10.4.20", "babel-jest": "^29.7.0", diff --git a/phpmyfaq/src/phpMyFAQ/Export/Pdf/Wrapper.php b/phpmyfaq/src/phpMyFAQ/Export/Pdf/Wrapper.php index 604621ed74..bcd0e5b020 100644 --- a/phpmyfaq/src/phpMyFAQ/Export/Pdf/Wrapper.php +++ b/phpmyfaq/src/phpMyFAQ/Export/Pdf/Wrapper.php @@ -480,7 +480,8 @@ public function setFaq(array $faq) } /** - * Extends the TCPDF::Image() method to handle base64 encoded images. + * Extends the TCPDF::Image() method to convert all images to base64 encoded images. + * This is necessary as TCPDF does not support external images from self-signed certificates. * * @param string $file Name of the file containing the image or a '@' character followed by the image data * string. To link an image without embedding it on the document, set an asterisk @@ -541,7 +542,7 @@ public function Image(// phpcs:ignore $file = parse_url($file, PHP_URL_PATH); $type = pathinfo($file, PATHINFO_EXTENSION); - $data = file_get_contents(PMF_ROOT_DIR . $file); + $data = file_get_contents($this->concatenatePaths($file)); if ($this->checkBase64Image($data)) { $file = '@' . $data; @@ -582,4 +583,18 @@ private function checkBase64Image(string $base64): bool return $info && $info[0] > 0 && $info[1] > 0 && isset($info['mime']); } + + private function concatenatePaths(string $file): string + { + $trimmedPath = rtrim(PMF_ROOT_DIR, '/'); + $trimmedFile = ltrim($file, '/'); + + if (str_starts_with($trimmedFile, basename($trimmedPath))) { + $relativePath = substr($trimmedFile, strlen(basename($trimmedPath))); + } else { + $relativePath = $trimmedFile; + } + + return $trimmedPath . DIRECTORY_SEPARATOR . $relativePath; + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bac2c5549e..0f2765424b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: ^2.11.8 version: 2.11.8 autocompleter: - specifier: ^8.0.4 - version: 8.0.4 + specifier: ^9.3.2 + version: 9.3.2 bootstrap: specifier: ^5.3.3 version: 5.3.3(@popperjs/core@2.11.8) @@ -21,8 +21,8 @@ dependencies: specifier: ^1.11.3 version: 1.11.3 chart.js: - specifier: ^4.4.4 - version: 4.4.4 + specifier: ^4.4.6 + version: 4.4.6 handlebars: specifier: 4.7.8 version: 4.7.8 @@ -56,8 +56,8 @@ devDependencies: specifier: ^19.5.0 version: 19.5.0 '@testing-library/jest-dom': - specifier: ^6.6.2 - version: 6.6.2 + specifier: ^6.6.3 + version: 6.6.3 '@types/node': specifier: ^20.16.5 version: 20.16.5 @@ -2421,8 +2421,8 @@ packages: '@sinonjs/commons': 3.0.1 dev: true - /@testing-library/jest-dom@6.6.2: - resolution: {integrity: sha512-P6GJD4yqc9jZLbe98j/EkyQDTPgqftohZF5FBkHY5BUERZmcf4HeO2k0XaefEg329ux2p21i1A1DmyQ1kKw2Jw==} + /@testing-library/jest-dom@6.6.3: + resolution: {integrity: sha512-IteBhl4XqYNkM54f4ejhLRJiZNqcSCoXUOG2CPK7qbD322KjQozM4kHQOfkG2oln9b9HTYqs+Sae8vBATubxxA==} engines: {node: '>=14', npm: '>=6', yarn: '>=1'} dependencies: '@adobe/css-tools': 4.4.0 @@ -2663,8 +2663,8 @@ packages: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} dev: true - /autocompleter@8.0.4: - resolution: {integrity: sha512-q334YswwucSBphN5djVkEt3beVhHotrCtPGNIXmyilw9UnXV9Cb+gNAZ2yhZSfiBSzP6rxHLLT2gpr57xgbcwQ==} + /autocompleter@9.3.2: + resolution: {integrity: sha512-rLbf2TLGOD7y+gOS36ksrZdIsvoHa2KXc2A7503w+NBRPrcF73zzFeYBxEcV/iMPjaBH3jFhNIYObZ7zt1fkCQ==} dev: false /autoprefixer@10.4.20(postcss@8.4.47): @@ -3408,8 +3408,8 @@ packages: engines: {node: '>=10'} dev: true - /chart.js@4.4.4: - resolution: {integrity: sha512-emICKGBABnxhMjUjlYRR12PmOXhJ2eJjEHL2/dZlWjxRAZT1D8xplLFq5M0tMQK8ja+wBS/tuVEJB5C6r7VxJA==} + /chart.js@4.4.6: + resolution: {integrity: sha512-8Y406zevUPbbIBA/HRk33khEmQPk5+cxeflWE/2rx1NJsjVWMPw/9mSP9rxHP5eqi6LNoPBVMfZHxbwLSgldYA==} engines: {pnpm: '>=8'} dependencies: '@kurkle/color': 0.3.2