{"action":"created","issue":{"url":"https://api.github.com/repos/getpelican/pelican/issues/2260","repository_url":"https://api.github.com/repos/getpelican/pelican","labels_url":"https://api.github.com/repos/getpelican/pelican/issues/2260/labels{/name}","comments_url":"https://api.github.com/repos/getpelican/pelican/issues/2260/comments","events_url":"https://api.github.com/repos/getpelican/pelican/issues/2260/events","html_url":"https://github.com/getpelican/pelican/pull/2260","id":280844548,"number":2260,"title":"Escape special HTML chars coming from SITEURL in the internal link replacer","user":{"login":"mosra","id":344828,"avatar_url":"https://avatars3.githubusercontent.com/u/344828?v=4","gravatar_id":"","url":"https://api.github.com/users/mosra","html_url":"https://github.com/mosra","followers_url":"https://api.github.com/users/mosra/followers","following_url":"https://api.github.com/users/mosra/following{/other_user}","gists_url":"https://api.github.com/users/mosra/gists{/gist_id}","starred_url":"https://api.github.com/users/mosra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mosra/subscriptions","organizations_url":"https://api.github.com/users/mosra/orgs","repos_url":"https://api.github.com/users/mosra/repos","events_url":"https://api.github.com/users/mosra/events{/privacy}","received_events_url":"https://api.github.com/users/mosra/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/getpelican/pelican/milestones/12","html_url":"https://github.com/getpelican/pelican/milestone/12","labels_url":"https://api.github.com/repos/getpelican/pelican/milestones/12/labels","id":2242117,"number":12,"title":"3.8.0","description":"","creator":{"login":"justinmayer","id":1503700,"avatar_url":"https://avatars2.githubusercontent.com/u/1503700?v=4","gravatar_id":"","url":"https://api.github.com/users/justinmayer","html_url":"https://github.com/justinmayer","followers_url":"https://api.github.com/users/justinmayer/followers","following_url":"https://api.github.com/users/justinmayer/following{/other_user}","gists_url":"https://api.github.com/users/justinmayer/gists{/gist_id}","starred_url":"https://api.github.com/users/justinmayer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinmayer/subscriptions","organizations_url":"https://api.github.com/users/justinmayer/orgs","repos_url":"https://api.github.com/users/justinmayer/repos","events_url":"https://api.github.com/users/justinmayer/events{/privacy}","received_events_url":"https://api.github.com/users/justinmayer/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":20,"state":"open","created_at":"2017-01-10T21:49:16Z","updated_at":"2018-02-08T15:44:41Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2017-12-10T21:02:57Z","updated_at":"2018-02-08T15:44:50Z","closed_at":null,"author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/getpelican/pelican/pulls/2260","html_url":"https://github.com/getpelican/pelican/pull/2260","diff_url":"https://github.com/getpelican/pelican/pull/2260.diff","patch_url":"https://github.com/getpelican/pelican/pull/2260.patch"},"body":"When `SITEURL` (or any other URL such as `PAGE_URL`, `ARTICLE_URL` etc.) contains special HTML characters such as `&`, they were not properly escaped when going through the link replacer. \r\n\r\nA convoluted example: when `SITEURL = 'http://my.site/?app=\"blog\"&path='` and there's the following input:\r\n\r\n```html\r\n<a href=\"{filename}/article.rst\">An article</a>\r\n```\r\n\r\nThe following gets rendered:\r\n\r\n```html\r\n<a href=\"http://my.site/?app=\"blog\"&path=/article.rst\">An article</a>\r\n```\r\n\r\nWhich is wrong and should be instead\r\n\r\n```html\r\n<a href=\"http://my.site/?app=&quot;blog&quot;&amp;path=/article.rst\">An article</a>\r\n```\r\n\r\nWhile the Jinja2 template itself usually takes care of escaping `SITEURL` where it is used in the template, this link replacement is done after that and thus there's no way around it.\r\n\r\nThe patch takes care of properly unescaping the other URL parts and then escaping them again so they get preserved. There's a test case checking that as well.\r\n\r\nSimilarly to #2196, this is based on https://github.com/getpelican/pelican/pull/2196/commits/1f30306e2329e5a1f0c5dd39844d9bb0a0c04573, which just makes the internal link replacer function public. See #2164 for the original reason behind this change.\r\n\r\nThanks in advance! :)"},"comment":{"url":"https://api.github.com/repos/getpelican/pelican/issues/comments/364152387","html_url":"https://github.com/getpelican/pelican/pull/2260#issuecomment-364152387","issue_url":"https://api.github.com/repos/getpelican/pelican/issues/2260","id":364152387,"user":{"login":"justinmayer","id":1503700,"avatar_url":"https://avatars2.githubusercontent.com/u/1503700?v=4","gravatar_id":"","url":"https://api.github.com/users/justinmayer","html_url":"https://github.com/justinmayer","followers_url":"https://api.github.com/users/justinmayer/followers","following_url":"https://api.github.com/users/justinmayer/following{/other_user}","gists_url":"https://api.github.com/users/justinmayer/gists{/gist_id}","starred_url":"https://api.github.com/users/justinmayer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinmayer/subscriptions","organizations_url":"https://api.github.com/users/justinmayer/orgs","repos_url":"https://api.github.com/users/justinmayer/repos","events_url":"https://api.github.com/users/justinmayer/events{/privacy}","received_events_url":"https://api.github.com/users/justinmayer/received_events","type":"User","site_admin":false},"created_at":"2018-02-08T15:44:50Z","updated_at":"2018-02-08T15:44:50Z","author_association":"OWNER","body":"My admittedly cursory scan of this pull request didn't yield any glaring problems. Any @getpelican/reviewers care to comment before this is merged?"}}
{"actor":{"display_login":"justinmayer"}}