Fix null handling in preg_replace calls inside normalize_content()#177
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #177 +/- ##
=============================================
- Coverage 50.91% 50.33% -0.58%
+ Complexity 375 366 -9
=============================================
Files 27 26 -1
Lines 1974 1951 -23
=============================================
- Hits 1005 982 -23
Misses 969 969
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
What?
This PR fixes a potential bug where
preg_replace()failures could silently corrupt content in thenormalize_content()function. It's an edge case.Why?
If any of these
preg_replace()calls failed and returnednull, the code would continue withnullbeing cast to an empty string in subsequent operations. This could silently corrupt content without any indication of an error.How?
Added null coalescing operator to all three
preg_replace()calls innormalize_content().Not sure if we want to document the
@sincefor any modifications. If that's the case, please let me know, and I'll be happy to make the addition.