flavorjones / loofah

Ruby library for HTML/XML transformation and sanitization
MIT License
934 stars 137 forks source link

Empty data attributes are stripped #215

Closed ryanb closed 3 years ago

ryanb commented 3 years ago

Is there a reason why empty data attributes are stripped?

Loofah.fragment('<div data-foo></div>').scrub!(:prune).to_s
 #=> "<div></div>"
Loofah.fragment('<div data-foo="bar"></div>').scrub!(:prune).to_s
 #=> "<div data-foo=\"bar\"></div>"

From what I can tell, empty data attributes are valid in HTML 5.

flavorjones commented 3 years ago

Hi @ryanb, thanks for reporting this. I agree, empty data-* attributes are valid and I think this behavior is just an oversight. Support for data-* attributes was added in #59 and expanded in #84 but at no point were empty attributes tested.

I think I can get to this in the next day or two, hang tight!

flavorjones commented 3 years ago

PR is #216 going through CI now. If it goes green, I'll ship it in v2.12.0 shortly thereafter.

flavorjones commented 3 years ago

v2.12.0 has been released with a fix: Release 2.12.0 / 2021-08-11 · flavorjones/loofah

ryanb commented 3 years ago

Wow thanks for the fast turnaround! I really appreciate the work you put into loofah.

flavorjones commented 3 years ago

Ah, thanks for the kind words.