Skip to content

🤖 avm1: Report XML status -9 for unmatched start-tags - #25083

Open
nazem-droubi wants to merge 2 commits into
ruffle-rs:masterfrom
nazem-droubi:avm1-xml-status-unmatched-start
Open

nazem-droubi wants to merge 2 commits into
ruffle-rs:masterfrom
nazem-droubi:avm1-xml-status-unmatched-start

Conversation

@nazem-droubi

@nazem-droubi nazem-droubi commented Nov 2, 2026 •

Copy link
Copy Markdown

Description

Fixes #24337.

XML.status should be -9 ("a start-tag was not matched with an end-tag") in two cases where Ruffle reported something else:

  • An end-tag closes the element directly above the open one, as in <a><b>foo</a>. Ruffle gave -10.
  • Elements are still open when the input ends, as in <a>foo. Ruffle gave 0.

I ran a set of inputs in the Flash Player 32 debug projector first. They show that -9 applies only when the end-tag names the element one level up. If it names an element further up, as in <a><b><c>foo</a>, or an element that isn't open, Flash still returns -10. So mapping every quick-xml MismatchedEndTag to -9 would be wrong. This PR returns -9 only when the end-tag matches the parent of the open element, and sets -9 at EOF when elements are still open. The parsed tree doesn't change: in every case the test covers, Ruffle and Flash already produce the same toString().

Testing

  • New test avm1/xml_status_mismatched_tags, compiled with Rascal. It covers 21 inputs: the -9 cases (including crossed tags like <a><b>foo</a></b>), the -10 cases next to them, unmatched end-tags, input ending with elements still open, and well-formed input. It traces each case in a multi-line case / returned / toString format. output.txt was recorded with the Flash Player 32 Linux debug projector (cargo testutils execute -s). The test fails without the fix.

Checklist

  • I, a human, have self-reviewed this PR and fully understand the changes within.
  • I have made or updated tests where possible.
  • All of my commits are properly scoped, compile successfully, and pass all tests.
  • This PR does not make sense to split up into smaller PRs.
  • An LLM was involved in the authoring of this code.

AI disclosure: an AI coding agent working on my behalf wrote the code, the test, and this description, and ran the test in Flash Player. I'll handle any review discussion personally.

@nazem-droubi
nazem-droubi marked this pull request as ready for review November 2, 2026 18:54
@danielhjacobs danielhjacobs added A-avm1 Area: AVM1 (ActionScript 1 & 2) T-compat Type: Compatibility with Flash Player labels Nov 2, 2026

@kjarosh kjarosh left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm opening this as a draft so I can review it myself before marking it ready.

Please don't do that. It's fine to open as a draft so that others can review a WIP, but you should review the code before opening the PR. We already have too many PRs open.

Not to mention reviewers won't get notified when you are ready and it's wasting our CI resources.

@kjarosh kjarosh added the waiting-on-author Waiting on the PR author to make the requested changes label Nov 2, 2026
@Lord-McSweeney Lord-McSweeney added the llm The PR contains mostly LLM-generated code label Nov 2, 2026
@kjarosh

kjarosh commented Nov 2, 2026

Copy link
Copy Markdown
Member

The full tests suite passes locally: 4295 passed, 0 failed. cargo fmt --check and cargo clippy -p ruffle_core -- -D warnings are clean.

As mentioned in the template, you don't need to say that, CI takes care of it. This sentence means nothing because every PR has to pass it.

@nazem-droubi

Copy link
Copy Markdown
Author

Thanks — removed that sentence from the description. CI covers it.

@evilpie evilpie left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the second commit should have tests. Also make the commit message that actually describes what is being test.

Comment thread core/src/avm1/globals/xml.rs Resolved
@evilpie evilpie added the xml label Nov 7, 2026
Flash returns -9 when an end-tag closes the element directly above the
open one, as in `<a><b>foo</a>`, and when elements are still open at the
end of the input. Ruffle returned -10 for the first case and 0 for the
second. Other mismatched or unmatched end-tags still give -10.

Fixes ruffle-rs#24337.
Cover XML.status for one-level-up mismatched end-tags, including
`<a><b>foo</a>` and the crossed-tag case `<a><b>foo</a></b>`, and for
EOF while elements are still open. Those cases return -9. Other
mismatched or unmatched end-tags return -10. Traces use the multi-line
case/returned/toString format and were recorded from Flash Player 32.
@cursor
cursor Bot force-pushed the avm1-xml-status-unmatched-start branch from 48d577e to 272a4c7 Compare November 7, 2026 23:12
@evilpie

evilpie commented Nov 7, 2026

Copy link
Copy Markdown
Collaborator

Please remove the following from the commit message. You can't be your own co-author.

Co-authored-by: Nazem nazem-droubi@users.noreply.github.com

Otherwise looks good.

@cursor
cursor Bot force-pushed the avm1-xml-status-unmatched-start branch from 272a4c7 to b59074d Compare November 8, 2026 02:06
@nazem-droubi

Copy link
Copy Markdown
Author

Removed the Co-authored-by trailer from both commits. Thanks for the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-avm1 Area: AVM1 (ActionScript 1 & 2) llm The PR contains mostly LLM-generated code T-compat Type: Compatibility with Flash Player waiting-on-author Waiting on the PR author to make the requested changes xml

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong XML status returned with unmatched start tag (AVM1)

5 participants