[gnome-maps/gnome-3-34] wikipedia: Fix generating encoded URL
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/gnome-3-34] wikipedia: Fix generating encoded URL
- Date: Tue, 29 Oct 2019 21:29:23 +0000 (UTC)
commit 90e5af2554313af07c17114f968519a29d3c421d
Author: Marcus Lundblad <ml update uu se>
Date: Tue Oct 29 22:23:43 2019 +0100
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
src/wikipedia.js | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/wikipedia.js b/src/wikipedia.js
index 52c567d1..f26f9e3f 100644
--- a/src/wikipedia.js
+++ b/src/wikipedia.js
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]