This repository has been archived on 2023-07-01. You can view files and clone it, but cannot push or open issues or pull requests.
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 Add request pool to improve delivery performance (#10353) 2019-07-02 00:34:38 +02:00
ostatus Remove Atom feeds and old URLs in the form of `GET /:username/updates/:id` (#11247) 2019-07-07 16:16:51 +02:00
settings Add a test for Settings::Extend#settings (#5720) 2017-11-19 04:15:32 +01:00
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 Fix single Redis connection being used across all threads (#18135) 2022-04-28 17:47:34 +02:00
emoji_formatter_spec.rb Change RSS feeds (#18356) 2022-05-09 07:43:08 +02:00
entity_cache_spec.rb Fix cache_collection crashing when given an empty collection (#15921) 2021-03-18 00:41:32 +01:00
extractor_spec.rb Spec Extractor (#3540) 2017-06-04 14:57:02 +02:00
fast_ip_map_spec.rb Add IP-based rules (#14963) 2020-10-12 16:33:49 +02:00
feed_manager_spec.rb Merge branch 'main' into glitch-soc/merge-upstream 2022-10-02 18:46:22 +02:00
hash_object_spec.rb Spec HashObject (#3544) 2017-06-04 14:59:52 +02:00
hashtag_normalizer_spec.rb Change how hashtags are normalized (#18795) 2022-07-13 15:03:28 +02:00
html_aware_formatter_spec.rb Fix test-related issues (#17888) 2022-03-28 12:43:58 +02:00
link_details_extractor_spec.rb Add workaround for YouTube Shorts links (#17869) 2022-03-25 19:31:35 +01:00
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 Refactor formatter (#17828) 2022-03-26 02:53:34 +01:00
request_pool_spec.rb Add request pool to improve delivery performance (#10353) 2019-07-02 00:34:38 +02:00
request_spec.rb Fix typos (#18604) 2022-08-28 17:44:34 +02:00
sanitize_config_spec.rb Add advanced text formatting back into glitch-soc 2022-03-28 22:21:37 +02:00
scope_transformer_spec.rb Change authorized applications page (#17656) 2022-03-01 16:48:58 +01:00
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 Record account suspend/silence time and keep track of domain blocks (#10660) 2019-05-14 19:05:02 +02:00
status_finder_spec.rb Remove Atom feeds and old URLs in the form of `GET /:username/updates/:id` (#11247) 2019-07-07 16:16:51 +02:00
status_reach_finder_spec.rb Add support for editing for published statuses (#16697) 2022-01-19 22:37:27 +01:00
suspicious_sign_in_detector_spec.rb Remove sign-in token authentication, instead send e-mail about new sign-in (#17970) 2022-04-06 20:58:12 +02:00
tag_manager_spec.rb Spelling (#17705) 2022-03-06 22:51:40 +01:00
text_formatter_spec.rb Refactor formatter (#17828) 2022-03-26 02:53:34 +01:00
user_settings_decorator_spec.rb Enable updating additional account information from user preferences via rest api (#6789) 2018-04-08 13:43:10 +02:00
webfinger_resource_spec.rb Fix typos (#19849) 2022-11-08 17:32:03 +01:00