Title: Fix: Ensure equalities processed via new processEqualities hook (Fixes #219) by tusharsoni52 · Pull Request #224 · java-diff-utils/java-diff-utils · GitHub
Open Graph Title: Fix: Ensure equalities processed via new processEqualities hook (Fixes #219) by tusharsoni52 · Pull Request #224 · java-diff-utils/java-diff-utils
X Title: Fix: Ensure equalities processed via new processEqualities hook (Fixes #219) by tusharsoni52 · Pull Request #224 · java-diff-utils/java-diff-utils
Description: Summary This PR introduces a new extension point, processEqualities(), inside DiffRowGenerator to address the HTML-escaping issue described in #219. Previously, equal (unchanged) segments were passed through HTML normalization only once. Because < and > were normalized to < and >, equalities that began with & caused incorrect inline diff grouping (e.g., < vs >). This produced invalid HTML when inlineDiffByWord(true) was used. What This PR Changes ✔ Adds a new protected hook: protected String processEqualities(String text) ✔ All equality chunks now pass through this hook before becoming DiffRow(Tag.EQUAL, ...). ✔ Default behavior is no modification (fully backward compatible). ✔ Users can override this hook to customize HTML or text transformations after diffing, solving the core issue. Why this Fix Works The problem in #219 occurs because the diff logic compares normalized text, but the final output does not normalize equal segments the same way as diffs. By exposing processEqualities(), we give users a consistent post-diff transformation path. This ensures that equal text is handled symmetrically to diffed text and prevents HTML-breaking cases like < / > being partially diffed. Backward Compatibility Existing behavior is preserved. No breaking API changes. The feature is opt-in — users override it only if needed. Tests Included ✔ Added DiffRowGeneratorEqualitiesTest ✔ Verifies that: Equalities now route through processEqualities() Inline diffs still work correctly The issue #219 reproduction scenario no longer produces broken HTML Fixes Fixes #219
Open Graph Description: Summary This PR introduces a new extension point, processEqualities(), inside DiffRowGenerator to address the HTML-escaping issue described in #219. Previously, equal (unchanged) segments were pass...
X Description: Summary This PR introduces a new extension point, processEqualities(), inside DiffRowGenerator to address the HTML-escaping issue described in #219. Previously, equal (unchanged) segments were pass...
Opengraph URL: https://github.com/java-diff-utils/java-diff-utils/pull/224
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:8d03b534-62b2-4b47-0b6d-cd19a7891760 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BE52:22117D:98F9E0:D53185:6968D660 |
| html-safe-nonce | fbdd6632f5c07b219f7ee83128f3cf2a720fc5f0e1fde1286bff03543136a265 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTUyOjIyMTE3RDo5OEY5RTA6RDUzMTg1OjY5NjhENjYwIiwidmlzaXRvcl9pZCI6IjUyOTEwOTY4NTUxMTY1NjgxNjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | ccd1e1edf5dd27ff98c9576230ae25f8e093eddaab04a58f537cd4fc4288e84c |
| hovercard-subject-tag | pull_request:3055657713 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/java-diff-utils/java-diff-utils/pull/224/files |
| twitter:image | https://avatars.githubusercontent.com/u/116971475?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/116971475?s=400&v=4 |
| og:image:alt | Summary This PR introduces a new extension point, processEqualities(), inside DiffRowGenerator to address the HTML-escaping issue described in #219. Previously, equal (unchanged) segments were pass... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3c4e9f2fc1db52c609205138be6a397cfde4574cb54d53015014de30dd49f27e |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/java-diff-utils/java-diff-utils git https://github.com/java-diff-utils/java-diff-utils.git |
| octolytics-dimension-user_id | 40540835 |
| octolytics-dimension-user_login | java-diff-utils |
| octolytics-dimension-repository_id | 86663812 |
| octolytics-dimension-repository_nwo | java-diff-utils/java-diff-utils |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 86663812 |
| octolytics-dimension-repository_network_root_nwo | java-diff-utils/java-diff-utils |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1fb1ea11f8c37dd4dd50347cca70d89824e93788 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width