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

Handling of protocol relative external urls in zimcheck #307

Merged
merged 3 commits into from
Jul 5, 2022

Conversation

veloman-yunkan
Copy link
Collaborator

Should fix #305

@codecov
Copy link

codecov bot commented Jul 2, 2022

Codecov Report

Merging #307 (3c5c32e) into master (92fc9c7) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #307      +/-   ##
==========================================
+ Coverage   51.13%   51.18%   +0.05%     
==========================================
  Files          21       21              
  Lines        1942     1944       +2     
  Branches     1151     1152       +1     
==========================================
+ Hits          993      995       +2     
  Misses        947      947              
  Partials        2        2              
Impacted Files Coverage Δ
src/tools.h 37.83% <ø> (ø)
src/tools.cpp 86.59% <100.00%> (+0.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92fc9c7...3c5c32e. Read the comment docs.

@veloman-yunkan
Copy link
Collaborator Author

@kelson42 I am glad that this PR made you laugh, but I wonder what you find so funny about it? 🤔

@kelson42
Copy link
Contributor

kelson42 commented Jul 3, 2022

@veloman-yunkan My bad. Wrong emoticon. Was just happy to see a fix finally released.

src/tools.cpp Show resolved Hide resolved
zimcheck treats protocol-relative absolute URLs as relative URLs. This
bug is demonstrated by enhanced test data (which makes the zimcheck test
fail). Bugfix coming in the next commit.

The test data was enhanced in the following ways:

- Added external links in main.html. The protocol-relative variant
  (//openzim.org) is the one that breaks the tests. The mismatch
  in the test output demonstrates that the absolute link //openzim.org
  is treated as an internal link:

```
[ RUN      ] zimcheck.internal_url_check_poorzimfile
.../test/zimcheck-test.cpp:249: Failure
Expected equality of these values:
  expected_stdout
    Which is: ...
  std::string(zimcheck_output)
    Which is: ...
With diff:
@@ +7,23 @@
 (A/non_existent.html) were not found in article dangling_link.html
   Found 1 empty links in article: empty_link.html
+  The following links:
+- //openzim.org
+(openzim.org) were not found in article empty_link.html
+  The following links:
+- //openzim.org
+(openzim.org) were not found in article external_image_http.html
+  The following links:
+- //openzim.org
+(openzim.org) were not found in article external_image_https.html
+  The following links:
+- //a.io/pic.png
+(a.io/pic.png) were not found in article external_image_protocol_relative.html
+  The following links:
+- //openzim.org
+(openzim.org) were not found in article main.html
   ../../oops.html is out of bounds. Article: outofbounds_link.html
+  The following links:
+- //openzim.org
+(openzim.org) were not found in article outofbounds_link.html
 [INFO] Overall Test Status: Fail
 [INFO] Total time taken by zimcheck: <3 seconds.\n

Test context:
 zimcheck -u data/zimfiles/poor.zim

[  FAILED  ] zimcheck.internal_url_check_poorzimfile
```

- Added an image with inline data. This change only increases the
  functional coverage of zimcheck testing.

- In poor.zim, added three (http, https and protocol-relative) variants
  of absolute referenes to an external image. The mismatch in the test
  output demonstrates that the protocol-relative variant is not reported:

```
[ RUN      ] zimcheck.external_url_check_poorzimfile
.../test/zimcheck-test.cpp:249: Failure
Expected equality of these values:
  expected_stdout
    Which is: ...
  std::string(zimcheck_output)
    Which is: ...
With diff:
@@ -5,5 @@
   http://a.io/pic.png is an external dependence in article external_image_http.html
   https://a.io/pic.png is an external dependence in article external_image_https.html
-  //a.io/pic.png is an external dependence in article external_image_protocol_relative.html
 [INFO] Overall Test Status: Fail
 [INFO] Total time taken by zimcheck: <3 seconds.\n

Test context:
 zimcheck -x data/zimfiles/poor.zim

[  FAILED  ] zimcheck.external_url_check_poorzimfile (1 ms)
```

Also:
 - In create_test_zimfiles script, replaced the obsolete option -f
   of zimwriterfs with a new option -I.
This change fixes the bug demonstrated by the previous commit.
@veloman-yunkan veloman-yunkan force-pushed the zimcheck_protocol_relative_external_urls branch from ee78b4b to 3c5c32e Compare July 5, 2022 13:29
@mgautierfr mgautierfr merged commit 89b0ae0 into master Jul 5, 2022
@mgautierfr mgautierfr deleted the zimcheck_protocol_relative_external_urls branch July 5, 2022 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Core dump checking latest stackoverflow
3 participants