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

Allow multi-word data attributes #84

Merged

Conversation

jstorimer
Copy link
Contributor

This is an extension of #59. It's very common when using data attributes to have a multi-word name like data-user-email or data-shop-id. However, the regex added in #59 wasn't general enough to allow these multi-word attributes so they are being scrubbed by the default scrubbers whereas single-word names like data-user are being passed over.

Sidenote: I double-checked the spec and separating words with dashes is definitely the correct way to be doing this
http://www.w3.org/TR/2011/WD-html5-20110525/elements.html#embedding-custom-non-visible-data-with-the-data-attributes

@flavorjones cc @rafaelfranca

@@ -23,7 +23,7 @@ def scrub_attributes node
attr_node.node_name
end

if attr_name =~ /\Adata-\w+\z/
if attr_name =~ /\Adata-[\w-]+\z/

Choose a reason for hiding this comment

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

Maybe we should make this configurable so people can for example disallow data attributes.

flavorjones added a commit that referenced this pull request May 5, 2015
@flavorjones flavorjones merged commit 7def792 into flavorjones:master May 5, 2015
@flavorjones
Copy link
Owner

Awesome, thank you for the contribution!

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

Successfully merging this pull request may close these issues.

3 participants