Skip to content

The automatic linking of URLs in job log output incorrectly considers a `]` after the URL to be part of the URL

Summary

The automatic linking of URLs in job log output incorrectly considers a ] after the URL to be part of the URL

Steps to reproduce

Create a new project, where .gitlab-ci.yml contains only:

stages:
  - demo

demo-job-log:
  stage: demo
  image: bash:latest
  script:
    - echo "blah blah [https://example.invalid/foo] blah blah"
    - echo "blah blah [blah https://example.invalid/foo] blah blah"
    - echo "blah blah [https://example.invalid/foo]blah blah"
    - echo "blah blah [blah https://example.invalid/foo]blah blah"
    - echo "blah blah [https://[2001:DB8::]/foo]"

Example Project

https://gitlab.com/david.prior/job-log-url-demo

What is the current bug behaviour?

For the 5 echo lines above, the hrefs of the links are:

  1. https://example.invalid/foo]
  2. https://example.invalid/foo]
  3. https://example.invalid/foo]blah
  4. https://example.invalid/foo]blah
  5. https://[2001:DB8::]/foo]

What is the expected correct behaviour?

For the 5 echo lines above, the hrefs of the links should be:

  1. https://example.invalid/foo
  2. https://example.invalid/foo
  3. https://example.invalid/foo
  4. https://example.invalid/foo
  5. https://[2001:DB8::]/foo

More generally, a ] should not be treated as part of the URL unless it marks the end of a host portion which began with ] as described in Section 3.3 of RFC3986

Relevant logs and/or screenshots

image

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

N/A

Results of GitLab application Check

N/A

Edited by David Prior