Skip to content

feat: add PHP strip_tags for AOT and Magician/eval - #901

Open
nahime0 wants to merge 8 commits into
mainfrom
cursor/strip-tags-builtin-5a54
Open

feat: add PHP strip_tags for AOT and Magician/eval#901
nahime0 wants to merge 8 commits into
mainfrom
cursor/strip-tags-builtin-5a54

Conversation

@nahime0

@nahime0 nahime0 commented Sep 5, 2026

Copy link
Copy Markdown
Member

Summary

Adds PHP 8.5 strip_tags(string $string, array|string|null $allowed_tags = null): string on both AOT and Magician/eval.

Termwind's HtmlRenderer::parse uses strip_tags($html) === $html as its plain-text fast path. This change implements only strip_tags (no DOM).

Semantics follow php-src PHP_FUNCTION(strip_tags) + php_strip_tags_ex(..., allow_tag_spaces=0) + php_tag_find:

  • Always strip NULs, HTML tags, PHP tags, and HTML comments
  • Comments and PHP tags cannot be allow-listed
  • < followed by whitespace stays literal ("1 < 2")
  • Unclosed tag at EOF is discarded
  • String allow-list ("<p><a>") and array form (['p','a']<p><a>)
  • Allowed tags keep attributes; inner text of stripped tags is kept
  • Wrong $allowed_tags type is a TypeError

Changes

  • Builtin contract in elephc-builtin-contract
  • Magician eval_builtin! + PHP state machine
  • AOT RuntimeFnId::StripTags, __rt_strip_tags (aarch64 + x86_64), EIR lowering
  • Codegen, eval, error, and Magician unit tests
  • Example coverage in examples/string-ops
  • Docs: docs/php/strings.md, docs/php/eval.md, ROADMAP.md, generated builtin pages, registry, and docs/php/compatibility.md

CI

Head e8188a836 is green: 144 successful, 0 failed. The first run failed on catalog bookkeeping (597/484/584/463 asserts and an unregenerated docs/php/compatibility.md); those are fixed. The earlier macos curl-codegen zlib DNS flake retried clean.

Open in Web Open in Cursor 

cursoragent and others added 4 commits September 5, 2026 10:34
Declare PHP 8.5 strip_tags(string, array|string|null = null) in the
shared catalog, wire the AOT home and RuntimeFnId, and port php-src
php_strip_tags_ex / php_tag_find for Magician/eval.

Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Emit __rt_strip_tags for AArch64 and Linux x86_64, lower optional
allowed_tags (string, null, array, Mixed), and dispatch StripTags
through the typed EIR runtime path.

Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Cover default stripping, allow-lists, Termwind's plain-text check,
case-insensitive and namespaced calls, Magician dispatch, and arity.

Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
@github-actions github-actions Bot added area:builtins Touches PHP builtin declarations or emitters. area:magician Touches eval, include execution, or elephc-magician. area:runtime Touches runtime helpers, GC, ownership, or bridge runtimes. scope:multi-area Touches more compiler areas than the automatic area-label cap. size:l Large pull request. target:linux-x86_64 Contains behavior specific to the Linux x86_64 target. type:feature Introduces new user-visible behavior or capabilities. labels Sep 5, 2026
cursoragent and others added 2 commits September 5, 2026 10:38
PHP leaves the inner text of disallowed tags, so
strip_tags("<p>A</p><b>B</b>", "<p>") is "<p>A</p>B".

Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
@github-actions github-actions Bot added size:xl Very large pull request that needs deliberate review planning. and removed size:l Large pull request. labels Sep 5, 2026
@cursor cursor Bot changed the title feat: add PHP strip_tags() for AOT and Magician/eval feat: add PHP strip_tags for AOT and Magician/eval Sep 5, 2026
@nahime0
nahime0 marked this pull request as ready for review September 5, 2026 10:39
@greptile-apps

greptile-apps Bot commented Sep 5, 2026

Copy link
Copy Markdown

Too many files changed for review (220 files, 100 file limit).

Bypass the limit by tagging @greptile-apps to review.

cursoragent and others added 2 commits September 5, 2026 14:40
The new contract increments the default-feature catalog, eval-registry,
AOT-registry, and interpreter-adapter counts by one.

Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
standard coverage moves to 365/542 and overall builtin coverage to 516/2030.

Co-authored-by: Vincenzo Petrucci <nahime0@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:builtins Touches PHP builtin declarations or emitters. area:magician Touches eval, include execution, or elephc-magician. area:runtime Touches runtime helpers, GC, ownership, or bridge runtimes. scope:multi-area Touches more compiler areas than the automatic area-label cap. size:xl Very large pull request that needs deliberate review planning. target:linux-x86_64 Contains behavior specific to the Linux x86_64 target. type:feature Introduces new user-visible behavior or capabilities.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants