From 9ff228812f0b0d565d8c0fc50f567d31ebd7ad08 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 13 Sep 2020 19:33:57 -0400 Subject: [PATCH 1/8] Normalize item location template variable name --- include/conversation.php | 15 ++------------- src/Object/Post.php | 5 ++--- view/templates/search_item.tpl | 2 +- view/templates/wall_thread.tpl | 2 +- view/theme/frio/templates/search_item.tpl | 6 +++--- view/theme/frio/templates/wall_thread.tpl | 8 ++++---- view/theme/quattro/templates/search_item.tpl | 2 +- view/theme/quattro/templates/wall_item_tag.tpl | 2 +- view/theme/quattro/templates/wall_thread.tpl | 2 +- view/theme/smoothly/templates/search_item.tpl | 2 +- view/theme/smoothly/templates/wall_thread.tpl | 2 +- view/theme/vier/templates/search_item.tpl | 2 +- view/theme/vier/templates/wall_item_tag.tpl | 2 +- view/theme/vier/templates/wall_thread.tpl | 2 +- 14 files changed, 21 insertions(+), 33 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index a995ea4ad1..6bf511a6bc 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -546,8 +546,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => '']; Hook::callAll('render_location',$locate); - - $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate)); + $location_html = $locate['html'] ?: Strings::escapeHtml($locate['location'] ?: $locate['coord'] ?: ''); localize_item($item); if ($mode === 'network-new') { @@ -616,7 +615,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'text' => strip_tags($body), 'localtime' => DateTimeFormat::local($item['created'], 'r'), 'ago' => (($item['app']) ? DI::l10n()->t('%s from %s', Temporal::getRelativeDate($item['created']),$item['app']) : Temporal::getRelativeDate($item['created'])), - 'location' => $location, + 'location_html' => $location_html, 'indent' => '', 'owner_name' => $owner_name, 'owner_url' => $owner_url, @@ -1497,13 +1496,3 @@ function sort_thr_commented(array $a, array $b) { return strcmp($b['commented'], $a['commented']); } - -function render_location_dummy(array $item) { - if (!empty($item['location']) && !empty($item['location'])) { - return $item['location']; - } - - if (!empty($item['coord']) && !empty($item['coord'])) { - return $item['coord']; - } -} diff --git a/src/Object/Post.php b/src/Object/Post.php index d9f0d44d67..f5e91c07c5 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -254,7 +254,7 @@ class Post $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => '']; Hook::callAll('render_location', $locate); - $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate)); + $location_html = $locate['html'] ?: Strings::escapeHtml($locate['location'] ?: $locate['coord'] ?: ''); // process action responses - e.g. like/dislike/attend/agree/whatever $response_verbs = ['like', 'dislike', 'announce']; @@ -371,7 +371,6 @@ class Post $title_e = $item['title']; } - $location_e = $location; $owner_name_e = $this->getOwnerName(); if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) { @@ -457,7 +456,7 @@ class Post 'app' => $item['app'], 'created' => $ago, 'lock' => $lock, - 'location' => $location_e, + 'location_html' => $location_html, 'indent' => $indent, 'shiny' => $shiny, 'owner_self' => $item['author-link'] == Session::get('my_url'), diff --git a/view/templates/search_item.tpl b/view/templates/search_item.tpl index 1a756db8a3..82db4884c6 100644 --- a/view/templates/search_item.tpl +++ b/view/templates/search_item.tpl @@ -19,7 +19,7 @@
{{if $item.lock}}
{{$item.lock}}
{{else}}
{{/if}} -
{{$item.location nofilter}}
+
{{$item.location_html nofilter}}
diff --git a/view/templates/wall_thread.tpl b/view/templates/wall_thread.tpl index bd8a1a2309..13b358b520 100644 --- a/view/templates/wall_thread.tpl +++ b/view/templates/wall_thread.tpl @@ -48,7 +48,7 @@
{{if $item.lock}}
{{$item.lock}}
{{else}}
{{/if}} -
{{$item.location nofilter}}
+
{{$item.location_html nofilter}}
diff --git a/view/theme/frio/templates/search_item.tpl b/view/theme/frio/templates/search_item.tpl index 2cd231f8fb..e48a12b50b 100644 --- a/view/theme/frio/templates/search_item.tpl +++ b/view/theme/frio/templates/search_item.tpl @@ -66,9 +66,9 @@ {{$item.ago}}
- {{if $item.location}} + {{if $item.location_html}}
- ({{$item.location nofilter}}) + ({{$item.location_html nofilter}})
{{/if}} @@ -81,7 +81,7 @@
{{$item.name}}

- {{$item.ago}} {{if $item.location}} — ({{$item.location nofilter}}){{/if}} + {{$item.ago}} {{if $item.location_html}} — ({{$item.location_html nofilter}}){{/if}}

diff --git a/view/theme/frio/templates/wall_thread.tpl b/view/theme/frio/templates/wall_thread.tpl index 81532f943c..2b285456a9 100644 --- a/view/theme/frio/templates/wall_thread.tpl +++ b/view/theme/frio/templates/wall_thread.tpl @@ -186,9 +186,9 @@ as the value of $top_child_total (this is done at the end of this file) - {{if $item.location}} + {{if $item.location_html}}
- ({{$item.location nofilter}}) + ({{$item.location_html nofilter}})
{{/if}} @@ -202,7 +202,7 @@ as the value of $top_child_total (this is done at the end of this file)

{{$item.ago}} - {{if $item.location}} — ({{$item.location nofilter}}){{/if}} + {{if $item.location_html}} — ({{$item.location_html nofilter}}){{/if}} {{if $item.owner_self}} {{include file="sub/delivery_count.tpl" delivery=$item.delivery}} {{/if}} @@ -221,7 +221,7 @@ as the value of $top_child_total (this is done at the end of this file) {{$item.ago}} - {{if $item.location}} — ({{$item.location nofilter}}){{/if}} + {{if $item.location_html}} — ({{$item.location_html nofilter}}){{/if}} {{if $item.owner_self}} {{include file="sub/delivery_count.tpl" delivery=$item.delivery}} {{/if}} diff --git a/view/theme/quattro/templates/search_item.tpl b/view/theme/quattro/templates/search_item.tpl index cb400ac4f5..be9a43604a 100644 --- a/view/theme/quattro/templates/search_item.tpl +++ b/view/theme/quattro/templates/search_item.tpl @@ -19,7 +19,7 @@ -

{{$item.location nofilter}}
+
{{$item.location_html nofilter}}
{{if $item.title}}

{{$item.title}}

{{/if}} diff --git a/view/theme/quattro/templates/wall_item_tag.tpl b/view/theme/quattro/templates/wall_item_tag.tpl index cb4b890153..e957e719a6 100644 --- a/view/theme/quattro/templates/wall_item_tag.tpl +++ b/view/theme/quattro/templates/wall_item_tag.tpl @@ -34,7 +34,7 @@
-
{{$item.location nofilter}}
+
{{$item.location_html nofilter}}
{{$item.ago}} {{$item.body nofilter}} diff --git a/view/theme/quattro/templates/wall_thread.tpl b/view/theme/quattro/templates/wall_thread.tpl index 21de7db2df..7c8a567835 100644 --- a/view/theme/quattro/templates/wall_thread.tpl +++ b/view/theme/quattro/templates/wall_thread.tpl @@ -50,7 +50,7 @@
{{/if}} -
{{$item.location nofilter}}
+
{{$item.location_html nofilter}}
{{if $item.title}}

{{$item.title}}

{{/if}} diff --git a/view/theme/smoothly/templates/search_item.tpl b/view/theme/smoothly/templates/search_item.tpl index b3ae01eb4e..284264f29b 100644 --- a/view/theme/smoothly/templates/search_item.tpl +++ b/view/theme/smoothly/templates/search_item.tpl @@ -15,7 +15,7 @@
-
{{if $item.location}}{{$item.location nofilter}} {{/if}}
+
{{if $item.location_html}}{{$item.location_html nofilter}} {{/if}}
{{if $item.lock}}
{{$item.lock}}
diff --git a/view/theme/smoothly/templates/wall_thread.tpl b/view/theme/smoothly/templates/wall_thread.tpl index 4ff34aed11..99d7020539 100644 --- a/view/theme/smoothly/templates/wall_thread.tpl +++ b/view/theme/smoothly/templates/wall_thread.tpl @@ -37,7 +37,7 @@
-
{{if $item.location}}{{$item.location nofilter}} {{/if}}
+
{{if $item.location_html}}{{$item.location_html nofilter}} {{/if}}
{{if $item.lock}} diff --git a/view/theme/vier/templates/search_item.tpl b/view/theme/vier/templates/search_item.tpl index 1da18b0867..1ab47844cc 100644 --- a/view/theme/vier/templates/search_item.tpl +++ b/view/theme/vier/templates/search_item.tpl @@ -51,7 +51,7 @@
-
{{$item.location nofilter}} 
+
{{$item.location_html nofilter}} 
{{if $item.star}} diff --git a/view/theme/vier/templates/wall_item_tag.tpl b/view/theme/vier/templates/wall_item_tag.tpl index 49fb26a83c..eedc51bf17 100644 --- a/view/theme/vier/templates/wall_item_tag.tpl +++ b/view/theme/vier/templates/wall_item_tag.tpl @@ -34,7 +34,7 @@
-
{{$item.location nofilter}}
+
{{$item.location_html nofilter}}
{{$item.ago}} {{$item.body nofilter}} diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl index e52aab1814..60f0c796cb 100644 --- a/view/theme/vier/templates/wall_thread.tpl +++ b/view/theme/vier/templates/wall_thread.tpl @@ -150,7 +150,7 @@ {{/if}}
-
{{$item.location nofilter}} {{$item.postopts}}
+
{{$item.location_html nofilter}} {{$item.postopts}}
From 2bfd53bf092cd97ad96df9406b40b16362a56fc9 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 13 Sep 2020 19:37:43 -0400 Subject: [PATCH 2/8] Normalize item body template variable name --- include/conversation.php | 6 +++--- src/Object/Post.php | 9 ++++----- view/templates/search_item.tpl | 2 +- view/templates/wall_thread.tpl | 2 +- view/theme/frio/templates/search_item.tpl | 2 +- view/theme/frio/templates/wall_thread.tpl | 2 +- view/theme/quattro/templates/search_item.tpl | 2 +- view/theme/quattro/templates/wall_item_tag.tpl | 2 +- view/theme/quattro/templates/wall_thread.tpl | 2 +- view/theme/smoothly/templates/search_item.tpl | 2 +- view/theme/smoothly/templates/wall_thread.tpl | 2 +- view/theme/vier/templates/search_item.tpl | 2 +- view/theme/vier/templates/wall_item_tag.tpl | 2 +- view/theme/vier/templates/wall_thread.tpl | 2 +- 14 files changed, 19 insertions(+), 20 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 6bf511a6bc..fd7303fa46 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -576,7 +576,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o unset($likebuttons['dislike']); } - $body = Item::prepareBody($item, true, $preview); + $body_html = Item::prepareBody($item, true, $preview); list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item); @@ -601,7 +601,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'lock' => $lock, 'thumb' => DI::baseUrl()->remove($item['author-avatar']), 'title' => $title, - 'body' => $body, + 'body_html' => $body_html, 'tags' => $tags['tags'], 'hashtags' => $tags['hashtags'], 'mentions' => $tags['mentions'], @@ -612,7 +612,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'has_folders' => ((count($folders)) ? 'true' : ''), 'categories' => $categories, 'folders' => $folders, - 'text' => strip_tags($body), + 'text' => strip_tags($body_html), 'localtime' => DateTimeFormat::local($item['created'], 'r'), 'ago' => (($item['app']) ? DI::l10n()->t('%s from %s', Temporal::getRelativeDate($item['created']),$item['app']) : Temporal::getRelativeDate($item['created'])), 'location_html' => $location_html, diff --git a/src/Object/Post.php b/src/Object/Post.php index f5e91c07c5..8176233092 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -357,13 +357,12 @@ class Post localize_item($item); - $body = Item::prepareBody($item, true); + $body_html = Item::prepareBody($item, true); list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item); - $body_e = $body; - $text_e = strip_tags($body); $name_e = $profile_name; + $text = strip_tags($body_html); if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) { $title_e = ucfirst($item['content-warning']); @@ -432,8 +431,8 @@ class Post 'has_folders' => ((count($folders)) ? 'true' : ''), 'categories' => $categories, 'folders' => $folders, - 'body' => $body_e, - 'text' => $text_e, + 'body_html' => $body_html, + 'text' => $text, 'id' => $this->getId(), 'guid' => urlencode($item['guid']), 'isevent' => $isevent, diff --git a/view/templates/search_item.tpl b/view/templates/search_item.tpl index 82db4884c6..32d1823ca5 100644 --- a/view/templates/search_item.tpl +++ b/view/templates/search_item.tpl @@ -30,7 +30,7 @@
{{$item.title}}
-
{{$item.body nofilter}}
+
{{$item.body_html nofilter}}
{{if $item.has_cats}}
{{$item.txt_cats}} {{foreach $item.categories as $cat}}{{$cat.name}}{{if $cat.removeurl}} [{{$remove}}]{{/if}} {{if $cat.last}}{{else}}, {{/if}}{{/foreach}}
diff --git a/view/templates/wall_thread.tpl b/view/templates/wall_thread.tpl index 13b358b520..c805a2921e 100644 --- a/view/templates/wall_thread.tpl +++ b/view/templates/wall_thread.tpl @@ -58,7 +58,7 @@
{{$item.title}}
-
{{$item.body nofilter}} +
{{$item.body_html nofilter}}
{{if !$item.suppress_tags}} {{foreach $item.tags as $tag}} diff --git a/view/theme/frio/templates/search_item.tpl b/view/theme/frio/templates/search_item.tpl index e48a12b50b..bb01b48ddb 100644 --- a/view/theme/frio/templates/search_item.tpl +++ b/view/theme/frio/templates/search_item.tpl @@ -96,7 +96,7 @@

{{$item.title}}


{{/if}} -
{{$item.body nofilter}}
+
{{$item.body_html nofilter}}
diff --git a/view/theme/frio/templates/wall_thread.tpl b/view/theme/frio/templates/wall_thread.tpl index 2b285456a9..03a1889e2f 100644 --- a/view/theme/frio/templates/wall_thread.tpl +++ b/view/theme/frio/templates/wall_thread.tpl @@ -246,7 +246,7 @@ as the value of $top_child_total (this is done at the end of this file)

{{$item.title}}


{{/if}} -
{{$item.body nofilter}}
+
{{$item.body_html nofilter}}
diff --git a/view/theme/quattro/templates/search_item.tpl b/view/theme/quattro/templates/search_item.tpl index be9a43604a..dcbe827909 100644 --- a/view/theme/quattro/templates/search_item.tpl +++ b/view/theme/quattro/templates/search_item.tpl @@ -23,7 +23,7 @@
{{if $item.title}}

{{$item.title}}

{{/if}} -
{{$item.body nofilter}}
+
{{$item.body_html nofilter}}
diff --git a/view/theme/quattro/templates/wall_item_tag.tpl b/view/theme/quattro/templates/wall_item_tag.tpl index e957e719a6..4e0c230cb0 100644 --- a/view/theme/quattro/templates/wall_item_tag.tpl +++ b/view/theme/quattro/templates/wall_item_tag.tpl @@ -37,7 +37,7 @@
{{$item.location_html nofilter}}
- {{$item.ago}} {{$item.body nofilter}} + {{$item.ago}} {{$item.body_html nofilter}}
{{if $item.drop.pagedrop}} diff --git a/view/theme/quattro/templates/wall_thread.tpl b/view/theme/quattro/templates/wall_thread.tpl index 7c8a567835..612e646f04 100644 --- a/view/theme/quattro/templates/wall_thread.tpl +++ b/view/theme/quattro/templates/wall_thread.tpl @@ -54,7 +54,7 @@
{{if $item.title}}

{{$item.title}}

{{/if}} - {{$item.body nofilter}} + {{$item.body_html nofilter}}
diff --git a/view/theme/smoothly/templates/search_item.tpl b/view/theme/smoothly/templates/search_item.tpl index 284264f29b..1e5b5c5801 100644 --- a/view/theme/smoothly/templates/search_item.tpl +++ b/view/theme/smoothly/templates/search_item.tpl @@ -31,7 +31,7 @@
{{$item.title}}
-
{{$item.body nofilter}}
+
{{$item.body_html nofilter}}
{{$item.name}} diff --git a/view/theme/smoothly/templates/wall_thread.tpl b/view/theme/smoothly/templates/wall_thread.tpl index 99d7020539..198b785019 100644 --- a/view/theme/smoothly/templates/wall_thread.tpl +++ b/view/theme/smoothly/templates/wall_thread.tpl @@ -62,7 +62,7 @@
{{$item.title}}
-
{{$item.body nofilter}} +
{{$item.body_html nofilter}}
{{if !$item.suppress_tags}} {{foreach $item.tags as $tag}} diff --git a/view/theme/vier/templates/search_item.tpl b/view/theme/vier/templates/search_item.tpl index 1ab47844cc..b21b3de9fd 100644 --- a/view/theme/vier/templates/search_item.tpl +++ b/view/theme/vier/templates/search_item.tpl @@ -30,7 +30,7 @@
{{if $item.title}}

{{$item.title}}

{{/if}} -
{{$item.body nofilter}}
+
{{$item.body_html nofilter}}
diff --git a/view/theme/vier/templates/wall_item_tag.tpl b/view/theme/vier/templates/wall_item_tag.tpl index eedc51bf17..f52da7c8d5 100644 --- a/view/theme/vier/templates/wall_item_tag.tpl +++ b/view/theme/vier/templates/wall_item_tag.tpl @@ -37,7 +37,7 @@
{{$item.location_html nofilter}}
- {{$item.ago}} {{$item.body nofilter}} + {{$item.ago}} {{$item.body_html nofilter}}
{{if $item.drop.pagedrop}} diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl index 60f0c796cb..29d6840c7a 100644 --- a/view/theme/vier/templates/wall_thread.tpl +++ b/view/theme/vier/templates/wall_thread.tpl @@ -74,7 +74,7 @@
{{if $item.title}}

{{$item.title}}

{{/if}} - {{$item.body nofilter}} + {{$item.body_html nofilter}}
From 65b796ed1faac71bfa9da5897b2cd7a6e2934535 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 13 Sep 2020 19:40:59 -0400 Subject: [PATCH 3/8] Normalize item_photo_menu template variable name --- include/conversation.php | 2 +- src/Object/Post.php | 2 +- view/templates/search_item.tpl | 2 +- view/templates/wall_thread.tpl | 2 +- view/theme/quattro/templates/search_item.tpl | 2 +- view/theme/quattro/templates/wall_item_tag.tpl | 2 +- view/theme/quattro/templates/wall_thread.tpl | 2 +- view/theme/smoothly/templates/search_item.tpl | 2 +- view/theme/smoothly/templates/wall_thread.tpl | 2 +- view/theme/vier/templates/search_item.tpl | 2 +- view/theme/vier/templates/wall_item_tag.tpl | 2 +- view/theme/vier/templates/wall_thread.tpl | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index fd7303fa46..8b658521ed 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -595,7 +595,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'network_icon' => ContactSelector::networkToIcon($item['network'], $item['author-link']), 'linktitle' => DI::l10n()->t('View %s\'s profile @ %s', $profile_name, $item['author-link']), 'profile_url' => $profile_link, - 'item_photo_menu' => item_photo_menu($item), + 'item_photo_menu_html' => item_photo_menu($item), 'name' => $profile_name, 'sparkle' => $sparkle, 'lock' => $lock, diff --git a/src/Object/Post.php b/src/Object/Post.php index 8176233092..6e5088f167 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -444,8 +444,8 @@ class Post 'wall' => DI::l10n()->t('Wall-to-Wall'), 'vwall' => DI::l10n()->t('via Wall-To-Wall:'), 'profile_url' => $profile_link, - 'item_photo_menu' => item_photo_menu($item), 'name' => $name_e, + 'item_photo_menu_html' => item_photo_menu($item), 'thumb' => DI::baseUrl()->remove($item['author-avatar']), 'osparkle' => $osparkle, 'sparkle' => $sparkle, diff --git a/view/templates/search_item.tpl b/view/templates/search_item.tpl index 32d1823ca5..4c6dcb7226 100644 --- a/view/templates/search_item.tpl +++ b/view/templates/search_item.tpl @@ -11,7 +11,7 @@ menu
    - {{$item.item_photo_menu nofilter}} + {{$item.item_photo_menu_html nofilter}}
diff --git a/view/templates/wall_thread.tpl b/view/templates/wall_thread.tpl index c805a2921e..235889930f 100644 --- a/view/templates/wall_thread.tpl +++ b/view/templates/wall_thread.tpl @@ -39,7 +39,7 @@ menu
    - {{$item.item_photo_menu nofilter}} + {{$item.item_photo_menu_html nofilter}}
diff --git a/view/theme/quattro/templates/search_item.tpl b/view/theme/quattro/templates/search_item.tpl index dcbe827909..e05e37621e 100644 --- a/view/theme/quattro/templates/search_item.tpl +++ b/view/theme/quattro/templates/search_item.tpl @@ -15,7 +15,7 @@ menu
diff --git a/view/theme/quattro/templates/wall_item_tag.tpl b/view/theme/quattro/templates/wall_item_tag.tpl index 4e0c230cb0..93e6abaef6 100644 --- a/view/theme/quattro/templates/wall_item_tag.tpl +++ b/view/theme/quattro/templates/wall_item_tag.tpl @@ -30,7 +30,7 @@ {{$item.name}}
diff --git a/view/theme/quattro/templates/wall_thread.tpl b/view/theme/quattro/templates/wall_thread.tpl index 612e646f04..6c557507bf 100644 --- a/view/theme/quattro/templates/wall_thread.tpl +++ b/view/theme/quattro/templates/wall_thread.tpl @@ -39,7 +39,7 @@ menu diff --git a/view/theme/smoothly/templates/search_item.tpl b/view/theme/smoothly/templates/search_item.tpl index 1e5b5c5801..5d0764de4a 100644 --- a/view/theme/smoothly/templates/search_item.tpl +++ b/view/theme/smoothly/templates/search_item.tpl @@ -10,7 +10,7 @@ menu
    - {{$item.item_photo_menu nofilter}} + {{$item.item_photo_menu_html nofilter}}
diff --git a/view/theme/smoothly/templates/wall_thread.tpl b/view/theme/smoothly/templates/wall_thread.tpl index 198b785019..d5138978dd 100644 --- a/view/theme/smoothly/templates/wall_thread.tpl +++ b/view/theme/smoothly/templates/wall_thread.tpl @@ -31,7 +31,7 @@ menu
    - {{$item.item_photo_menu nofilter}} + {{$item.item_photo_menu_html nofilter}}
diff --git a/view/theme/vier/templates/search_item.tpl b/view/theme/vier/templates/search_item.tpl index b21b3de9fd..278beb0174 100644 --- a/view/theme/vier/templates/search_item.tpl +++ b/view/theme/vier/templates/search_item.tpl @@ -16,7 +16,7 @@ {{$item.name}} diff --git a/view/theme/vier/templates/wall_item_tag.tpl b/view/theme/vier/templates/wall_item_tag.tpl index f52da7c8d5..960cb171af 100644 --- a/view/theme/vier/templates/wall_item_tag.tpl +++ b/view/theme/vier/templates/wall_item_tag.tpl @@ -30,7 +30,7 @@ {{$item.name}} diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl index 29d6840c7a..aedcf34e45 100644 --- a/view/theme/vier/templates/wall_thread.tpl +++ b/view/theme/vier/templates/wall_thread.tpl @@ -40,7 +40,7 @@ {{$item.name}} From 8d5eb61ea3dd61433cc6f1d2b9000d47340f8342 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 13 Sep 2020 19:43:42 -0400 Subject: [PATCH 4/8] Normalize item comment template variable name --- include/conversation.php | 2 +- src/Object/Post.php | 4 ++-- view/templates/wall_thread.tpl | 6 +++--- view/theme/frio/templates/search_item.tpl | 8 ++++---- view/theme/frio/templates/wall_thread.tpl | 16 ++++++++-------- view/theme/quattro/templates/wall_item_tag.tpl | 6 +++--- view/theme/quattro/templates/wall_thread.tpl | 10 +++++----- view/theme/smoothly/templates/wall_thread.tpl | 6 +++--- view/theme/vier/templates/wall_item_tag.tpl | 6 +++--- view/theme/vier/templates/wall_thread.tpl | 18 +++++++++--------- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 8b658521ed..0c007851cd 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -628,7 +628,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'vote' => $likebuttons, 'like' => '', 'dislike' => '', - 'comment' => '', + 'comment_html' => '', 'conv' => (($preview) ? '' : ['href'=> 'display/'.$item['guid'], 'title'=> DI::l10n()->t('View in context')]), 'previewing' => $previewing, 'wait' => DI::l10n()->t('Please wait'), diff --git a/src/Object/Post.php b/src/Object/Post.php index 6e5088f167..70142e887f 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -349,7 +349,7 @@ class Post } } - $comment = $this->getCommentBox($indent); + $comment_html = $this->getCommentBox($indent); if (strcmp(DateTimeFormat::utc($item['created']), DateTimeFormat::utc('now - 12 hours')) > 0) { $shiny = 'shiny'; @@ -479,7 +479,7 @@ class Post 'responses' => $responses, 'switchcomment' => DI::l10n()->t('Comment'), 'reply_label' => DI::l10n()->t('Reply to %s', $name_e), - 'comment' => $comment, + 'comment_html' => $comment_html, 'remote_comment' => $remote_comment, 'menu' => DI::l10n()->t('More'), 'previewing' => $conv->isPreview() ? ' preview ' : '', diff --git a/view/templates/wall_thread.tpl b/view/templates/wall_thread.tpl index 235889930f..73e99cb1bd 100644 --- a/view/templates/wall_thread.tpl +++ b/view/templates/wall_thread.tpl @@ -129,9 +129,9 @@ {{/foreach}} {{/if}} {{if $item.threaded}} - {{if $item.comment}} + {{if $item.comment_html}}
- {{$item.comment nofilter}} + {{$item.comment_html nofilter}}
{{/if}} {{/if}} @@ -144,7 +144,7 @@ {{if $item.flatten}}
- {{$item.comment nofilter}} + {{$item.comment_html nofilter}}
{{/if}} diff --git a/view/theme/frio/templates/search_item.tpl b/view/theme/frio/templates/search_item.tpl index bb01b48ddb..d7a22927cc 100644 --- a/view/theme/frio/templates/search_item.tpl +++ b/view/theme/frio/templates/search_item.tpl @@ -128,7 +128,7 @@

{{* Action buttons to interact with the item (like: like, dislike, share and so on *}} - diff --git a/view/theme/quattro/templates/wall_item_tag.tpl b/view/theme/quattro/templates/wall_item_tag.tpl index 93e6abaef6..71c7e0844f 100644 --- a/view/theme/quattro/templates/wall_item_tag.tpl +++ b/view/theme/quattro/templates/wall_item_tag.tpl @@ -58,10 +58,10 @@ {{/if}} {{* top thread comment box *}} -{{if $item.threaded}}{{if $item.comment}}{{if $item.thread_level==1}} -

{{$item.comment nofilter}}
+{{if $item.threaded}}{{if $item.comment_html}}{{if $item.thread_level==1}} +
{{$item.comment_html nofilter}}
{{/if}}{{/if}}{{/if}} {{if $item.flatten}} -
{{$item.comment nofilter}}
+
{{$item.comment_html nofilter}}
{{/if}} diff --git a/view/theme/quattro/templates/wall_thread.tpl b/view/theme/quattro/templates/wall_thread.tpl index 6c557507bf..a97a0cc5e4 100644 --- a/view/theme/quattro/templates/wall_thread.tpl +++ b/view/theme/quattro/templates/wall_thread.tpl @@ -161,11 +161,11 @@ {{/if}} - {{if $item.threaded}}{{if $item.comment}}{{if $item.indent==comment}} + {{if $item.threaded}}{{if $item.comment_html}}{{if $item.indent==comment}}
- {{$item.comment nofilter}} + {{$item.comment_html nofilter}}
{{/if}}{{/if}}{{/if}} @@ -189,11 +189,11 @@ {{/if}} {{* top thread comment box *}} -{{if $item.threaded}}{{if $item.comment}}{{if $item.thread_level==1}} -
{{$item.comment nofilter}}
+{{if $item.threaded}}{{if $item.comment_html}}{{if $item.thread_level==1}} +
{{$item.comment_html nofilter}}
{{/if}}{{/if}}{{/if}} {{if $item.flatten}} -
{{$item.comment nofilter}}
+
{{$item.comment_html nofilter}}
{{/if}} diff --git a/view/theme/smoothly/templates/wall_thread.tpl b/view/theme/smoothly/templates/wall_thread.tpl index d5138978dd..0cd52fcdea 100644 --- a/view/theme/smoothly/templates/wall_thread.tpl +++ b/view/theme/smoothly/templates/wall_thread.tpl @@ -147,9 +147,9 @@
{{$item.dislike nofilter}}
{{if $item.threaded}} - {{if $item.comment}} + {{if $item.comment_html}}
- {{$item.comment nofilter}} + {{$item.comment_html nofilter}}
{{/if}} {{/if}} @@ -163,7 +163,7 @@ {{if $item.flatten}}
- {{$item.comment nofilter}} + {{$item.comment_html nofilter}}
{{/if}} diff --git a/view/theme/vier/templates/wall_item_tag.tpl b/view/theme/vier/templates/wall_item_tag.tpl index 960cb171af..76e587f00a 100644 --- a/view/theme/vier/templates/wall_item_tag.tpl +++ b/view/theme/vier/templates/wall_item_tag.tpl @@ -58,10 +58,10 @@ {{/if}} {{* top thread comment box *}} -{{if $item.threaded}}{{if $item.comment}}{{if $item.thread_level==1}} -
{{$item.comment nofilter}}
+{{if $item.threaded}}{{if $item.comment_html}}{{if $item.thread_level==1}} +
{{$item.comment_html nofilter}}
{{/if}}{{/if}}{{/if}} {{if $item.flatten}} -
{{$item.comment nofilter}}
+
{{$item.comment_html nofilter}}
{{/if}} diff --git a/view/theme/vier/templates/wall_thread.tpl b/view/theme/vier/templates/wall_thread.tpl index aedcf34e45..944aee77b9 100644 --- a/view/theme/vier/templates/wall_thread.tpl +++ b/view/theme/vier/templates/wall_thread.tpl @@ -109,7 +109,7 @@ {{$item.remote_comment.1}} {{/if}} - {{if $item.comment}} + {{if $item.comment_html}} {{$item.switchcomment}} {{/if}} @@ -181,12 +181,12 @@ - {{if $item.threaded}}{{if $item.comment}} + {{if $item.threaded}}{{if $item.comment_html}}
{{/if}}{{/if}} @@ -210,19 +210,19 @@ {{/if}} {{if $item.total_comments_num}} - {{if $item.threaded}}{{if $item.comment}}{{if $item.thread_level==1}} -
{{$item.comment nofilter}}
+ {{if $item.threaded}}{{if $item.comment_html}}{{if $item.thread_level==1}} +
{{$item.comment_html nofilter}}
{{/if}}{{/if}}{{/if}} {{if $item.flatten}} -
{{$item.comment nofilter}}
+
{{$item.comment_html nofilter}}
{{/if}} {{else}} - {{if $item.threaded}}{{if $item.comment}}{{if $item.thread_level==1}} - + {{if $item.threaded}}{{if $item.comment_html}}{{if $item.thread_level==1}} + {{/if}}{{/if}}{{/if}} {{if $item.flatten}} - + {{/if}} {{/if}} From 3fa3e78844f98e8732c0b708483d23cfaefb7161 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 13 Sep 2020 19:44:11 -0400 Subject: [PATCH 5/8] Normalize item like/dislike template variable name --- include/conversation.php | 4 ++-- src/Object/Post.php | 4 ++-- view/theme/quattro/templates/search_item.tpl | 4 ++-- view/theme/smoothly/templates/wall_thread.tpl | 4 ++-- view/theme/vier/templates/search_item.tpl | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index 0c007851cd..d496e5bb7c 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -626,8 +626,8 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'star' => $star, 'drop' => $drop, 'vote' => $likebuttons, - 'like' => '', - 'dislike' => '', + 'like_html' => '', + 'dislike_html' => '', 'comment_html' => '', 'conv' => (($preview) ? '' : ['href'=> 'display/'.$item['guid'], 'title'=> DI::l10n()->t('View in context')]), 'previewing' => $previewing, diff --git a/src/Object/Post.php b/src/Object/Post.php index 70142e887f..c3b93b1a02 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -474,8 +474,8 @@ class Post 'filer' => $filer, 'drop' => $drop, 'vote' => $buttons, - 'like' => $responses['like']['output'], - 'dislike' => $responses['dislike']['output'], + 'like_html' => $responses['like']['output'], + 'dislike_html' => $responses['dislike']['output'], 'responses' => $responses, 'switchcomment' => DI::l10n()->t('Comment'), 'reply_label' => DI::l10n()->t('Reply to %s', $name_e), diff --git a/view/theme/quattro/templates/search_item.tpl b/view/theme/quattro/templates/search_item.tpl index e05e37621e..a7e755747e 100644 --- a/view/theme/quattro/templates/search_item.tpl +++ b/view/theme/quattro/templates/search_item.tpl @@ -82,8 +82,8 @@
- -
{{$item.dislike nofilter}}
+ +
{{$item.dislike_html nofilter}}
{{if $item.conv}}
{{$item.conv.title}} diff --git a/view/theme/smoothly/templates/wall_thread.tpl b/view/theme/smoothly/templates/wall_thread.tpl index 0cd52fcdea..c9f258f6fd 100644 --- a/view/theme/smoothly/templates/wall_thread.tpl +++ b/view/theme/smoothly/templates/wall_thread.tpl @@ -143,8 +143,8 @@
- -
{{$item.dislike nofilter}}
+ +
{{$item.dislike_html nofilter}}
{{if $item.threaded}} {{if $item.comment_html}} diff --git a/view/theme/vier/templates/search_item.tpl b/view/theme/vier/templates/search_item.tpl index 278beb0174..fd3a0a5369 100644 --- a/view/theme/vier/templates/search_item.tpl +++ b/view/theme/vier/templates/search_item.tpl @@ -89,7 +89,7 @@
- -
{{$item.dislike nofilter}}
+ +
{{$item.dislike_html nofilter}}
From 76d69621292af02f7612c06dfc041e9d33ea5465 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 13 Sep 2020 19:50:39 -0400 Subject: [PATCH 6/8] Remove superfluous variable in item template variables --- include/conversation.php | 19 ++++++------------- src/Object/Post.php | 40 +++++++++++++++++----------------------- 2 files changed, 23 insertions(+), 36 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index d496e5bb7c..ff7c28b608 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -520,10 +520,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o $threadsid++; - $owner_url = ''; - $owner_name = ''; - $sparkle = ''; - // prevent private email from leaking. if ($item['network'] === Protocol::MAIL && local_user() != $item['uid']) { continue; @@ -540,6 +536,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'network' => $item['author-network'], 'url' => $item['author-link']]; $profile_link = Contact::magicLinkByContact($author); + $sparkle = ''; if (strpos($profile_link, 'redir/') === 0) { $sparkle = ' sparkle'; } @@ -562,10 +559,6 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'delete' => DI::l10n()->t('Delete'), ]; - $star = false; - $isstarred = "unstarred"; - - $lock = false; $likebuttons = [ 'like' => null, 'dislike' => null, @@ -598,7 +591,7 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'item_photo_menu_html' => item_photo_menu($item), 'name' => $profile_name, 'sparkle' => $sparkle, - 'lock' => $lock, + 'lock' => false, 'thumb' => DI::baseUrl()->remove($item['author-avatar']), 'title' => $title, 'body_html' => $body_html, @@ -617,13 +610,13 @@ function conversation(App $a, array $items, $mode, $update, $preview = false, $o 'ago' => (($item['app']) ? DI::l10n()->t('%s from %s', Temporal::getRelativeDate($item['created']),$item['app']) : Temporal::getRelativeDate($item['created'])), 'location_html' => $location_html, 'indent' => '', - 'owner_name' => $owner_name, - 'owner_url' => $owner_url, + 'owner_name' => '', + 'owner_url' => '', 'owner_photo' => DI::baseUrl()->remove($item['owner-avatar']), 'plink' => Item::getPlink($item), 'edpost' => false, - 'isstarred' => $isstarred, - 'star' => $star, + 'isstarred' => 'unstarred', + 'star' => false, 'drop' => $drop, 'vote' => $likebuttons, 'like_html' => '', diff --git a/src/Object/Post.php b/src/Object/Post.php index c3b93b1a02..0de7bd072b 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -221,15 +221,14 @@ class Post $delete = $origin ? DI::l10n()->t('Delete globally') : DI::l10n()->t('Remove locally'); } - $drop = [ - 'dropping' => $dropping, - 'pagedrop' => $item['pagedrop'], - 'select' => DI::l10n()->t('Select'), - 'delete' => $delete, - ]; - - if (!local_user()) { - $drop = false; + $drop = false; + if (local_user()) { + $drop = [ + 'dropping' => $dropping, + 'pagedrop' => $item['pagedrop'], + 'select' => DI::l10n()->t('Select'), + 'delete' => $delete, + ]; } $filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? DI::l10n()->t("save to folder") : false); @@ -361,17 +360,12 @@ class Post list($categories, $folders) = DI::contentItem()->determineCategoriesTerms($item); - $name_e = $profile_name; - $text = strip_tags($body_html); - if (!empty($item['content-warning']) && DI::pConfig()->get(local_user(), 'system', 'disable_cw', false)) { - $title_e = ucfirst($item['content-warning']); + $title = ucfirst($item['content-warning']); } else { - $title_e = $item['title']; + $title = $item['title']; } - $owner_name_e = $this->getOwnerName(); - if (DI::pConfig()->get(local_user(), 'system', 'hide_dislike')) { $buttons['dislike'] = false; } @@ -412,8 +406,8 @@ class Post } elseif (DI::config()->get('debug', 'show_direction')) { $conversation = DBA::selectFirst('conversation', ['direction'], ['item-uri' => $item['uri']]); if (!empty($conversation['direction']) && in_array($conversation['direction'], [1, 2])) { - $title = [1 => DI::l10n()->t('Pushed'), 2 => DI::l10n()->t('Pulled')]; - $direction = ['direction' => $conversation['direction'], 'title' => $title[$conversation['direction']]]; + $direction_title = [1 => DI::l10n()->t('Pushed'), 2 => DI::l10n()->t('Pulled')]; + $direction = ['direction' => $conversation['direction'], 'title' => $direction_title[$conversation['direction']]]; } } @@ -432,7 +426,7 @@ class Post 'categories' => $categories, 'folders' => $folders, 'body_html' => $body_html, - 'text' => $text, + 'text' => strip_tags($body_html), 'id' => $this->getId(), 'guid' => urlencode($item['guid']), 'isevent' => $isevent, @@ -444,12 +438,12 @@ class Post 'wall' => DI::l10n()->t('Wall-to-Wall'), 'vwall' => DI::l10n()->t('via Wall-To-Wall:'), 'profile_url' => $profile_link, - 'name' => $name_e, + 'name' => $profile_name, 'item_photo_menu_html' => item_photo_menu($item), 'thumb' => DI::baseUrl()->remove($item['author-avatar']), 'osparkle' => $osparkle, 'sparkle' => $sparkle, - 'title' => $title_e, + 'title' => $title, 'localtime' => DateTimeFormat::local($item['created'], 'r'), 'ago' => $item['app'] ? DI::l10n()->t('%s from %s', $ago, $item['app']) : $ago, 'app' => $item['app'], @@ -461,7 +455,7 @@ class Post 'owner_self' => $item['author-link'] == Session::get('my_url'), 'owner_url' => $this->getOwnerUrl(), 'owner_photo' => DI::baseUrl()->remove($item['owner-avatar']), - 'owner_name' => $owner_name_e, + 'owner_name' => $this->getOwnerName(), 'plink' => Item::getPlink($item), 'edpost' => $edpost, 'ispinned' => $ispinned, @@ -478,7 +472,7 @@ class Post 'dislike_html' => $responses['dislike']['output'], 'responses' => $responses, 'switchcomment' => DI::l10n()->t('Comment'), - 'reply_label' => DI::l10n()->t('Reply to %s', $name_e), + 'reply_label' => DI::l10n()->t('Reply to %s', $profile_name), 'comment_html' => $comment_html, 'remote_comment' => $remote_comment, 'menu' => DI::l10n()->t('More'), From dc909841065d280a470c284e3fb11f2c1ce194c8 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 13 Sep 2020 19:51:03 -0400 Subject: [PATCH 7/8] Remove obsolete uses of Strings::escapeTags in mod/item --- mod/item.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mod/item.php b/mod/item.php index 911a9530c9..17f6486f89 100644 --- a/mod/item.php +++ b/mod/item.php @@ -260,7 +260,7 @@ function item_post(App $a) { $objecttype = $orig_post['object-type']; $app = $orig_post['app']; $categories = $orig_post['file'] ?? ''; - $title = Strings::escapeTags(trim($_REQUEST['title'])); + $title = trim($_REQUEST['title'] ?? ''); $body = trim($body); $private = $orig_post['private']; $pubmail_enabled = $orig_post['pubmail']; @@ -281,13 +281,13 @@ function item_post(App $a) { $str_group_deny = isset($_REQUEST['group_deny']) ? $aclFormatter->toString($_REQUEST['group_deny']) : $user['deny_gid'] ?? ''; } - $title = Strings::escapeTags(trim($_REQUEST['title'] ?? '')); - $location = Strings::escapeTags(trim($_REQUEST['location'] ?? '')); - $coord = Strings::escapeTags(trim($_REQUEST['coord'] ?? '')); - $verb = Strings::escapeTags(trim($_REQUEST['verb'] ?? '')); - $emailcc = Strings::escapeTags(trim($_REQUEST['emailcc'] ?? '')); + $title = trim($_REQUEST['title'] ?? ''); + $location = trim($_REQUEST['location'] ?? ''); + $coord = trim($_REQUEST['coord'] ?? ''); + $verb = trim($_REQUEST['verb'] ?? ''); + $emailcc = trim($_REQUEST['emailcc'] ?? ''); $body = trim($body); - $network = Strings::escapeTags(trim(($_REQUEST['network'] ?? '') ?: Protocol::DFRN)); + $network = trim(($_REQUEST['network'] ?? '') ?: Protocol::DFRN); $guid = System::createUUID(); $postopts = $_REQUEST['postopts'] ?? ''; From a7de06d280c33c3a00fb807dbca12b95edc09d98 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 13 Sep 2020 19:53:03 -0400 Subject: [PATCH 8/8] Add deprecation notice on Strings::escapeTags --- src/Util/Strings.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Util/Strings.php b/src/Util/Strings.php index 1d440c19b7..9d4a8212f6 100644 --- a/src/Util/Strings.php +++ b/src/Util/Strings.php @@ -68,6 +68,7 @@ class Strings * * @param string $string Input string * @return string Filtered string + * @deprecated since 2020.09 Please use Smarty default HTML escaping for templates or htmlspecialchars() otherwise */ public static function escapeTags($string) {