{"id":22200696,"url":"https://github.com/amrrbakry/xml_sanitizer","last_synced_at":"2026-02-12T20:32:00.458Z","repository":{"id":56898813,"uuid":"414714769","full_name":"amrrbakry/xml_sanitizer","owner":"amrrbakry","description":"XML sanitization with Loofah and Nokogiri.","archived":false,"fork":false,"pushed_at":"2021-10-08T19:33:25.000Z","size":25,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-25T09:51:35.648Z","etag":null,"topics":["hacktoberfest","loofah","nokogiri","sanitization","sanitizer","xml"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amrrbakry.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-07T18:27:54.000Z","updated_at":"2024-10-21T22:35:29.000Z","dependencies_parsed_at":"2022-08-20T17:40:44.069Z","dependency_job_id":null,"html_url":"https://github.com/amrrbakry/xml_sanitizer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/amrrbakry/xml_sanitizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amrrbakry%2Fxml_sanitizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amrrbakry%2Fxml_sanitizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amrrbakry%2Fxml_sanitizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amrrbakry%2Fxml_sanitizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amrrbakry","download_url":"https://codeload.github.com/amrrbakry/xml_sanitizer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amrrbakry%2Fxml_sanitizer/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29380604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T19:05:20.189Z","status":"ssl_error","status_checked_at":"2026-02-12T19:01:44.216Z","response_time":55,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","loofah","nokogiri","sanitization","sanitizer","xml"],"created_at":"2024-12-02T15:36:20.535Z","updated_at":"2026-02-12T20:32:00.443Z","avatar_url":"https://github.com/amrrbakry.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# XmlSanitizer\n\nXML sanitization with [Loofah](https://github.com/flavorjones/loofah) and [Nokogiri](https://github.com/sparklemotion/nokogiri).\n\n```ruby\nscrubber = XmlSanitizer::DefaultPermitScrubber.new\nscrubber.tags = [\"foo\", \"bar\"]\n\nxml = '\u003cfoo\u003e\u003cbar\u003e\u003cbaz\u003ebaz\u003c/baz\u003e\u003c/bar\u003e\u003c/foo\u003e'\n\nXmlSanitizer.sanitize(xml: xml, scrubber: scrubber) # or use your custom scrubber\n# =\u003e \"\u003c?xml version=\\\"1.0\\\"?\u003e\\n\u003cfoo\u003e\\n  \u003cbar/\u003e\\n\u003c/foo\u003e\\n\"\n```\n\nThe default scrubber will remove all non-permitted tags and their subtrees.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'xml_sanitizer'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install xml_sanitizer\n\n## Usage\n\n### Sanitize an XML document\n```ruby\nscrubber = XmlSanitizer::DefaultPermitScrubber.new\nscrubber.tags = [\"foo\"]\nscrubber.direction = :bottom_up # default is :top_down\n\nxml = '\u003cfoo\u003e\u003cbar\u003e\u003cbaz\u003ebaz\u003c/baz\u003e\u003c/bar\u003e\u003c/foo\u003e'\n\nXmlSanitizer.sanitize(xml: xml, scrubber: scrubber)\n# =\u003e \"\u003c?xml version=\\\"1.0\\\"?\u003e\\n\u003cfoo/\u003e\\n\"\n```\n\n#### with XML namespaces\n\n```ruby\nscrubber = XmlSanitizer::DefaultPermitScrubber.new\nscrubber.tags = [\"ns:foo\"]\n\nxml = '\u003cns:foo xmlns:ns=\"http://www.w3.org/TR/html4/\"\u003e\u003cbar\u003ebaz\u003c/bar\u003e\u003c/ns:foo\u003e'\n\nXmlSanitizer.sanitize(xml: xml, scrubber: scrubber)\n# =\u003e \"\u003c?xml version=\\\"1.0\\\"?\u003e\\n\u003cns:foo xmlns:ns=\\\"http://www.w3.org/TR/html4/\\\"/\u003e\\n\"\n ```\n\n### Sanitize an XML fragment\n```ruby\nscrubber = XmlSanitizer::DefaultPermitScrubber.new(tags: %w[foo bar])\nxml = '\u003cfoo\u003e\u003cbar\u003ebaz\u003c/bar\u003e\u003c/foo\u003e'\n\nXmlSanitizer.sanitize_fragment(xml: xml, scrubber: scrubber)\n# =\u003e \"\u003cfoo\u003e\\n  \u003cbar\u003ebaz\u003c/bar\u003e\\n\u003c/foo\u003e\"\n ```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/amrrbakry/xml_sanitizer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/amrrbakry/xml_sanitizer/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the XmlSanitizer project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/amrrbakry/xml_sanitizer/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famrrbakry%2Fxml_sanitizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famrrbakry%2Fxml_sanitizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famrrbakry%2Fxml_sanitizer/lists"}