Web frontend: Commit message text is altered when creating commit hash links
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=443863) </details> <!--IssueSummary end--> <!--- Please read this! Before opening a new issue, make sure to search for keywords in the issues filtered by the "regression" or "type::bug" label: - https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=regression - https://gitlab.com/gitlab-org/gitlab/issues?label_name%5B%5D=type::bug and verify the issue you're about to submit isn't a duplicate. ---> ### Summary <!-- Summarize the bug encountered concisely. --> When viewing a commit message in the web frontend, words that match the beginning of a commit hash are expanded to 8 characters when displayed. This is inappropriate when it is coincidental that the words matches a commit hash. ### Steps to reproduce <!-- Describe how one can reproduce the issue - this is very important. Please use an ordered list. --> 1. Make some commit and push it. Note the first seven characters of the commit hash. 2. Make and push another commit with a message that contains those seven characters as a standalone word somewhere. 3. View the second commit in the web frontend and see that the messages displays eight characters instead of seven. ### Example Project <!-- If possible, please create an example project here on GitLab.com that exhibits the problematic behavior, and link to it here in the bug report. If you are using an older version of GitLab, this will also determine whether the bug is fixed in a more recent version. --> https://gitlab.com/zivarah/hash-link-repro reproduces this issue, specifically in the commit message for [a59e8d073b55dd1b61e1ac01516ad00eec4a8616](https://gitlab.com/zivarah/hash-link-repro/-/commit/a59e8d073b55dd1b61e1ac01516ad00eec4a8616). ### What is the current *bug* behavior? When viewing a commit message in the web frontend, words that are recognized as commit hashes are expanded to 8 characters. Under normal circumstances, this isn't particularly problematic. However, there can be cases where a non-hash value happens to match a commit hash. When this false-positive occurs, adding additional characters to the value displayed _changes the meaning of the message_. For example, take this original commit message which has an issue ID as a trailer: ``` Some subject Some additional content Issue: 1234567 ``` If there happens to be a commit with a hash starting with "1234567", this actually ends up displaying as: ``` Some subject Some additional content Issue: 12345678 ``` Any user attempting to look up the issue by that ID is going to have a bad day. At best, it doesn't exist. At worst, it's the wrong issue entirely. ### What is the expected *correct* behavior? <!-- Describe what you should see instead. --> The _displayed text_ should not be altered when showing the commit message to the user. I think it's acceptable if these false-positive hash matches are displayed as links still -- that's probably not really viable to avoid. ### Relevant logs and/or screenshots <!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise. --> ![image](/uploads/af0d06d7235ee576709af3b1e0a18e3f/image.png) ~"reproduced on GitLab.com" ~"type::bug"
issue