Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Processing the select element inside the foreign namespace causes the TypeError #12120

Open
1 task done
Ry0taK opened this issue Nov 24, 2024 · 1 comment
Open
1 task done
Labels
browser Browser Extension bug

Comments

@Ry0taK
Copy link

Ry0taK commented Nov 24, 2024

Steps To Reproduce

  1. Go to https://example.com
  2. Execute document.body.innerHTML = "<svg><select>" in DevTools
  3. Confirm that the Bitwarden throws an error

image

Expected Result

The select element is ignored because it's not an HTMLSelectElement.

Actual Result

The select element inside the svg namespace is treated as HTMLSelectElement. However, it's actually an SVGElement, which causes the error to be thrown.

Screenshots or Videos

No response

Additional Context

The error is thrown in this line because the element.options is undefined for the SVGElement

const options = Array.from(element.options).map((option) => {

Checking the namespace or the prototype in this function should prevent the error.

export function elementIsSelectElement(element: Element): element is HTMLSelectElement {
return elementIsInstanceOf<HTMLSelectElement>(element, "select");
}

Operating System

Windows

Operating System Version

No response

Web Browser

Firefox

Browser Version

132.0.2

Build Version

2024.11.0

Issue Tracking Info

  • I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.
@Ry0taK Ry0taK added browser Browser Extension bug labels Nov 24, 2024
@bitwarden-bot
Copy link

Thank you for reporting this issue! We've added this to our internal tracking system.
ID: PM-15230

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser Browser Extension bug
Projects
None yet
Development

No branches or pull requests

2 participants