Skip to content

Commit

Permalink
Merge branch '4.0' into 'main'
Browse files Browse the repository at this point in the history
  • Loading branch information
thorsten committed Nov 11, 2024
2 parents 35f51d9 + 427e21c commit 3af49d3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
19 changes: 17 additions & 2 deletions phpmyfaq/src/phpMyFAQ/Export/Pdf/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}
24 changes: 12 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3af49d3

Please sign in to comment.