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

Apostrophe in input / select id prevents the selectize widget from loading #1568

Open
5 tasks done
mflorea opened this issue Dec 16, 2020 · 1 comment
Open
5 tasks done
Labels
pending review This issue was closed as stale; since then additional review has been requested.

Comments

@mflorea
Copy link

mflorea commented Dec 16, 2020

I did:

  • Search for if my issue has already been submitted
  • Make sure I'm reporting something precise that needs to be fixed
  • Give my issue a descriptive and concise title
  • Create a minimal working example on JsFiddle or Codepen
    (or gave a link to a demo on the Selectize docs)
  • Indicate precise steps to reproduce in numbers and the result,
    like below

The selectize widget doesn't load if the id of the target input contains an apostrophe. Even if that makes the id invalid (XML-wise), it shouldn't break selectize because if it works without an id it should also work with an invalid id. The selectize widget doesn't depend on the input id to function correctly. "Fixing" the input / select id is not always easy because the code that loads the selectize widget might not control the input HTML (i.e. the code that loads the selectize widget is part of an extension / plugin).

Steps to reproduce:

See https://jsfiddle.net/04jfthgk/1/ . It's enough to set the input / select id to something like foo'bar.

Expected result:

The selectize widget should load. If there is some feature of the selectize widget that requires / expects a valid id then that feature should degrade nicely.

Actual result:

The selectize widget doesn't load and this exception is thrown:

Uncaught Error: Syntax error, unrecognized expression: label[for='foo'bar']

The problem is with this line:

$("label[for='"+inputId+"']").attr('for', inputId + '-selectized');

The input id is not escaped and thus the produced CSS selector can easily be broken if the id contains an apostrophe.

oyejorge added a commit to orchidjs/tom-select that referenced this issue Jan 10, 2021
@github-actions
Copy link
Contributor

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 5 days

@risadams risadams added pending review This issue was closed as stale; since then additional review has been requested. and removed no-issue-activity labels Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending review This issue was closed as stale; since then additional review has been requested.
Projects
None yet
Development

No branches or pull requests

2 participants