We received a report in https://wordpress.org/support/topic/file-couldnt-be-sanitized-error/ stating that certain files couldn't be uploaded. After investigating the issue, we discovered that files larger than 10mb were being rejected due to the DOMDocument limit. We found a solution in version 0.18.0 of enshrined/svg-sanitize that allows us to bypass this limit using $this->sanitizer->setAllowHugeFiles( true );.
However, this solution disables the max recursion limits within the XML parser. As it is unlikely that users will regularly upload SVG files larger than 10mb, I suggest adding this option to the settings instead. When enabled, it sets setAllowHugeFiles() to true, allowing users who need to upload large files to do so without affecting everyone else.
Steps to Reproduce
Install plugin.
Try to upload an SVG that's larger than 10mb.
See issue.
Code of Conduct
[X] I agree to follow this project's Code of Conduct
Describe the bug
We received a report in https://wordpress.org/support/topic/file-couldnt-be-sanitized-error/ stating that certain files couldn't be uploaded. After investigating the issue, we discovered that files larger than 10mb were being rejected due to the
DOMDocument
limit. We found a solution in version0.18.0
ofenshrined/svg-sanitize
that allows us to bypass this limit using$this->sanitizer->setAllowHugeFiles( true );
.However, this solution disables the max recursion limits within the XML parser. As it is unlikely that users will regularly upload SVG files larger than 10mb, I suggest adding this option to the settings instead. When enabled, it sets
setAllowHugeFiles()
totrue
, allowing users who need to upload large files to do so without affecting everyone else.Steps to Reproduce
Code of Conduct