Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic when checking links #209

Open
deining opened this issue Feb 24, 2023 · 1 comment
Open

Panic when checking links #209

deining opened this issue Feb 24, 2023 · 1 comment
Labels

Comments

@deining
Copy link

deining commented Feb 24, 2023

How to repoduce

Create index.html with this content in an empty directory of your choice:

Please note the <a> element at line 6 with the link target {{< relref "/docs" >}}. The latter is a built in hugo shortcode.

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<a href="{{< relref "/docs" >}}">My link</a>
</body>
</html>

Run htmltest inside this directory:

$ htmltest .
htmltest started at 08:44:28 on .
========================================================================
panic: CreateFile {{< relref: Die Syntax für den Dateinamen, Verzeichnisnamen oder die Datenträgerbezeichnung ist falsch.

goroutine 1 [running]:
github.com/wjdp/htmltest/output.CheckErrorPanic(...)
        /home/runner/work/htmltest/htmltest/output/error.go:22
github.com/wjdp/htmltest/htmltest.(*HTMLTest).checkFile(0xc0000aa000, 0xc0000ae2d0, {0xc0000871b0, 0xa})
        /home/runner/work/htmltest/htmltest/htmltest/check-link.go:366 +0x298
github.com/wjdp/htmltest/htmltest.(*HTMLTest).checkInternal(0xc0000aa000, 0xc0000ae2d0)
        /home/runner/work/htmltest/htmltest/htmltest/check-link.go:306 +0x159
github.com/wjdp/htmltest/htmltest.(*HTMLTest).checkLink(0xc0000aa000, 0xc0000be090, 0xc0000ca7e0)
        /home/runner/work/htmltest/htmltest/htmltest/check-link.go:99 +0x1028
github.com/wjdp/htmltest/htmltest.(*HTMLTest).testDocument(0xc0000aa000, 0xc0000be090)
        /home/runner/work/htmltest/htmltest/htmltest/htmltest.go:213 +0x205
github.com/wjdp/htmltest/htmltest.(*HTMLTest).testDocuments(0xc0000aa000)
        /home/runner/work/htmltest/htmltest/htmltest/htmltest.go:184 +0x22f
github.com/wjdp/htmltest/htmltest.Test(0x1132680)
        /home/runner/work/htmltest/htmltest/htmltest/htmltest.go:144 +0x911
main.run(0x1080fa0)
        /home/runner/work/htmltest/htmltest/main.go:163 +0x195
main.main()
        /home/runner/work/htmltest/htmltest/main.go:71 +0x1e5

However, exiting with a panic is never a good thing. htmltest could/should handle this issue more gracefully and continue with link checking IMHO.

Note: Of course I am aware of the fact that the file does not held valid html, so I consider this is a minor issue.

@deining deining added the bug label Feb 24, 2023
@honzik20
Copy link

honzik20 commented Mar 23, 2023

I have similar, tho in my case I cannot decode where the problem is:. <a href=: doesn't appear in my output.

panic: CreateFile public/apps/<a href=: The filename, directory name, or volume label syntax is incorrect.

goroutine 1 [running]:
github.com/wjdp/htmltest/output.CheckErrorPanic(...)
        /home/runner/work/htmltest/htmltest/output/error.go:22
github.com/wjdp/htmltest/htmltest.(*HTMLTest).checkFile(0xc00022ec80, 0xc000a536e0, {0xc0002c9518, 0x14})
        /home/runner/work/htmltest/htmltest/htmltest/check-link.go:366 +0x298
github.com/wjdp/htmltest/htmltest.(*HTMLTest).checkInternal(0xc00022ec80, 0xc000a536e0)
        /home/runner/work/htmltest/htmltest/htmltest/check-link.go:306 +0x159
github.com/wjdp/htmltest/htmltest.(*HTMLTest).checkLink(0xc00022ec80, 0xc0002227e0, 0xc0010d9f80)
        /home/runner/work/htmltest/htmltest/htmltest/check-link.go:99 +0x1028
github.com/wjdp/htmltest/htmltest.(*HTMLTest).testDocument(0xc00022ec80, 0xc0002227e0)
        /home/runner/work/htmltest/htmltest/htmltest/htmltest.go:213 +0x205
github.com/wjdp/htmltest/htmltest.(*HTMLTest).testDocuments(0xc00022ec80)
        /home/runner/work/htmltest/htmltest/htmltest/htmltest.go:184 +0x22f
github.com/wjdp/htmltest/htmltest.Test(0xce2680)
        /home/runner/work/htmltest/htmltest/htmltest/htmltest.go:144 +0x911
main.run(0xc30fa0)
        /home/runner/work/htmltest/htmltest/main.go:163 +0x195
main.main()
        /home/runner/work/htmltest/htmltest/main.go:71 +0x1e5
 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants