Commit 90e5af25 authored by Marcus Lundblad's avatar Marcus Lundblad

wikipedia: Fix generating encoded URL

The URL encoding didn't handle ' correctly.
Change to use regular URI encoding for the
the Wikipedia URLs and HTML entity encoding
for the parameters for the thumbnail API.

Fixes #230
parent 6d4dcce7
Pipeline #127102 passed with stages
in 9 minutes and 7 seconds
......@@ -43,6 +43,11 @@ function getLanguage(wiki) {
}
function getArticle(wiki) {
return Soup.uri_encode(wiki.replace(/ /g, '_').split(':').splice(1).join(':'),
'\'');
}
function getHtmlEntityEncodedArticle(wiki) {
return GLib.markup_escape_text(wiki.split(':').splice(1).join(':'), -1);
}
......@@ -53,7 +58,7 @@ function getArticle(wiki) {
*/
function fetchArticleThumbnail(wiki, size, callback) {
let lang = getLanguage(wiki);
let title = getArticle(wiki);
let title = getHtmlEntityEncodedArticle(wiki);
let uri = Format.vprintf('https://%s.wikipedia.org/w/api.php', [ lang ]);
let msg = Soup.form_request_new_from_hash('GET', uri, { action: 'query',
titles: title,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment