Skip to content

Commit bf52267

Browse files
committed
fix: harden android xml attribute parsing
1 parent b42b80e commit bf52267

2 files changed

Lines changed: 292 additions & 103 deletions

File tree

src/platforms/android/__tests__/index.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,16 @@ test('parseUiHierarchy supports mixed quote styles in one node', () => {
104104
assert.equal(result.nodes[0].identifier, 'com.demo:id/title');
105105
});
106106

107+
test('parseUiHierarchy decodes XML entities in Android node attributes', () => {
108+
const xml =
109+
'<hierarchy><node class="android.widget.TextView" text="Line 1&#10;Line 2&#9;&amp;&lt;&gt;&quot;&apos;" bounds="[0,0][10,10]"/></hierarchy>';
110+
111+
const result = parseUiHierarchy(xml, 800, { raw: true });
112+
assert.equal(result.nodes.length, 1);
113+
assert.equal(result.nodes[0].value, 'Line 1\nLine 2\t&<>"\'');
114+
assert.equal(result.nodes[0].label, 'Line 1\nLine 2\t&<>"\'');
115+
});
116+
107117
test('findBounds supports single and double quoted attributes', () => {
108118
const xml = [
109119
'<hierarchy>',

0 commit comments

Comments
 (0)