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

Safe href in suggestion links for the iframe-based viewer #859

Merged
merged 1 commit into from
Dec 14, 2022

Conversation

veloman-yunkan
Copy link
Collaborator

Addresses kiwix/kiwix-tools#587 with respect to suggestions in the iframe-based viewer.

The value of the href attributed is assumed to always be a URI-encoded string that has to be decoded. This is true for URLs with javascript: scheme too.

The following example demonstrates the problem

<!DOCTYPE html>
<html>
  <head>
    <script>
      function foo() { alert('A%26B'); }
    </script>
  </head>
  <body>
    <a href="javascript:alert('A%26B)">Inline javascript.</a>
    <a href="javascript:foo()">Out-of-line javascript</a>
  </body>
</html>

Invoking inline javascript via the first link displays URL-decoded text ("A&B"). Running out-of-line javascript via the second link display the text as is ("A%26B").

This means that suggestion links in the iframe-based viewer that work via javascript need a second level of URL-encoding.

@codecov
Copy link

codecov bot commented Dec 12, 2022

Codecov Report

Base: 71.04% // Head: 71.04% // No change to project coverage 👍

Coverage data is based on head (99f24eb) compared to base (6790a14).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #859   +/-   ##
=======================================
  Coverage   71.04%   71.04%           
=======================================
  Files          53       53           
  Lines        3685     3685           
  Branches     2058     2058           
=======================================
  Hits         2618     2618           
  Misses       1065     1065           
  Partials        2        2           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@mgautierfr mgautierfr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tricky bug.
LGTM

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.

None yet

2 participants