[gnome-maps] wikipedia: Fix generating encoded URL



commit 082c63b50fb44e4eb94c4fc596e20e37338791e3
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 f954d8c2..48e231c1 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]