Describe the Bug
Regex match limits cause large embedded image data uris, within markdown content, not to be extracted due to reaching the limits of PHP regex pattern matching.
Verified by attempting to upload 3MB of data uri, which triggered issue.
Adding the below, just before the regex ran, would then allow this 3MB file to work fine.
ini_set("pcre.backtrack_limit", "23001337");
ini_set("pcre.recursion_limit", "23001337");
Need to use a more efficient solution for parsing the image data uris.
Maybe a loop over strtok to with some simple tracking would be best.
Ideally needs a test to cover.
HTML unaffected due to using a parser instead of regex.
Regex location:
|
preg_match_all('/!\[.*?]\(.*?(data:image\/.*?)[)"\s]/', $markdown, $matches); |
As reported by @SteveDinn here: #2898 (comment)
Describe the Bug
Regex match limits cause large embedded image data uris, within markdown content, not to be extracted due to reaching the limits of PHP regex pattern matching.
Verified by attempting to upload 3MB of data uri, which triggered issue.
Adding the below, just before the regex ran, would then allow this 3MB file to work fine.
Need to use a more efficient solution for parsing the image data uris.
Maybe a loop over
strtokto with some simple tracking would be best.Ideally needs a test to cover.
HTML unaffected due to using a parser instead of regex.
Regex location:
BookStack/app/Entities/Tools/PageContent.php
Line 116 in 767a82f
As reported by @SteveDinn here: #2898 (comment)