Repository navigation
fix: stop fixAmps() recursing forever on a navbar link with an entity - #5210
Merged
connortechnology merged 2 commits intoOct 11, 2026
Merged
Conversation
fixAmps() is declared with one parameter but called itself with a position, which PHP drops, so every call searched from the first '&' again. Once ZM_WEB_NAVBAR_LINKS held an entity (&, &ZoneMinder#39;, ...) or a bare '&' followed later by a ';', rendering the left navbar recursed until PHP ran out of memory, and every page answered 500 for users who use the left navbar. Escape the bare ampersands in one preg_replace() instead. Character references are matched at the '&' itself, so a bare '&' is no longer taken as valid because an entity appears later in the string, and hexadecimal references (') are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
getAdditionalLinksHTML() parsed every left navbar link's href as if it carried a query string with a view parameter. A link to another site (https://host/docs) logged 'Undefined array key "query"', a parse_str() deprecation and 'Undefined array key "view"' on every page view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
connortechnology
pushed a commit
that referenced
this pull request
Oct 11, 2026
…#5210) * fix: stop fixAmps() recursing forever on a navbar link with an entity fixAmps() is declared with one parameter but called itself with a position, which PHP drops, so every call searched from the first '&' again. Once ZM_WEB_NAVBAR_LINKS held an entity (&, ', ...) or a bare '&' followed later by a ';', rendering the left navbar recursed until PHP ran out of memory, and every page answered 500 for users who use the left navbar. Escape the bare ampersands in one preg_replace() instead. Character references are matched at the '&' itself, so a bare '&' is no longer taken as valid because an entity appears later in the string, and hexadecimal references (') are kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix: read the view of a navbar link only when its href has one getAdditionalLinksHTML() parsed every left navbar link's href as if it carried a query string with a view parameter. A link to another site (https://host/docs) logged 'Undefined array key "query"', a parse_str() deprecation and 'Undefined array key "view"' on every page view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit f4b4665)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
ZM_WEB_NAVBAR_LINKScontains an HTML entity.fixAmps()becomes onepreg_replace()that escapes every&that doesn't start a character reference; a second commit stops the per-page warnings for navbar links without a query string. 1 file, +9/-15.Details: change, behaviour changes, checks
Before
Upstream master
6c0f976c2:[entity],[two-entities],[bare-and-entity]HTTP 500 (Allowed memory size of 536870912 bytes exhausted ... functions.php on line 1828);[plain],[bare-amp]200.Change
web/skins/classic/includes/functions.phpfixAmps():preg_replace('/&(?!#[0-9]+;|#x[0-9a-f]+;|[a-z][a-z0-9]*;)/i', '&', $html)replaces the recursive search. (Passing the missing offset would also stop the recursion, but keeps the old check, which accepted a bare&whenever any;came later and escaped hex references.)viewof a navbar link only when its href has a query string.Behaviour changes
&is now escaped even when a;appears later in the string (was left as is)&: escape unless it starts a decimal, hex or named reference[bare-and-entity]&) are kept (were escaped to&#x26;)Undefined array keyandparse_str()lines per pageAfter
Branch at
34a032188(base6c0f976c2): 5/5 HTTP 200, link in page, no PHP lines.Not run: release-1.38 (same code; the patches apply with
git am -3).refs #5209
🤖 Generated with Claude Code