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 suggestion links with single quotes (and other special symbols) #860

Merged
merged 3 commits into from
Dec 21, 2022

Conversation

veloman-yunkan
Copy link
Collaborator

@veloman-yunkan veloman-yunkan commented Dec 15, 2022

This is a follow-up of #859.

Should fix kiwix/kiwix-tools#589

This PR fixes suggestion links in the presence of special symbols such as ' (a single quote), ? (a question mark), and/or # (hash) in the root location (value of the --urlRootLocation option of kiwix-serve), book name or article name.

@codecov
Copy link

codecov bot commented Dec 15, 2022

Codecov Report

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

Coverage data is based on head (f3d2f47) compared to base (a10067e).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #860   +/-   ##
=======================================
  Coverage   71.41%   71.41%           
=======================================
  Files          53       53           
  Lines        3740     3740           
  Branches     2089     2077   -12     
=======================================
  Hits         2671     2671           
  Misses       1067     1067           
  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.

@kelson42 kelson42 added this to the 12.1.0 milestone Dec 15, 2022
@veloman-yunkan veloman-yunkan changed the title Handling of suggestion links with single quotes Handling of suggestion links with single quotes (and other special symbols) Dec 17, 2022
This change fixes two issues:

1. Presence of URL-specific special symbols (such as ? or #) in the book
   and/or article name resulted in a wrong suggestion link. This is
   fixed by URI-encoding the book name and the path, too.

2. Presence of a single quote symbol in the book and/or article name
   resulted in invalid javascript code in the href attribute of the
   suggestion link.

   The single quote (') symbol is not URL-encoded (unlike its double quote
   counterpart). As a result, enclosing a URL-encoded string in single
   quotes may result in invalid javascript. Using double quotes instead is
   safe, since both double quote (") and backslash (\) symbols (which are
   the only special symbols for such quoting) undergo URL-encoding.
@veloman-yunkan veloman-yunkan force-pushed the handling_of_suggestion_links_with_single_quotes branch from fdbb4d0 to f3d2f47 Compare December 17, 2022 14:50
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.

I now know why people use js framework instead of reimplementing everything themselves :)

@mgautierfr mgautierfr merged commit 90318df into master Dec 21, 2022
@mgautierfr mgautierfr deleted the handling_of_suggestion_links_with_single_quotes branch December 21, 2022 11:03
This pull request was closed.
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.

Question mark in article title caused broser to report "The page isn’t redirecting properly"
3 participants