URLs in Markdown are parsed as commit hashes when containing a 7+ digit number #2356

Closed
opened 2025-11-02 04:33:44 -06:00 by GiteaMirror · 1 comment
Owner

Originally created by @linusg on GitHub (Sep 26, 2018).

  • Gitea version (or commit ref): 79b4d4729c
  • Git version: 2.11.0
  • Operating system: Debian 9
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
    • Not relevant
  • Log gist:

Description

This just occurred to me while putting a product link into a MD readme without the special link syntax ([Example](http://example.com)). If the link contains a number with 7 digits or more, it will break the link:

  • The part before that number will become the link (but broken since it's only a part)
  • The number will become a link to a most likely non-existent commit
  • The part behind the number will be plain text
  • The "special" link syntax stated above is not affected

Minimal example:

Markdown

Good: https://example.com/foo-123456-bar

Bad: https://example.com/foo-1234567-bar

[Good](https://example.com/foo-123456-bar)

[Good](https://example.com/foo-1234567-bar)

Rendered HTML

<p>Good: <a href="https://example.com/foo-123456-bar" rel="nofollow">https://example.com/foo-123456-bar</a></p>

<p>Bad: <a href="https://example.com/foo-" rel="nofollow">https://example.com/foo-</a><a href="https://git.example.com/user/project/src/branch/master/commit/1234567" rel="nofollow">1234567</a>-bar</p>

<p><a href="https://example.com/foo-123456-bar" rel="nofollow">Good</a></p>

<p><a href="https://example.com/foo-1234567-bar" rel="nofollow">Good</a></p>

Screenshots

image
(Mouse pointer is on "https://example.com/foo-")

image
(Mouse pointer is on "1234567")

Originally created by @linusg on GitHub (Sep 26, 2018). - Gitea version (or commit ref): 79b4d4729c3d45a19eb1c02417c3cce1c4111b5c - Git version: 2.11.0 - Operating system: Debian 9 - Database (use `[x]`): - [ ] PostgreSQL - [x] MySQL - [ ] MSSQL - [ ] SQLite - Can you reproduce the bug at https://try.gitea.io: - [ ] Yes (provide example URL) - [ ] No - [x] Not relevant - Log gist: ## Description This just occurred to me while putting a product link into a MD readme without the special link syntax (`[Example](http://example.com)`). If the link contains a number with 7 digits or more, it will break the link: - The part before that number will become the link (but broken since it's only a part) - The number will become a link to a most likely non-existent commit - The part behind the number will be plain text - The "special" link syntax stated above is not affected Minimal example: **Markdown** ``` Good: https://example.com/foo-123456-bar Bad: https://example.com/foo-1234567-bar [Good](https://example.com/foo-123456-bar) [Good](https://example.com/foo-1234567-bar) ``` **Rendered HTML** ``` <p>Good: <a href="https://example.com/foo-123456-bar" rel="nofollow">https://example.com/foo-123456-bar</a></p> <p>Bad: <a href="https://example.com/foo-" rel="nofollow">https://example.com/foo-</a><a href="https://git.example.com/user/project/src/branch/master/commit/1234567" rel="nofollow">1234567</a>-bar</p> <p><a href="https://example.com/foo-123456-bar" rel="nofollow">Good</a></p> <p><a href="https://example.com/foo-1234567-bar" rel="nofollow">Good</a></p> ``` ## Screenshots ![image](https://user-images.githubusercontent.com/19366641/46069761-8964f300-c17c-11e8-808a-c2fd9e619289.png) (Mouse pointer is on "https://example.com/foo-") ![image](https://user-images.githubusercontent.com/19366641/46069708-66d2da00-c17c-11e8-94a3-a28e844d2da5.png) (Mouse pointer is on "1234567")
Author
Owner

@linusg commented on GitHub (Sep 26, 2018):

Sorry, just found https://github.com/go-gitea/gitea/issues/4435. Closing as duplicate.

@linusg commented on GitHub (Sep 26, 2018): Sorry, just found https://github.com/go-gitea/gitea/issues/4435. Closing as duplicate.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#2356