Skip to content

Commit

Permalink
Bugfix: allowing images path starting with 'data' to be passed to FPD…
Browse files Browse the repository at this point in the history
…F.image() - fix py-pdf#794 (py-pdf#796)
  • Loading branch information
Lucas-C committed Jun 1, 2023
1 parent ba7d27a commit 6779a1f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ This can also be enabled programmatically with `warnings.simplefilter('default',
### Added
- [`FPDF.mirror()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.mirror) - New method: [documentation page](https://pyfpdf.github.io/fpdf2/Transformations.html) - Contributed by @sebastiantia
- [`FPDF.table()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.table): new optional parameters `gutter_height`, `gutter_width` and `wrapmode`
### Fixed
- [`FPDF.image()`](https://pyfpdf.github.io/fpdf2/fpdf/fpdf.html#fpdf.fpdf.FPDF.image): allowing images path starting with `data` to be passed as input

## [2.7.4] - 2023-04-28
### Added
Expand Down
2 changes: 1 addition & 1 deletion fpdf/image_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def load_image(filename):
# nosemgrep: python.lang.security.audit.dynamic-urllib-use-detected.dynamic-urllib-use-detected
with urlopen(filename) as url_file: # nosec B310
return BytesIO(url_file.read())
elif filename.startswith("data"):
elif filename.startswith("data:"):
return _decode_base64_image(filename)
with open(filename, "rb") as local_file:
return BytesIO(local_file.read())
Expand Down

0 comments on commit 6779a1f

Please sign in to comment.