feat: htmlspecialchars/htmlentities ENT_* flags + ENT_* constants#461
Open
chadmandoo wants to merge 1 commit into
Open
feat: htmlspecialchars/htmlentities ENT_* flags + ENT_* constants#461chadmandoo wants to merge 1 commit into
chadmandoo wants to merge 1 commit into
Conversation
Adds the ENT_* flag constants (ENT_QUOTES=3, ENT_COMPAT, ENT_NOQUOTES, ENT_HTML401, ENT_HTML5=48, ENT_XHTML, ENT_XML1, ENT_SUBSTITUTE, ENT_IGNORE) to the checker constant map + the codegen prescan value table, and extends htmlspecialchars() and htmlentities() to accept the optional flags + encoding arguments (so the common `htmlspecialchars($s, ENT_QUOTES)` form compiles). The arity-tolerant lower_html_escape uses the subject (operand 0) and reuses __rt_htmlspecialchars, which implements ENT_QUOTES behaviour — matching PHP's default flag set and the ENT_QUOTES call form (byte-parity verified). A flag-aware runtime (ENT_HTML5 ' vs &illegalstudio#39;) is a documented follow-up. (cherry picked from commit 7e44adb)
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.
What
Adds the
ENT_*flag constants and extendshtmlspecialchars()/htmlentities()to accept the optionalflags+encodingarguments, so the commonhtmlspecialchars($s, ENT_QUOTES)form compiles (previously: "Undefined constant: ENT_QUOTES" + single-arg only).How
ENT_QUOTES(3),ENT_COMPAT,ENT_NOQUOTES,ENT_HTML401,ENT_HTML5(48),ENT_XHTML,ENT_XML1,ENT_SUBSTITUTE,ENT_IGNOREin the checker constant map (driver/init.rs) and the codegen prescan value table (prescan.rs).builtin!registrations toparams: [string, flags: Int = 11, encoding: Str = "UTF-8"](PHP's default flag set).lower_html_escapeuses the subject (operand 0) and reuses__rt_htmlspecialchars.Note
__rt_htmlspecialcharsimplements ENT_QUOTES behaviour, which matches PHP's default and the ENT_QUOTES call form (byte-parity verified:< " ' &). The flags are accepted but not yet distinguished — a flag-aware runtime (ENT_HTML5'vs', ENT_NOQUOTES) is a follow-up. Builds standalone onmain.