Skip to content

Wrongly decoding %23 as # #105

@alban

Description

@alban

My markdown file contains this:

![Slack](https://img.shields.io/badge/slack-%23inspektor--gadget-brightgreen.svg?logo=slack)

Notice that %23 is part of the file name. It is not meant to be discarded as a url fragment. The web server uses the file name to generate the following image with the text "slack #inspektor-gadget" inside:

Slack

However, the link checker decodes %23 into #, interprets it as a url fragment, and discards it:

const url = encodeURI(decodeURIComponent(new URL(link, opts.baseUrl).toString()));

Tested with a local web server with the following:

$ cat README2.md 
![Slack](http://localhost:8080/badge/slack-%23inspektor--gadget-brightgreen.svg?logo=slack)]

$ nc -lkp 8080 &
[1] 4003675

$ docker run --net=host -v .:/tmp:ro --rm -i ghcr.io/tcort/markdown-link-check:stable /tmp/README2.md

FILE: /tmp/README2.md

HEAD /badge/slack- HTTP/1.1
accept: */*
user-agent: link-check/5.4.0
host: localhost:8080
Connection: close

Notice how the URL of the HTTP request made by link-check is truncated to /badge/slack-.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions