force-https
force-https copied to clipboard
Can the content filter regex backtracks be optimized?
I have an edge-case scenario but wanted to suggest an improvement because it "could" affect users some day.
I am applying the content filter as an output buffer so that I can also convert non-https links outside of the post content. When applied to a 518K JSON payload, the preg_replace_callback() function fails. I could likely address this by modifying the pcre backtrack/recursion limits on my server.
Your users may trigger a similar edge case only if they have a large post_content field - unlikely, but remotely possible and a nasty gremlin to detect as there are no errors to explain the missing output.
I would submit a patch if/when I raise my regex game.