mastodon/app/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-28 19:23:58 +02:00
admin Change incoming activity processing to happen in `ingress` queue (#20264) 2022-11-10 14:21:51 +01:00
connection_pool
importer Fix ambiguous column names in `tootctl search deploy` (#18993) 2022-08-17 22:07:12 +01:00
nodeinfo
ostatus
rss Fix errors when rendering RSS feeds (#18531) 2022-05-26 23:02:42 +02:00
settings Merge branch 'main' into glitch-soc/merge-upstream 2021-03-24 10:53:50 +01:00
translation_service Add mention of the translation provider when translating a post (#19433) 2022-10-24 18:37:57 +02:00
vacuum Merge branch 'main' into glitch-soc/merge-upstream 2022-11-28 11:33:34 +01:00
access_token_extension.rb Fix single Redis connection being used across all threads (#18135) 2022-04-28 17:47:34 +02:00
account_reach_finder.rb Fix remote reporters not receiving suspend/unsuspend activities (#16050) 2021-04-17 14:55:46 +02:00
activity_tracker.rb Add graphs and retention metrics to admin dashboard (#16829) 2021-10-14 20:44:59 +02:00
advanced_text_formatter.rb Use a tree‐based approach for advanced text formatting (#1907) 2022-12-02 10:29:42 +01:00
application_extension.rb Fix confirmation redirect to app without `Location` header (#18523) 2022-05-26 22:03:54 +02:00
ascii_folding.rb Change how hashtags are normalized (#18795) 2022-07-13 15:03:28 +02:00
cache_buster.rb Add cache buster feature for media files (#15155) 2020-11-19 17:38:06 +01:00
delivery_failure_tracker.rb Fix some performance issues with /admin/instances (#21907) 2022-12-01 10:32:10 +01:00
emoji_formatter.rb Fix emoji substitution not applying only to text nodes in backend code (#20641) 2022-11-14 20:26:21 +01:00
entity_cache.rb Fix cache_collection crashing when given an empty collection (#15921) 2021-03-18 00:41:32 +01:00
extractor.rb Fix being able to post URLs longer than 4096 characters (#17908) 2022-03-30 14:46:03 +02:00
fast_geometry_parser.rb Switch from unmaintained paperclip to kt-paperclip (#16724) 2021-09-29 23:52:36 +02:00
fast_ip_map.rb Add IP-based rules (#14963) 2020-10-12 16:33:49 +02:00
feed_manager.rb Merge branch 'main' into glitch-soc/merge-upstream 2022-10-28 19:23:58 +02:00
hash_object.rb
hashtag_normalizer.rb Improve performance by avoiding regex construction (#20215) 2022-11-10 05:49:30 +01:00
html_aware_formatter.rb Add advanced text formatting back into glitch-soc 2022-03-28 22:21:37 +02:00
inline_renderer.rb Add caching for payload serialization during fan-out (#19642) 2022-11-04 13:21:06 +01:00
link_details_extractor.rb Add workaround for YouTube Shorts links (#17869) 2022-03-25 19:31:35 +01:00
permalink_redirector.rb Change public accounts pages to mount the web UI (#19319) 2022-10-20 14:35:29 +02:00
plain_text_formatter.rb Refactor formatter (#17828) 2022-03-26 02:53:34 +01:00
potential_friendship_tracker.rb Change auto-following admin-selected accounts, show in recommendations (#16078) 2021-04-24 17:01:43 +02:00
rate_limiter.rb
redis_configuration.rb Add retention policy for cached content and media (#19232) 2022-09-27 03:08:19 +02:00
request.rb fixes ArgumentError when proxy is used (#20420) 2022-11-11 21:31:03 +01:00
request_pool.rb
response_with_limit.rb
scope_parser.rb Change authorized applications page (#17656) 2022-03-01 16:48:58 +01:00
scope_transformer.rb Change authorized applications page (#17656) 2022-03-01 16:48:58 +01:00
search_query_parser.rb
search_query_transformer.rb Fix error resposes for `from` search prefix (#17963) 2022-04-08 21:21:49 +02:00
status_cache_hydrator.rb Merge branch 'main' into glitch-soc/merge-upstream 2022-11-07 19:53:30 +01:00
status_filter.rb
status_finder.rb
status_reach_finder.rb Fix reblogs being discarded after the reblogged status (#19731) 2022-11-04 16:31:44 +01:00
suspicious_sign_in_detector.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.rb Fix TagManager#local_url? erroring out on invalid URL (#18580) 2022-05-31 18:25:24 +02:00
text_formatter.rb Refactor formatter (#17828) 2022-03-26 02:53:34 +01:00
themes.rb Refactor theme config loading 2022-01-16 22:26:18 +01:00
toc_generator.rb
translation_service.rb Change “Translate” button to only show up when a translation backend is configured (#19434) 2022-10-24 18:30:58 +02:00
user_settings_decorator.rb Fix users not being able to change their hide_followers_count setting (#1889) 2022-11-05 11:55:25 +01:00
vacuum.rb Add retention policy for cached content and media (#19232) 2022-09-27 03:08:19 +02:00
validation_error_formatter.rb Add `details` to error response for `POST /api/v1/accounts` in REST API (#15803) 2021-03-01 04:59:13 +01:00
video_metadata_extractor.rb Fix some media attachments being converted with too high framerates (#17619) 2022-02-22 17:11:22 +01:00
webfinger.rb Improve error reporting and logging when processing remote accounts (#15605) 2022-09-20 23:30:26 +02:00
webfinger_resource.rb