From 265a2c498ec27f205289188664e927bc36329f79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Fri, 27 Jul 2018 02:08:03 +0200 Subject: [PATCH 1/4] [global]: Proxy class has been introduced, need to fix these as well. --- buffer/buffer.php | 7 +++---- curweather/curweather.php | 4 ++-- impressum/impressum.php | 10 +++++----- mastodoncustomemojis/mastodoncustomemojis.php | 3 ++- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/buffer/buffer.php b/buffer/buffer.php index 0f43a0ece..4a8185e04 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -15,6 +15,7 @@ use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Database\DBA; use Friendica\Model\ItemContent; +use Friendica\Network\Proxy; function buffer_install() { @@ -363,14 +364,12 @@ function buffer_send(App $a, array &$b) logger("buffer_send: converted message ".$b["id"]." result: ".print_r($post, true), LOGGER_DEBUG); // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures - require_once "mod/proxy.php"; - if (isset($post["image"])) { - $post["image"] = proxy_url($post["image"]); + $post["image"] = Proxy::proxifyUrl($post["image"]); } if (isset($post["preview"])) { - $post["preview"] = proxy_url($post["preview"]); + $post["preview"] = Proxy::proxifyUrl($post["preview"]); } // Seems like a bug to me diff --git a/curweather/curweather.php b/curweather/curweather.php index 6852ee70f..cfc4fc183 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -9,7 +9,6 @@ * */ -require_once 'mod/proxy.php'; require_once 'include/text.php'; use Friendica\App; @@ -18,6 +17,7 @@ use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; +use Friendica\Network\Proxy; use Friendica\Util\Network; function curweather_install() @@ -138,7 +138,7 @@ function curweather_network_mod_init(App $a, &$b) $t = get_markup_template("widget.tpl", "addon/curweather/" ); $curweather = replace_macros ($t, [ '$title' => L10n::t("Current Weather"), - '$icon' => proxy_url('http://openweathermap.org/img/w/'.$res['icon'].'.png'), + '$icon' => Proxy::proxifyUrl('http://openweathermap.org/img/w/'.$res['icon'].'.png'), '$city' => $res['city'], '$lon' => $res['lon'], '$lat' => $res['lat'], diff --git a/impressum/impressum.php b/impressum/impressum.php index 149b13954..f44f07af9 100644 --- a/impressum/impressum.php +++ b/impressum/impressum.php @@ -7,12 +7,11 @@ * License: 3-clause BSD license */ -require_once 'mod/proxy.php'; - use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; +use Friendica\Network\Proxy; function impressum_install() { Addon::registerHook('load_config', 'addon/impressum/impressum.php', 'impressum_load_config'); @@ -41,7 +40,8 @@ function obfuscate_email ($s) { return $s; } function impressum_footer($a, &$b) { - $text = proxy_parse_html(BBCode::convert(Config::get('impressum','footer_text'))); + $text = Proxy::proxifyHtml(BBCode::convert(Config::get('impressum','footer_text'))); + if (! $text == '') { $a->page['htmlhead'] .= ''; $b .= '
'; @@ -58,8 +58,8 @@ function impressum_show($a,&$b) { $b .= '

'.L10n::t('Impressum').'

'; $owner = Config::get('impressum', 'owner'); $owner_profile = Config::get('impressum','ownerprofile'); - $postal = proxy_parse_html(BBCode::convert(Config::get('impressum', 'postal'))); - $notes = proxy_parse_html(BBCode::convert(Config::get('impressum', 'notes'))); + $postal = Proxy::proxifyHtml(BBCode::convert(Config::get('impressum', 'postal'))); + $notes = Proxy::proxifyHtml(BBCode::convert(Config::get('impressum', 'notes'))); $email = obfuscate_email( Config::get('impressum','email') ); if (strlen($owner)) { if (strlen($owner_profile)) { diff --git a/mastodoncustomemojis/mastodoncustomemojis.php b/mastodoncustomemojis/mastodoncustomemojis.php index 93d0ba65a..9b6667f16 100644 --- a/mastodoncustomemojis/mastodoncustomemojis.php +++ b/mastodoncustomemojis/mastodoncustomemojis.php @@ -14,6 +14,7 @@ use Friendica\Core\Addon; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\Protocol; +use Friendica\Network\Proxy; use Friendica\Util\Network; function mastodoncustomemojis_install() @@ -88,7 +89,7 @@ function mastodoncustomemojis_get_custom_emojis_for_author($author_link) if (is_array($emojis_array)) { foreach ($emojis_array as $emoji) { $emojis['texts'][] = ':' . $emoji['shortcode'] . ':'; - $emojis['icons'][] = ':' . $emoji['shortcode'] . ':'; + $emojis['icons'][] = ':' . $emoji['shortcode'] . ':'; } } From 7032e088f7d314c03f02bf6f3dd927dc5e66cfb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Sat, 28 Jul 2018 01:19:29 +0200 Subject: [PATCH 2/4] [global] Moved to Module\Proxy --- buffer/buffer.php | 2 +- curweather/curweather.php | 2 +- impressum/impressum.php | 2 +- mastodoncustomemojis/mastodoncustomemojis.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/buffer/buffer.php b/buffer/buffer.php index 4a8185e04..c0a06d068 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -15,7 +15,7 @@ use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Database\DBA; use Friendica\Model\ItemContent; -use Friendica\Network\Proxy; +use Friendica\Module\Proxy; function buffer_install() { diff --git a/curweather/curweather.php b/curweather/curweather.php index cfc4fc183..6c8efa763 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -17,7 +17,7 @@ use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; -use Friendica\Network\Proxy; +use Friendica\Module\Proxy; use Friendica\Util\Network; function curweather_install() diff --git a/impressum/impressum.php b/impressum/impressum.php index f44f07af9..64dcf1e0f 100644 --- a/impressum/impressum.php +++ b/impressum/impressum.php @@ -11,7 +11,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; -use Friendica\Network\Proxy; +use Friendica\Module\Proxy; function impressum_install() { Addon::registerHook('load_config', 'addon/impressum/impressum.php', 'impressum_load_config'); diff --git a/mastodoncustomemojis/mastodoncustomemojis.php b/mastodoncustomemojis/mastodoncustomemojis.php index 9b6667f16..079477e45 100644 --- a/mastodoncustomemojis/mastodoncustomemojis.php +++ b/mastodoncustomemojis/mastodoncustomemojis.php @@ -14,7 +14,7 @@ use Friendica\Core\Addon; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\Protocol; -use Friendica\Network\Proxy; +use Friendica\Module\Proxy; use Friendica\Util\Network; function mastodoncustomemojis_install() From e269589c65b990e5822c559fa2e6ca66f79eb327 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Sat, 28 Jul 2018 20:24:16 +0200 Subject: [PATCH 3/4] [global] CR request: Moved proxify*() methods to separate class --- buffer/buffer.php | 6 +++--- curweather/curweather.php | 4 ++-- impressum/impressum.php | 8 ++++---- mastodoncustomemojis/mastodoncustomemojis.php | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/buffer/buffer.php b/buffer/buffer.php index c0a06d068..69b313ede 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -15,7 +15,7 @@ use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Database\DBA; use Friendica\Model\ItemContent; -use Friendica\Module\Proxy; +use Friendica\Util\ProxyUtils; function buffer_install() { @@ -365,11 +365,11 @@ function buffer_send(App $a, array &$b) // The image proxy is used as a sanitizer. Buffer seems to be really picky about pictures if (isset($post["image"])) { - $post["image"] = Proxy::proxifyUrl($post["image"]); + $post["image"] = ProxyUtils::proxifyUrl($post["image"]); } if (isset($post["preview"])) { - $post["preview"] = Proxy::proxifyUrl($post["preview"]); + $post["preview"] = ProxyUtils::proxifyUrl($post["preview"]); } // Seems like a bug to me diff --git a/curweather/curweather.php b/curweather/curweather.php index 6c8efa763..c3abba16e 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -17,8 +17,8 @@ use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; -use Friendica\Module\Proxy; use Friendica\Util\Network; +use Friendica\Util\ProxyUtils; function curweather_install() { @@ -138,7 +138,7 @@ function curweather_network_mod_init(App $a, &$b) $t = get_markup_template("widget.tpl", "addon/curweather/" ); $curweather = replace_macros ($t, [ '$title' => L10n::t("Current Weather"), - '$icon' => Proxy::proxifyUrl('http://openweathermap.org/img/w/'.$res['icon'].'.png'), + '$icon' => ProxyUtils::proxifyUrl('http://openweathermap.org/img/w/'.$res['icon'].'.png'), '$city' => $res['city'], '$lon' => $res['lon'], '$lat' => $res['lat'], diff --git a/impressum/impressum.php b/impressum/impressum.php index 64dcf1e0f..8177c0803 100644 --- a/impressum/impressum.php +++ b/impressum/impressum.php @@ -11,7 +11,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; -use Friendica\Module\Proxy; +use Friendica\Util\ProxyUtils; function impressum_install() { Addon::registerHook('load_config', 'addon/impressum/impressum.php', 'impressum_load_config'); @@ -40,7 +40,7 @@ function obfuscate_email ($s) { return $s; } function impressum_footer($a, &$b) { - $text = Proxy::proxifyHtml(BBCode::convert(Config::get('impressum','footer_text'))); + $text = ProxyUtils::proxifyHtml(BBCode::convert(Config::get('impressum','footer_text'))); if (! $text == '') { $a->page['htmlhead'] .= ''; @@ -58,8 +58,8 @@ function impressum_show($a,&$b) { $b .= '

'.L10n::t('Impressum').'

'; $owner = Config::get('impressum', 'owner'); $owner_profile = Config::get('impressum','ownerprofile'); - $postal = Proxy::proxifyHtml(BBCode::convert(Config::get('impressum', 'postal'))); - $notes = Proxy::proxifyHtml(BBCode::convert(Config::get('impressum', 'notes'))); + $postal = ProxyUtils::proxifyHtml(BBCode::convert(Config::get('impressum', 'postal'))); + $notes = ProxyUtils::proxifyHtml(BBCode::convert(Config::get('impressum', 'notes'))); $email = obfuscate_email( Config::get('impressum','email') ); if (strlen($owner)) { if (strlen($owner_profile)) { diff --git a/mastodoncustomemojis/mastodoncustomemojis.php b/mastodoncustomemojis/mastodoncustomemojis.php index 079477e45..b9214d8e7 100644 --- a/mastodoncustomemojis/mastodoncustomemojis.php +++ b/mastodoncustomemojis/mastodoncustomemojis.php @@ -14,8 +14,8 @@ use Friendica\Core\Addon; use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\Protocol; -use Friendica\Module\Proxy; use Friendica\Util\Network; +use Friendica\Util\ProxyUtils; function mastodoncustomemojis_install() { @@ -89,7 +89,7 @@ function mastodoncustomemojis_get_custom_emojis_for_author($author_link) if (is_array($emojis_array)) { foreach ($emojis_array as $emoji) { $emojis['texts'][] = ':' . $emoji['shortcode'] . ':'; - $emojis['icons'][] = ':' . $emoji['shortcode'] . ':'; + $emojis['icons'][] = ':' . $emoji['shortcode'] . ':'; } } From 9695138ba11e428b62a95d93f9d14ad8c7b3991f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roland=20H=C3=A4der?= Date: Tue, 31 Jul 2018 03:20:29 +0200 Subject: [PATCH 4/4] [global] Renamed class ProxyUtils -> Proxy and aliased it back to ProxyUtils --- buffer/buffer.php | 2 +- curweather/curweather.php | 2 +- impressum/impressum.php | 2 +- mastodoncustomemojis/mastodoncustomemojis.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/buffer/buffer.php b/buffer/buffer.php index 69b313ede..c7f3cd35d 100644 --- a/buffer/buffer.php +++ b/buffer/buffer.php @@ -15,7 +15,7 @@ use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Database\DBA; use Friendica\Model\ItemContent; -use Friendica\Util\ProxyUtils; +use Friendica\Util\Proxy as ProxyUtils; function buffer_install() { diff --git a/curweather/curweather.php b/curweather/curweather.php index c3abba16e..044f5a154 100644 --- a/curweather/curweather.php +++ b/curweather/curweather.php @@ -18,7 +18,7 @@ use Friendica\Core\Config; use Friendica\Core\L10n; use Friendica\Core\PConfig; use Friendica\Util\Network; -use Friendica\Util\ProxyUtils; +use Friendica\Util\Proxy as ProxyUtils; function curweather_install() { diff --git a/impressum/impressum.php b/impressum/impressum.php index 8177c0803..b7cf64e40 100644 --- a/impressum/impressum.php +++ b/impressum/impressum.php @@ -11,7 +11,7 @@ use Friendica\Content\Text\BBCode; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; -use Friendica\Util\ProxyUtils; +use Friendica\Util\Proxy as ProxyUtils; function impressum_install() { Addon::registerHook('load_config', 'addon/impressum/impressum.php', 'impressum_load_config'); diff --git a/mastodoncustomemojis/mastodoncustomemojis.php b/mastodoncustomemojis/mastodoncustomemojis.php index b9214d8e7..2502344af 100644 --- a/mastodoncustomemojis/mastodoncustomemojis.php +++ b/mastodoncustomemojis/mastodoncustomemojis.php @@ -15,7 +15,7 @@ use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\Protocol; use Friendica\Util\Network; -use Friendica\Util\ProxyUtils; +use Friendica\Util\Proxy as ProxyUtils; function mastodoncustomemojis_install() {