mirror of
https://github.com/daledavies/jump.git
synced 2026-02-24 23:30:46 +01:00
Fix Issue #82: ampersand in url in sites.json breaks icon
This commit is contained in:
@@ -18,14 +18,15 @@ use \Jump\Exceptions\APIException;
|
||||
class Icon extends AbstractAPI {
|
||||
|
||||
public function get_output(): string {
|
||||
if (!isset($this->routeparams['siteurl']) || empty($this->routeparams['siteurl'])) {
|
||||
throw new APIException('The siteurl query parameter is not provided or empty');
|
||||
if (!isset($this->routeparams['siteid']) || empty($this->routeparams['siteid'])) {
|
||||
throw new APIException('The siteid query parameter is not provided or empty');
|
||||
}
|
||||
|
||||
$sites = new \Jump\Sites($this->config, $this->cache);
|
||||
|
||||
$siteurl = filter_var($this->routeparams['siteurl'], FILTER_SANITIZE_URL);
|
||||
$site = $sites->get_site_by_url($siteurl);
|
||||
# A site ID can contain lowercase a-z, 0-9 and the "-" (dash) character only.
|
||||
$siteid = preg_replace("/[^a-z0-9-]/", "", $this->routeparams['siteid']);
|
||||
$site = $sites->get_site_by_id($siteid);
|
||||
|
||||
$imagedata = $site->get_favicon_image_data();
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class Main {
|
||||
$this->router->addRoute('/tag/<tag>', [
|
||||
'class' => 'Jump\Pages\TagPage'
|
||||
]);
|
||||
$this->router->addRoute('/api/icon?siteurl=<siteurl>', [
|
||||
$this->router->addRoute('/api/icon?siteid=<siteid>', [
|
||||
'class' => 'Jump\API\Icon'
|
||||
]);
|
||||
$this->router->addRoute('/api/status[/<token>]', [
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<ul class="sites {{# altlayout}}alternate{{/ altlayout}}">
|
||||
{{# sites}}<li id="{{id}}"><a {{# newtab}}target="_blank"{{/ newtab}} rel="{{# nofollow}}nofollow {{/ nofollow}}{{# newtab}}noopener{{/ newtab}}" title="{{description}}" href="{{url}}">
|
||||
<span class="icon">
|
||||
<img src="{{{wwwurl}}}/api/icon?siteurl={{#urlencode}}{{url}}{{/urlencode}}">
|
||||
<img src="{{{wwwurl}}}/api/icon?siteid={{id}}">
|
||||
</span>
|
||||
<span class="name">{{name}}</span>
|
||||
</a></li>{{/ sites}}
|
||||
|
||||
Reference in New Issue
Block a user