Skip to content

fix(android): parse uiautomator XML attributes with single or double quotes#37

Merged
thymikee merged 3 commits into
callstackincubator:mainfrom
XiaoPengYouCode:main
Feb 10, 2026
Merged

fix(android): parse uiautomator XML attributes with single or double quotes#37
thymikee merged 3 commits into
callstackincubator:mainfrom
XiaoPengYouCode:main

Conversation

@XiaoPengYouCode
Copy link
Copy Markdown
Contributor

@XiaoPengYouCode XiaoPengYouCode commented Feb 10, 2026

Question

In the XML dump of Android uiautomator, node attributes may be enclosed in single or double quotes. Previous parsing logic only supported double quotes, causing parsing failures in single-quote scenarios, resulting in the inability to correctly retrieve key attributes such as text, content-desc, and bounds.

Solution

• A new readXmlAttr() function has been added, which supports both single and double quotes with the regular expression /name=(["'])(.*?)\1/
• Refactored findBounds and readNodeAttributes to use a unified new function for reading attributes.
• Export findBounds and parseUiHierarchy for testing.

test

Four new unit test coverages have been added:

  • Double quote attribute analysis
  • Single quote attribute analysis
  • Mixed quotation style
  • findBounds is compatible with both single and double quotes.

Change documents

  • src/platforms/android/index.ts
  • src/platforms/android/tests/index.test.ts (new)

This commit should fix #25

@XiaoPengYouCode
Copy link
Copy Markdown
Contributor Author

There appears to be a deployment issue. This is unrelated to the recent changes; how should we handle this?

@thymikee thymikee merged commit f56dda6 into callstackincubator:main Feb 10, 2026
4 of 6 checks passed
@thymikee
Copy link
Copy Markdown
Member

Thank you! I've pushed a small refactor and xml parsing hardening for security

@XiaoPengYouCode
Copy link
Copy Markdown
Contributor Author

This is my first time contributing to an open-source project, and it's been a great experience. Thank you for your and the community's positive response and helpful replies.

@thymikee
Copy link
Copy Markdown
Member

Love it, thanks for contributing!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android snapshot misses text when XML attributes use single quotes in uiautomator dump

2 participants