Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Add icon support to Selectlist #626

Merged
merged 1 commit into from
Aug 26, 2014
Merged

Conversation

interactivellama
Copy link
Contributor

No description provided.

@@ -62,7 +62,8 @@
this.$selectedItem = $selectedItem = $item;

this.$hiddenField.val(this.$selectedItem.attr('data-value'));
this.$label.text(this.$selectedItem.text());
// Shallow copy
this.$label.html( $(this.$selectedItem.children()[0]).html() );
Copy link
Contributor

Choose a reason for hiding this comment

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

is this just asking for XSS?

@interactivellama interactivellama force-pushed the selectlist-html-selected branch from 1aa7876 to 23d2673 Compare August 26, 2014 05:13
@interactivellama interactivellama changed the title Selectlist to copy contents not just text (for icon support, etc.) Add icon support to Selectlist Aug 26, 2014
@interactivellama
Copy link
Contributor Author

Using a chainsaw instead of a scalpel can get messy...

@kevinparkerson
Copy link
Contributor

I don't think there's a huge XSS issue here. It's utilizing content already defined on the page by the developer, with no input from the user. Additionally, the value that is submitted via form post is not the markup itself, but a separate value altogether. If it were combobox this could be a big problem but with selectlist I believe we're ok.

@vernak2539
Copy link
Contributor

True, but putting any sort of HTML into the page without checking it first is poor form. yes it should be done by the developer implementing it as well, but I don't think we should provide an easy way for it to happen if they mess up

@interactivellama
Copy link
Contributor Author

@vernak2539 Would you be more comfortable with:

this.$label.empty().append(labelContents.clone());

@futuremint
Copy link
Contributor

@vernak2539 would it be ok if it only uses already-existing DOM nodes and merely "moves" them?

@vernak2539
Copy link
Contributor

I would think @futuremint's suggestion would be a good path since we wouldn't be "adding/updating" anything. I'll add this is a weird subject and requires the developer to do a good amount of work implementing as @kevinparkerson said

@mbeard
Copy link
Contributor

mbeard commented Aug 26, 2014

I'm not sure moving would work because there are scenarios where the content would need to be displayed in multiple places at once. For instance, when the selectlist is expanded the content would be showing both within the button and within the menu item.

I do share your concern for XSS vulnerabilities, but in this case, I'm not sure there is one. 1) the content that is being cloned is already rendered and in the DOM 2) there is no direct user input here 3) we're exposing no API/method on the control that would allow you to inject XSS

@dougwilson
Copy link
Contributor

This code just takes HTML that is already on the page and puts it in another location. XSS would have occurred before this code even touched anything, meaning this code has nothing to do with an XSS attack.

@interactivellama interactivellama force-pushed the selectlist-html-selected branch from 23d2673 to 9229447 Compare August 26, 2014 15:53
@vernak2539
Copy link
Contributor

sweet, no worries then. still getting my brain in the mix this week

kevinparkerson pushed a commit that referenced this pull request Aug 26, 2014
@kevinparkerson kevinparkerson merged commit cc6b24b into 3.0.1-wip Aug 26, 2014
@kevinparkerson kevinparkerson deleted the selectlist-html-selected branch August 26, 2014 21:35
@interactivellama interactivellama added this to the 3.0.1 milestone Aug 27, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants