Fix generation of change title system note to not be out of range

What does this MR do and why?

When issuable title changes and only some parts of it actually changed (e.g. Test "issue (1)" to issue (1)), it'll fail to generate diff and result to a 500 error when updating a title of MR/issue. Whenever a change like this happens, a RangeError gets raised.

This is because we are passing the HTML escaped title (" gets changed to ") as the raw title to the Gitlab::Diff::InlineDiffMarker. That class inherits from Gitlab::StringRangeMarker, expects a raw_line and a rich_line. In Gitlab::Diff::InlineDiffMarker, if we don't pass rich_line, we pass the raw_line instead. This is affecting the calculation done in Gitlab::StringRangeMarker#mark which results to the range error.

To fix that, we pass the unescaped title as line and it'll be passed as rich_line in Gitlab::Diff::InlineDiffMarker#initialize. In Gitlab::StringRangeMarker#initialize, it'll be then HTML escaped. This ensures that the calculation and mapping of range from raw to rich is working.

References

#556018 (closed)

How to set up and validate locally

  1. Create a MR or issue with title: Test "issue (1)"
  2. Rename that issuable to issue (1). Should be successful and creates system note.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Patrick Bajao

Merge request reports

Loading