mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
9eb30dfb1c
Summary: ------- This commit correctly sanitizes incoming MathML according to [FEP-dc88]. Instead of completely removing MathML nodes, it replaces them with their LaTeX or plain-text representation, so that the mathematics can be read in some form by mastodon users. Test Plan: ---------- ``` $ RAILS_ENV=test bundle exec rspec spec/lib/sanitize_config_spec.rb -f d Run options: exclude {:type=>#<Proc: ./spec/rails_helper.rb:79>} Randomized with seed 58854 Sanitize::Config ::MASTODON_STRICT sanitizes math blocks to LaTeX converts h1 to p strong removes "translate" attribute with invalid value removes a without href removes a without href and only keeps text content math sanitizer falls back to plaintext keeps ul prefers latex removes a with unparsable href keeps start and reversed attributes of ol removes a with unsupported scheme in href keeps a with translate="no" keeps a with href keeps a with supported scheme and no host does not re-interpret HTML when removing unsupported links sanitizes math to LaTeX Finished in 0.17323 seconds (files took 3.28 seconds to load) 16 examples, 0 failures Randomized with seed 58854 ``` observed 100% code coverage of `lib/sanitize_ext/sanitize_config.rb`. Ran mastodon locally, and fetched [reference post][nyancat] and observed that math was converted to plaintext form (and was not missing). [FEP-dc88]: https://codeberg.org/fediverse/fep/src/branch/main/fep/dc88/fep-dc88.md [tracking]: https://codeberg.org/fediverse/fep/issues/161 [socialhub]: https://socialhub.activitypub.rocks/t/fep-dc88-formatting-mathematics/3564 [nyancat]: https://nyan.network/notice/Aa4IvnBVHysWswRX1s Related Discussion: ------------------- Please see [FEP-dc88], the [FEP tracking issue][tracking] and [FEP forum discussion][socialhub] for more information. Fixes mastodon/mastodon#26943 |
||
---|---|---|
.. | ||
chewy | ||
config/initializers/rack | ||
controllers | ||
fabrication | ||
fabricators | ||
features | ||
fixtures | ||
generators | ||
helpers | ||
lib | ||
locales | ||
mailers | ||
models | ||
policies | ||
presenters | ||
requests | ||
routing | ||
search/models/concerns/account | ||
serializers | ||
services | ||
support | ||
system | ||
validators | ||
views | ||
workers | ||
rails_helper.rb | ||
spec_helper.rb |