-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
WEBrick directory listings take priority over permalinks #6222
Comments
So, Webrick doesn't redirect |
That's right. If you remove/modify the |
Disabling directory indexing by setting While I know gh-pages probably uses a different http server (maybe nginx or apache), I couldn't reproduce this bug when I tested on github.io. Using python's http.server module, which shows directory indexes too, I reproduced this. |
I wonder if there is some way we could configure one to take priority over the other |
Ok, looking into It may be possible to extend Thinking of something along these lines: # untested code. TODO: setup jekyll dev environment!
def search_index_file(req, res)
# First try the default check for index files in the directory
if file = super
return file
end
# Otherwise, try a custom check for directory.html in the parent directory
# Extract basename from the end of res.filename
path_arr = res.filename.scan(%r{/[^/]*})
# Get the last non-empty section of the filename
while basename = path_arr.pop
break unless basename == '/'
end
if file = search_file(req, res, basename + '.html')
res.filename = path_arr.join
return file
end
return nil
end |
Jekyll extends WEBrick to serve file.html if file is requested but doesn't exist (see jekyll#3452). This doesn't work if file exists as a directory though. This commit extends WEBrick further so that if file exists as a directory, we first try and serve file/index.html (as normal), but fallback to file.html if no index can be found within the file directory (reported as jekyll#6222). It is slightly hacky, to avoid having to re-implement the entire set_filename method, we instead extend search_index_file and temporarily mutate res.filename. This is all clearly commented. See base class search_index_file implementation: https://github.com/ruby/webrick/blob/3fb6a011d620f1c19fce71bc3447740553e4fa80/lib/webrick/httpservlet/filehandler.rb#L365-L385
Jekyll extends WEBrick to serve file.html if file is requested but doesn't exist (see jekyll#3452). This doesn't work if file exists as a directory though. This commit extends WEBrick further so that if file exists as a directory, we first try and serve file/index.html (as normal), but fallback to file.html if no index can be found within the file directory (reported as jekyll#6222). It is slightly hacky, to avoid having to re-implement the entire set_filename method, we instead extend search_index_file and temporarily mutate res.filename. This is all clearly commented. See base class search_index_file implementation: https://github.com/ruby/webrick/blob/3fb6a011/lib/webrick/httpservlet/filehandler.rb#L356-L363
Jekyll extends WEBrick to serve file.html if file is requested but doesn't exist (see jekyll#3452). This doesn't work if file exists as a directory though. This commit extends WEBrick further so that if file exists as a directory, we first try and serve file/index.html (as normal), but fallback to file.html if no index can be found within the file directory (reported as jekyll#6222). It is slightly hacky, to avoid having to re-implement the entire set_filename method, we instead extend search_index_file and mutate res.filename, reverting the change if it isn't needed. See base class search_index_file implementation: https://github.com/ruby/webrick/blob/3fb6a011/lib/webrick/httpservlet/filehandler.rb#L356-L363
Fix jekyll#6222, related to jekyll#3452 See base class search_index_file implementation: https://github.com/ruby/webrick/blob/3fb6a011/lib/webrick/httpservlet/filehandler.rb#L356-L363
Fix jekyll#6222, related to jekyll#3452 See base class search_file implementation: https://github.com/ruby/webrick/blob/3fb6a011/lib/webrick/httpservlet/filehandler.rb#L365-L385
@janpio So That seems like a regression, if this changed from 3.5.x to 3.6.0. Could you open a new issue explaining all of this? This deserves it's own conversation. |
Almost.
But just now I noticed that I will create a new issue with repro etc. |
What is on the disk, in the If the content is at |
No, content is in See this new issue for complete description and reproduction repo: |
Is the issue being reported that Jekyll appends a trailing slash (/) to the
URI? Correct content shown but incorrect URI formatting?
…On Sat, 21 Oct 2017, 19:28 Jan Piotrowski, ***@***.***> wrote:
No, content is in page.html. (Only page/index.md should be rendered to
/page/index.html, right?)
See this new issue for complete description and reproduction repo:
#6459 <#6459>
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#6222 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AE0BIsmV6z84A77LPJdRxGxAmNHW8tpfks5sujfbgaJpZM4OY575>
.
|
That is one part, yes. Unfortunately there is another, pages inside the folder show the same content as the page clashing with the folder name. This only started with 3.6.x. See #6459 for a proper bug report with repro etc. |
We upgraded Jekyll to 2.6.3 (a minor version upgrade from 2.4.3) to fix a security vulnerability, but the entire 2.6.x line has a bug with how URLs are handled in the built-in web server. (Fixed here: jekyll/jekyll#6459 and jekyll/jekyll#6475, originally introduced in the fix to jekyll/jekyll#6222 (comment)). Anyway, 2.8.5 includes a fix and generates an identical `_site` directory on disk, so should be all good.
Prefixing the default post permalink and setting page permalink to the same value doesn't work.
Seems to only affect the local
jekyll serve
WEBrick server. GitHub Pages, for example, isn't affected.github-pages
jekyll doctor
to check my configurationMy Reproduction Steps
_config.yml
, set permalink to/blog/:title
/blog
jekyll serve
localhost:4000/blog
localhost:4000/blog.html
_config.yml
, set permalink to/notblog/:title
jekyll serve
localhost:4000/blog
The Output I Wanted
I expected that visiting the permalink defined in the page's front matter would display that page.
Related to #3452
The text was updated successfully, but these errors were encountered: