-
-
Notifications
You must be signed in to change notification settings - Fork 141
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
Always succeed empty fragment checks #1599
Comments
Please apply this patch and confirm if this resolves the issue FYI: the patch also updates the fixtures/fragments/file.html with the empty fragment anchor and a #top anchor (included for testing) |
@thiru-appitap root@VM-Bookworm:~/DietPi-Docs# grep '"top"' /root/lychee/lychee-lib/src/utils/fragment_checker.rs
let contains_fragment = fragment.is_empty() && file_frags.contains("top")
root@VM-Bookworm:~/DietPi-Docs# /root/lychee/target/debug/lychee --include-fragments -vvv test.md
[200] file:///root/DietPi-Docs/build/docs/index.html#getting-started
[ERROR] file:///root/DietPi-Docs/build/docs/index.html#nonexistent | Cannot find fragment
[ERROR] file:///root/DietPi-Docs/build/docs/index.html# | Cannot find fragment
[ERROR] file:///root/DietPi-Docs/build/docs/index.html#top | Cannot find fragment
Issues found in 1 input. Find details below.
[test.md]:
[ERROR] file:///root/DietPi-Docs/build/docs/index.html#nonexistent | Cannot find fragment
[ERROR] file:///root/DietPi-Docs/build/docs/index.html#top | Cannot find fragment
[ERROR] file:///root/DietPi-Docs/build/docs/index.html# | Cannot find fragment EDIT: The From your patch, the EDIT2: Okay now I have: let contains_fragment = fragment.is_empty()
|| fragment.contains("top")
|| file_frags.contains(fragment)
|| file_frags.contains(&fragment_decoded as &str); With this, the EDIT3: let contains_fragment = fragment == ""
|| fragment == "top"
|| file_frags.contains(fragment)
|| file_frags.contains(&fragment_decoded as &str); which weirdly sometimes succeeds with one of let contains_fragment = match fragment {
"" | "top" => true,
_ => false
}
|| file_frags.contains(fragment)
|| file_frags.contains(&fragment_decoded as &str); which again consequently fails for both. However, I think the logic I aim for is clear, and I hope someone can implement this correctly, based on the type of |
Can you open a pull request with your last attempt and the changes from @thiru-appitap? Then I can take a look and perhaps spot the bug. |
PR up: #1609 |
Thanks for the PR. The race-condition you describe is certainly odd. |
Just to be sure: any cache includes the fragment, right? |
The fragment cache is here: https://github.com/lycheeverse/lychee/blob/master/lychee-lib/src/utils/fragment_checker.rs The normal request caching logic is here: lychee/lychee-bin/src/commands/check.rs Lines 270 to 310 in a11d515
The full URI (including the fragment) is cached. |
@MichaIng, @mre I was away and so have missed this conversation so far - my comments below:
Made this below code change and verified it is working (file1.html & file1.md changes are noted below)
BTW, the cargo test had succeeded in my case and i didn't encounter the race condition - have run few tests and still couldn't hit the issue and will keep trying. |
If you don't mind, could you open a pull request with your changes similar to how @MichaIng did? It would make review and testing much easier. |
@thiru-appitap Why did you add a |
The empty "#" and "#top" fragments are always valid without related HTML element. Browser will scroll to the top of the page. Hence lychee must not fail on those. Credits go to @thiru-appitap for initial attempt and helping to find missing parts of the implementation. Solves: lycheeverse#1599 Signed-off-by: MichaIng <micha@dietpi.com>
The empty "#" and "#top" fragments are always valid without related HTML element. Browser will scroll to the top of the page. Hence lychee must not fail on those. Credits go to @thiru-appitap for initial attempt and helping to find missing parts of the implementation. Solves: lycheeverse#1599 Signed-off-by: MichaIng <micha@dietpi.com>
The empty "#" and "#top" fragments are always valid without related HTML element. Browser will scroll to the top of the page. Hence lychee must not fail on those. Credits go to @thiru-appitap for initial attempt and helping to find missing parts of the implementation. Solves: lycheeverse#1599 Signed-off-by: MichaIng <micha@dietpi.com>
The empty "#" and "#top" fragments are always valid without related HTML element. Browser will scroll to the top of the page. Hence lychee must not fail on those. Credits go to @thiru-appitap for initial attempt and helping to find missing parts of the implementation. Solves: lycheeverse#1599 Signed-off-by: MichaIng <micha@dietpi.com>
The empty "#" and "#top" fragments are always valid without related HTML element. Browser will scroll to the top of the page. Hence lychee must not fail on those. Credits go to @thiru-appitap for initial attempt and helping to find missing parts of the implementation. Solves: lycheeverse#1599 Signed-off-by: MichaIng <micha@dietpi.com>
The empty "#" and "#top" fragments are always valid without related HTML element. Browser will scroll to the top of the page. Hence lychee must not fail on those. Credits go to @thiru-appitap for initial attempt and helping to find missing parts of the implementation. Solves: lycheeverse#1599 Signed-off-by: MichaIng <micha@dietpi.com>
The empty "#" and "#top" fragments are always valid without related HTML element. Browser will scroll to the top of the page. Hence lychee must not fail on those. Credits go to @thiru-appitap for initial attempt and helping to find missing parts of the implementation. Solves: lycheeverse#1599 Signed-off-by: MichaIng <micha@dietpi.com>
The empty "#" and "#top" fragments are always valid without related HTML element. Browser will scroll to the top of the page. Hence lychee must not fail on those. Credits go to @thiru-appitap for initial attempt and helping to find missing parts of the implementation. Solves: lycheeverse#1599 Signed-off-by: MichaIng <micha@dietpi.com>
The empty "#" and "#top" fragments are always valid without related HTML element. Browser will scroll to the top of the page. Hence lychee must not fail on those. Credits go to @thiru-appitap for initial attempt and helping to find missing parts of the implementation. Solves: lycheeverse#1599 Signed-off-by: MichaIng <micha@dietpi.com>
The empty "#" and "#top" fragments are always valid without related HTML element. Browser will scroll to the top of the page. Hence lychee must not fail on those. Credits go to @thiru-appitap for initial attempt and helping to find missing parts of the implementation. Solves: lycheeverse#1599 Signed-off-by: MichaIng <micha@dietpi.com>
The empty "#" and "#top" fragments are always valid without related HTML element. Browser will scroll to the top of the page. Hence lychee must not fail on those. Credits go to @thiru-appitap for initial attempt and helping to find missing parts of the implementation. Solves: lycheeverse#1599 Signed-off-by: MichaIng <micha@dietpi.com>
@MichaIng |
Currently we see errors like
while the empty fragment
#
is well known to scroll to the top of the page, just like#top
, while the latter can be overwritten, if there is an HTML element withid="top"
. I suggest to succeed the fragment check right away if any of those two special fragments is found.Sadly I could not find a good source in RFCs or similar. Maybe it is just browsers implementing this outside of specs. The empty fragment is very widely used, the
#top
however I found just now, while searching for a related source. It works however well in all browsers I checked: https://stackoverflow.com/a/77560206The text was updated successfully, but these errors were encountered: