Repository navigation
Conversation
Contributor
|
Please use the pull request description template. |
Contributor
|
That is not the pull request description template. Please edit your original comment to use the pull request description template (see below): DescriptionTestingChecklist
|
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.
Description
This PR fixes a bug in AVM2 with-statement scoping that manifests as TypeError: Error #1006: value is not a function in SWFs compiled with asc.jar that use E4X filter expressions containing method calls, e.g. someXML.(name() == x).
Per the AVM2 specification, with (obj) resolves unqualified names by calling [[HasProperty]] on obj — that is, it walks the full prototype chain, matching ECMAScript semantics for with. Ruffle 0.7.1 only checked [[HasOwnProperty]] in ScopeChain::find and search_scope_stack. As a result, names defined on a prototype (for example XML.prototype.name) were not found for objects brought into scope by with.
Changes are limited to core/src/avm2/scope.rs:
ScopeChain::find — for with-scopes, use has_property (walks the prototype chain) instead of has_own_property. Non-object values fall back to has_own_property to preserve existing behavior for pathological with-scopes.
search_scope_stack — same change, via the renamed helper.
Rename value_has_own_property → value_has_property; for Value::Object, call object.has_property(multiname).
TObject::has_property already walks the prototype chain, so no changes were needed in object.rs or in activation.rs.
Testing
asc.jar inlines E4X filter expressions into the following bytecode (abridged):
text
pushwith
findpropstrict name
callproperty name, 0
...
popscope
With obj being an XML node, name lives on XML.prototype, not on the node itself. findpropstrict name returned undefined, and the following callproperty name, 0 threw #1006.
We observed this in the wild on embedded equipment running a Flash-based control/management UI. The device's gui.swf (v2.4.42, built with asc.jar) embeds a navigator page (com.tvips.prodbase.pages.SubidNavigatorPage) that traverses an XML tree using . (name() == overviewnodename) inside updateTreeExpansion().
Under Ruffle 0.7.1 the navigator failed to populate and the page was unusable — no entries appeared, and the sin URL parameter was sent as null instead of the selected sub-identifier. The same SWF runs without issues on Adobe Flash Player, confirming this is a Ruffle-side deviation from the AVM2 spec rather than a bug in the SWF. After the fix, XML.name() is invoked normally, the navigator renders correctly, and sin becomes a valid identifier.
Checklist