From: alexandermomchilov@... Date: 2021-06-25T21:08:50+00:00 Subject: [ruby-core:104409] [Ruby master Feature#17992] Upstreaming the htmlentities gem into CGI#.(un)escape_html Issue #17992 has been updated by AMomchilov (Alexander Momchilov). I took the first steps in incorporating this gem, starting with: ```bash git subtree add \ --prefix=lib/cgi/htmlentities \ https://github.com/threedaymonk/htmlentities \ master ``` Which puts the entire `htmlentities` repo under lib/cgi/htmlentities`. This is really nice because it preserves all the git history of the files, original authorship, etc. * From there, I started pulling the subfolders apart, such as moving its tests from `lib/cgi/htmlentities/tests/*_test.rb` to `test/cgi/htmlentities/test_*.rb`. Here's what that process looked like: https://github.com/amomchilov/cgi/compare/embed-htmlentities-gem-subtree...amomchilov:integrate-htmlentities-gem?expand=1 * I also name-spaced all of its files from `HTMLEntities::*` to `CGI::HTMLEntities::*`, so that this doesn't conflict with any existing code that uses both `cgi` and `htmlentities`. * Next I plan to add `require 'cgi/htmlentities/lib/htmlentities'" to `lib/cgi/util.rb`, and the add `#escape_html_entites` and `#unescape_html_entities` methods, which forward onto `HTMLEntities`'s methods. How does this look so far? FYI Here's the "full diff" between my work and CGI's master branch: https://github.com/ruby/cgi/compare/master...amomchilov:integrate-htmlentities-gem?expand=1 ---------------------------------------- Feature #17992: Upstreaming the htmlentities gem into CGI#.(un)escape_html https://bugs.ruby-lang.org/issues/17992#change-92653 * Author: AMomchilov (Alexander Momchilov) * Status: Feedback * Priority: Normal ---------------------------------------- Hi there, I was looking to unescape some HTML entities in a String, and I discovered that `CGI#.(un)escape_html` is **really** limited. Many StackOverflow questions share a similar disappointment, and point users to using the [htmlentities gem](https://github.com/threedaymonk/htmlentities): 1. https://stackoverflow.com/a/383561/3141234 2. https://stackoverflow.com/a/22926384/3141234 This solved my problem, but I feel like something this standard/universal should be built-in. To that end, I'm interested in working on merging the htmlentities gem into CGI's repo. Would this be a welcome change? * I've e-mailed the author (Paul Battley) privately, and got his blessing to do so. * It's MIT licensed, so that should be OK. -- https://bugs.ruby-lang.org/ Unsubscribe: