This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
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
settings
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
account_reach_finder.rb
activity_tracker.rb
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
ascii_folding.rb Change how hashtags are normalized (#18795) 2022-07-13 15:03:28 +02:00
cache_buster.rb
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
extractor.rb
fast_geometry_parser.rb Switch from unmaintained paperclip to kt-paperclip (#16724) 2021-09-29 23:52:36 +02:00
fast_ip_map.rb
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
inline_renderer.rb Add caching for payload serialization during fan-out (#19642) 2022-11-04 13:21:06 +01:00
link_details_extractor.rb
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
potential_friendship_tracker.rb
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
scope_transformer.rb
search_query_parser.rb
search_query_transformer.rb
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
tag_manager.rb
text_formatter.rb
themes.rb
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
video_metadata_extractor.rb
webfinger.rb Improve error reporting and logging when processing remote accounts (#15605) 2022-09-20 23:30:26 +02:00
webfinger_resource.rb