mastodon/spec/lib
kibigo! 2cabc5d188
Use a tree‐based approach for advanced text formatting (#1907)
* Use a tree‐based approach for adv. text formatting

Sanitizing HTML/Markdown means parsing the content into an HTML tree
under‐the‐hood anyway, and it is more accurate to do mention/hashtag
replacement on the text nodes in that tree than it is to try to hack it
in with regexes et cetera.

This undoes the overrides of `#entities` and `#rewrite` on
`AdvancedTextFormatter` but also stops using them, instead keeping
track of the parsed Nokogiri tree itself and using that in the `#to_s`
method.

Internally, this tree uses `<mastodon-entity>` nodes to keep track of
hashtags, links, and mentions. Sanitization is moved to the beginning,
so it should be known that these do not appear in the input.

* Also disallow entities inside of `<code>`

I think this is generally expected behaviour, and people are annoyed
when their code gets turned into links/hashtags/mentions.

* Minor cleanup to AdvancedTextFormatter

* Change AdvancedTextFormatter to rewrite entities in one pass and sanitize at the end

Also, minor refactoring to better match how other formatters are organized.

* Add some tests

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
2022-12-02 10:29:42 +01:00
..
activitypub Merge branch 'main' into glitch-soc/merge-upstream 2022-10-02 18:46:22 +02:00
connection_pool
ostatus
settings
vacuum Fix vacuum scheduler missing lock, locks never expiring (#19458) 2022-10-26 12:10:48 +02:00
advanced_text_formatter_spec.rb Use a tree‐based approach for advanced text formatting (#1907) 2022-12-02 10:29:42 +01:00
delivery_failure_tracker_spec.rb
emoji_formatter_spec.rb
entity_cache_spec.rb
extractor_spec.rb
fast_ip_map_spec.rb
feed_manager_spec.rb Merge branch 'main' into glitch-soc/merge-upstream 2022-10-02 18:46:22 +02:00
hash_object_spec.rb
hashtag_normalizer_spec.rb
html_aware_formatter_spec.rb
link_details_extractor_spec.rb
permalink_redirector_spec.rb Change public accounts pages to mount the web UI (#19319) 2022-10-20 14:35:29 +02:00
plain_text_formatter_spec.rb
request_pool_spec.rb
request_spec.rb
sanitize_config_spec.rb
scope_transformer_spec.rb
status_cache_hydrator_spec.rb Fix filter handling in status cache hydration (#19963) 2022-11-07 19:47:48 +01:00
status_filter_spec.rb
status_finder_spec.rb
status_reach_finder_spec.rb
suspicious_sign_in_detector_spec.rb
tag_manager_spec.rb
text_formatter_spec.rb
user_settings_decorator_spec.rb
webfinger_resource_spec.rb Fix typos (#19849) 2022-11-08 17:32:03 +01:00