Commit Graph

19 Commits

Author SHA1 Message Date
Régis Hanol
20d46c9583
PERF: only diff HTML / Markdown when needed (#30014)
When serializing the `body_changes` in the `PostRevisionSerializer`, we create two diffs: one for the `cooked` and another one for the `raw` version of the post.

Inside `DiscourseDiff`, we generate both `html` and `markdown` diffs when we only need the `html` diffs for the `cooked` version of the post and the `markdown` diff for the `raw` version of the post.

This solves the issue repored in https://meta.discourse.org/t/server-error-accessing-topic-revisions-on-a-specific-topic/339185 where some revisions would return 500 because of a `ArgumentError : Attributes per element limit exceeded` exception when trying to generate the `html` diff on a very large `raw`.
2024-11-30 16:30:30 +01:00
Daniel Waterworth
666536cbd1
DEV: Prefer \A and \z over ^ and $ in regexes (#19936) 2023-01-20 12:52:49 -06:00
David Taylor
6417173082
DEV: Apply syntax_tree formatting to lib/* 2023-01-09 12:10:19 +00:00
Dmitry Klimensky
d54b339809 Escape values of HTML attributes 2021-08-10 10:25:15 -04:00
Krzysztof Kotlarek
9bff0882c3
FEATURE: Nokogumbo (#9577)
* FEATURE: Nokogumbo

Use Nokogumbo HTML parser.
2020-05-05 13:46:57 +10:00
Nacho Caballero
7d2f5240d9 FIX: Show a correct diff when editing consecutive paragraphs (#8177) 2019-10-11 03:50:37 -04:00
Krzysztof Kotlarek
427d54b2b0 DEV: Upgrading Discourse to Zeitwerk (#8098)
Zeitwerk simplifies working with dependencies in dev and makes it easier reloading class chains. 

We no longer need to use Rails "require_dependency" anywhere and instead can just use standard 
Ruby patterns to require files.

This is a far reaching change and we expect some followups here.
2019-10-02 14:01:53 +10:00
Régis Hanol
134a4c66b7 PERF: limit time spent diffing large blobs of text
REFACTOR: s/.length/.size/g
2019-06-27 01:45:52 +02:00
Régis Hanol
888e68a163 FIX: When mutating a string to build a diff. Duplicate it first
Co-authored-by: Roman Rizzi <rizziromanalejandro@gmail.com>
2019-05-13 09:31:32 +08:00
Sam Saffron
30990006a9 DEV: enable frozen string literal on all files
This reduces chances of errors where consumers of strings mutate inputs
and reduces memory usage of the app.

Test suite passes now, but there may be some stuff left, so we will run
a few sites on a branch prior to merging
2019-05-13 09:31:32 +08:00
Roman Rizzi
9adfd66a8b Revert "FIX: When mutating a string to build a diff. Duplicate it first (#7482)" (#7484)
This reverts commit 20d4093a67.
2019-05-07 16:36:23 +10:00
Roman Rizzi
20d4093a67
FIX: When mutating a string to build a diff. Duplicate it first (#7482) 2019-05-06 13:20:10 -03:00
Régis Hanol
001b0710c7 FIX: don't add diff classes more than once 2018-04-16 15:41:45 +02:00
Kris
2eef9b3295 UX: Adding a sticky footer to the post history modal, removing bootstrap columns 2018-01-29 15:15:50 -05:00
Konrad Borowski
9d737d894d FIX: Don't diplay character reference in HTML diffs (#4204)
* FIX: Don't diplay character reference in HTML diffs

Before this change, HTML escaping was done before splitting text into
tokens, so token splitter saw literals like "&#39;", and split them as
it was normal text into parts into ["&", "#", "39", ";"]. This caused
diff to display character references, as those tokens used separate
HTML tags to display their insertion/deletion status.

* Avoid making one element arrays while generating diffs
2016-05-09 08:44:21 +02:00
Sam Saffron
d65efe7304 SECURITY: fix XSS 2014-06-16 10:24:54 +10:00
Régis Hanol
e5a189fc17 BUGFIX: broken images in edit history with markdown view 2014-06-13 11:29:10 +02:00
Régis Hanol
206ef3dc08 add discourse_diff tests 2013-12-16 18:11:46 +01:00
Régis Hanol
06dd7ffe3c better revision history 2013-12-12 03:41:34 +01:00