Skip to content
New issue

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

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

Already on GitHub? # to your account

Directory listings don't work with magic file 404.html #882

Open
clownfeces opened this issue Jun 4, 2024 · 8 comments · May be fixed by #894
Open

Directory listings don't work with magic file 404.html #882

clownfeces opened this issue Jun 4, 2024 · 8 comments · May be fixed by #894

Comments

@clownfeces
Copy link

If you are using a 404.html as magic file, then directory listings don't work anymore. The 404.html is displayed instead.

Environment Versions

  1. Linux Mint 21.2 (Kernel 5.15.0-107)
  2. Node version 12.22.9
  3. http-server version 14.1.1
@JorensM
Copy link

JorensM commented Jul 8, 2024

This could arguably be the expected behavior, but I guess maybe we could have an option to decide whether directory URLs should be displayed as 404 when 404.html is present or to display the directory.

@JorensM
Copy link

JorensM commented Jul 9, 2024

On second thought it does make sense that when -d is specified that directories should be displayed even when 404.html is present

@KernelDeimos
Copy link
Contributor

I think this would be better as an option to specify 404 files. I'm also remembering nginx has a very unfortunate issue where it's difficult to specify all the 40x/50x pages in general, so learning from that http-server should also have the option to specify a general error page if we add this.

@JorensM
Copy link

JorensM commented Sep 20, 2024

@KernelDeimos So like, an option to specify whether magic 404s should be displayed for directories, if -d is enabled?

@KernelDeimos
Copy link
Contributor

Actually I missed an important detail when I read this at first - specifically that the magic 404.html is something already supported (which seemed to be implied; I'm going to test it myself shortly). I was suggesting a config param to specify the location of a 404 page.

I agree with your statement earlier that -d should imply we don't want to display the 404 page for directory listings. I need to explore a bit more to find out how parent directories etc are handled; do you remember if this is consistent for directories under a directory that contains a 404.html?

@KernelDeimos
Copy link
Contributor

Just did a bit of testing. Since -d defaults to true I'm going to go back to the position that we need a separate config flag for this. If we have -d do this we introduce behavior that exposes directory structures which previously weren't exposed, which is a regression with security implications.

Flag should be verbose and clear for now (I want to hold off reserving new letters for a bit), like --listings-override-404. If someone PRs this I'll merge it.

@JorensM
Copy link

JorensM commented Sep 22, 2024

@KernelDeimos I implemented this feature locally, in the following days I'll make a fork and also add tests. I'll upload the fork tomorrow so you can see my implementation.

@JorensM JorensM linked a pull request Sep 27, 2024 that will close this issue
8 tasks
@JorensM
Copy link

JorensM commented Sep 27, 2024

Hello, here is the PR: #894

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants