Skip to content

Commit 57edede

Browse files
authored
Merge pull request #1338 from pcworld/image-security-doc
Improve security-related documentation of addImage and addHtml
2 parents 9989e4e + 6253ada commit 57edede

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

docs/elements.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ To add an image, use the ``addImage`` method to sections, headers, footers, text
242242
243243
$section->addImage($src, [$style]);
244244
245-
- ``$src``. String path to a local image, URL of a remote image or the image data, as a string.
245+
- ``$src``. String path to a local image, URL of a remote image or the image data, as a string. Warning: Do not pass user-generated strings here, as that would allow an attacker to read arbitrary files or perform server-side request forgery by passing file paths or URLs instead of image data.
246246
- ``$style``. See :ref:`image-style`.
247247

248248
Examples:

src/PhpWord/Shared/Html.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class Html
3737
* Add HTML parts.
3838
*
3939
* Note: $stylesheet parameter is removed to avoid PHPMD error for unused parameter
40+
* Warning: Do not pass user-generated HTML here, as that would allow an attacker to read arbitrary
41+
* files or perform server-side request forgery by passing local file paths or URLs in <img>.
4042
*
4143
* @param \PhpOffice\PhpWord\Element\AbstractContainer $element Where the parts need to be added
4244
* @param string $html The code to parse

0 commit comments

Comments
 (0)