-
Notifications
You must be signed in to change notification settings - Fork 22
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
Feature: Allow for additional attributes #22
base: master
Are you sure you want to change the base?
Conversation
What quoting is necessary here? I know we don't have any quoting for Can you please add unit tests? See The last line should end with a newline. |
@ljosa i'll do this on Friday, what do you mean by quoting? - do you mean code commenting? |
Perhaps I should have written "escaping" instead of "quoting." The code builds HTML. As you know, many characters have special meaning in HTML. If these characters occur in the value of your data attribute, then the result can be invalid HTML (or even a security problem, such as an XSS vulnerability, depending on where the value comes from). I believe that &, <, >, `, and " need to be escaped (but please give that some thought and make sure it's correct). Perhaps it would be a good idea to validate the names of the data attributes also, since controls, U+0020 SPACE, U+0022 ("), U+0027 ('), U+003E (>), U+002F (/), U+003D (=), and noncharacters are not allowed in HTML attribute names (source). |
Hey @ljosa - have escaped values and removed illegal characters from keys and added tests - all asserting true |
Sorry, that's not right kind of escaping. If you have an HTML document with
then
Then, |
Update the HTMLEntities Escape through extending String and Regex prototypes Updated tests to expect HTMLEntities Neatened up indenting via JSFiddle
@ljosa just made another commit fixes this to ensure HTMLEntities are returned - tests updated and asserting true |
A few problems still:
Question: why are you escaping space, slash, and equal sign in the values? I don't think that is necessary—do you have reason to believe otherwise? I believe the unit test for the values should be:
Do you agree? Finally, can you please document the new functionality in the README.md? Thanks! |
I needed a data attribute on the link in my project so thought this would be helpful for others