From bbb397db20f250266b49d549a589dbba4d2f857e Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Mar 2020 00:42:37 -0400 Subject: [PATCH 1/6] Use correct variable name for deny input value concatenation --- view/templates/acl_selector.tpl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/view/templates/acl_selector.tpl b/view/templates/acl_selector.tpl index c3abdad5b..f1943cf3f 100644 --- a/view/templates/acl_selector.tpl +++ b/view/templates/acl_selector.tpl @@ -259,9 +259,9 @@ $contact_deny_input.val(''); [].forEach.call($acl_deny_input.tagsinput('items'), function (item) { if (item.type === 'group') { - $group_deny_input.val($group_allow_input.val() + ',' + item.id); + $group_deny_input.val($group_deny_input.val() + ',' + item.id); } else { - $contact_deny_input.val($contact_allow_input.val() + ',' + item.id); + $contact_deny_input.val($contact_deny_input.val() + ',' + item.id); } }); }); From 49b71546ec7e056282c96e4b68b4db26800a7bf5 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Mar 2020 08:19:28 -0400 Subject: [PATCH 2/6] Normalize vcard across themes display after profile fields reorganization --- view/templates/profile/vcard.tpl | 4 +--- view/theme/duepuntozero/templates/profile/vcard.tpl | 5 +++-- view/theme/quattro/templates/profile/vcard.tpl | 5 +++-- view/theme/vier/templates/profile/vcard.tpl | 4 +--- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/view/templates/profile/vcard.tpl b/view/templates/profile/vcard.tpl index 521738107..32f7e0fcf 100644 --- a/view/templates/profile/vcard.tpl +++ b/view/templates/profile/vcard.tpl @@ -1,12 +1,10 @@
-
{{$profile.name}}
+
{{$profile.name}}
{{if $profile.addr}}
{{$profile.addr}}
{{/if}} - {{if $profile.about}}
{{$profile.about nofilter}}
{{/if}} - {{if $profile.picdate}}
{{$profile.name}}
{{else}} diff --git a/view/theme/duepuntozero/templates/profile/vcard.tpl b/view/theme/duepuntozero/templates/profile/vcard.tpl index 983d8faa5..1ea91f197 100644 --- a/view/theme/duepuntozero/templates/profile/vcard.tpl +++ b/view/theme/duepuntozero/templates/profile/vcard.tpl @@ -1,11 +1,10 @@
-
{{$profile.name}}
+
{{$profile.name}}
{{if $profile.addr}}
{{$profile.addr}}
{{/if}} - {{if $profile.about}}
{{$profile.about nofilter}}
{{/if}}
{{$profile.name}}
{{if $account_type}}{{/if}} @@ -26,6 +25,8 @@ {{/if}} + {{if $profile.about}}
{{$profile.about nofilter}}
{{/if}} + {{if $profile.pubkey}}{{/if}} {{if $homepage}}
{{$homepage}}
{{$profile.homepage}}
{{/if}} diff --git a/view/theme/quattro/templates/profile/vcard.tpl b/view/theme/quattro/templates/profile/vcard.tpl index 605574bf8..3bbb9e09f 100644 --- a/view/theme/quattro/templates/profile/vcard.tpl +++ b/view/theme/quattro/templates/profile/vcard.tpl @@ -1,7 +1,7 @@
-
{{$profile.name}}
+
{{$profile.name}}
{{if $profile.edit}}
{{$profile.edit.1}} @@ -17,7 +17,6 @@ {{if $profile.addr}}
{{$profile.addr}}
{{/if}} - {{if $about}}
{{$profile.about nofilter}}
{{/if}}
{{$profile.name}}
{{if $account_type}}{{/if}} @@ -38,6 +37,8 @@ {{/if}} + {{if $about}}
{{$profile.about nofilter}}
{{/if}} + {{if $profile.xmpp}}
{{$xmpp}}
diff --git a/view/theme/vier/templates/profile/vcard.tpl b/view/theme/vier/templates/profile/vcard.tpl index 35f9099ab..c263ccde0 100644 --- a/view/theme/vier/templates/profile/vcard.tpl +++ b/view/theme/vier/templates/profile/vcard.tpl @@ -1,7 +1,7 @@
-
{{$profile.name}}
+
{{$profile.name}}
{{if $profile.edit}}
{{$profile.edit.1}} @@ -11,8 +11,6 @@ {{if $profile.addr}}
{{$profile.addr}}
{{/if}} - {{if $profile.about}}
{{$profile.about nofilter}}
{{/if}} - {{if $profile.picdate}}
{{$profile.name}}
{{else}} From b0dc3d6cf93392e31188a087814f2e88839a8f00 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Mar 2020 09:01:17 -0400 Subject: [PATCH 3/6] Improve Babel code - Add Diaspora source text choice - Simplify escaped display --- src/Module/Debug/Babel.php | 44 +++++++++++++++++++++++--------------- view/templates/babel.tpl | 1 + 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/src/Module/Debug/Babel.php b/src/Module/Debug/Babel.php index 35037f45e..80c70f788 100644 --- a/src/Module/Debug/Babel.php +++ b/src/Module/Debug/Babel.php @@ -37,9 +37,7 @@ class Babel extends BaseModule { function visible_whitespace($s) { - $s = str_replace(' ', ' ', $s); - - return str_replace(["\r\n", "\n", "\r"], '
', $s); + return '
' . htmlspecialchars($s) . '
'; } $results = []; @@ -61,7 +59,7 @@ class Babel extends BaseModule $html = Text\BBCode::convert($bbcode); $results[] = [ 'title' => DI::l10n()->t('BBCode::convert (raw HTML)'), - 'content' => visible_whitespace(htmlspecialchars($html)) + 'content' => visible_whitespace($html) ]; $results[] = [ @@ -78,13 +76,13 @@ class Babel extends BaseModule $markdown = Text\BBCode::toMarkdown($bbcode); $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown'), - 'content' => visible_whitespace(htmlspecialchars($markdown)) + 'content' => visible_whitespace($markdown) ]; $html2 = Text\Markdown::convert($markdown); $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::convert (raw HTML)'), - 'content' => visible_whitespace(htmlspecialchars($html2)) + 'content' => visible_whitespace($html2) ]; $results[] = [ 'title' => DI::l10n()->t('BBCode::toMarkdown => Markdown::convert'), @@ -118,17 +116,28 @@ class Babel extends BaseModule 'content' => $item['tag'] ]; break; - case 'markdown': - $markdown = trim($_REQUEST['text']); + case 'diaspora': + $diaspora = trim($_REQUEST['text']); $results[] = [ 'title' => DI::l10n()->t('Source input (Diaspora format)'), - 'content' => '
' . htmlspecialchars($markdown) . '
' + 'content' => visible_whitespace($diaspora), ]; - $html = Text\Markdown::convert(html_entity_decode($markdown,ENT_COMPAT, 'UTF-8')); + $markdown = XML::unescape($diaspora); + case 'markdown': + if (!isset($markdown)) { + $markdown = trim($_REQUEST['text']); + } + + $results[] = [ + 'title' => DI::l10n()->t('Source input (Markdown)'), + 'content' => visible_whitespace($markdown), + ]; + + $html = Text\Markdown::convert($markdown); $results[] = [ 'title' => DI::l10n()->t('Markdown::convert (raw HTML)'), - 'content' => visible_whitespace(htmlspecialchars($html)) + 'content' => visible_whitespace($html), ]; $results[] = [ @@ -136,17 +145,17 @@ class Babel extends BaseModule 'content' => $html ]; - $bbcode = Text\Markdown::toBBCode(XML::unescape($markdown)); + $bbcode = Text\Markdown::toBBCode($markdown); $results[] = [ 'title' => DI::l10n()->t('Markdown::toBBCode'), - 'content' => '
' . $bbcode . '
' + 'content' => visible_whitespace($bbcode), ]; break; case 'html' : $html = trim($_REQUEST['text']); $results[] = [ 'title' => DI::l10n()->t('Raw HTML input'), - 'content' => htmlspecialchars($html) + 'content' => visible_whitespace($html), ]; $results[] = [ @@ -174,7 +183,7 @@ class Babel extends BaseModule $bbcode2plain = Text\BBCode::toPlaintext($bbcode); $results[] = [ 'title' => DI::l10n()->t('HTML::toBBCode => BBCode::toPlaintext'), - 'content' => '
' . $bbcode2plain . '
' + 'content' => visible_whitespace($bbcode2plain), ]; $markdown = Text\HTML::toMarkdown($html); @@ -186,13 +195,13 @@ class Babel extends BaseModule $text = Text\HTML::toPlaintext($html, 0); $results[] = [ 'title' => DI::l10n()->t('HTML::toPlaintext'), - 'content' => '
' . $text . '
' + 'content' => visible_whitespace($text), ]; $text = Text\HTML::toPlaintext($html, 0, true); $results[] = [ 'title' => DI::l10n()->t('HTML::toPlaintext (compact)'), - 'content' => '
' . $text . '
' + 'content' => visible_whitespace($text), ]; } } @@ -201,6 +210,7 @@ class Babel extends BaseModule $o = Renderer::replaceMacros($tpl, [ '$text' => ['text', DI::l10n()->t('Source text'), $_REQUEST['text'] ?? '', ''], '$type_bbcode' => ['type', DI::l10n()->t('BBCode'), 'bbcode', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'bbcode'], + '$type_diaspora' => ['type', DI::l10n()->t('Diaspora'), 'diaspora', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'diaspora'], '$type_markdown' => ['type', DI::l10n()->t('Markdown'), 'markdown', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'markdown'], '$type_html' => ['type', DI::l10n()->t('HTML'), 'html', '', (($_REQUEST['type'] ?? '') ?: 'bbcode') == 'html'], '$results' => $results diff --git a/view/templates/babel.tpl b/view/templates/babel.tpl index caa829621..4dc50083d 100644 --- a/view/templates/babel.tpl +++ b/view/templates/babel.tpl @@ -6,6 +6,7 @@
{{include file="field_radio.tpl" field=$type_bbcode}} + {{include file="field_radio.tpl" field=$type_diaspora}} {{include file="field_radio.tpl" field=$type_markdown}} {{include file="field_radio.tpl" field=$type_html}}
From 5c726493aeb60b6cfb073d8a4b4df47bcf8d79c5 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Mar 2020 09:01:50 -0400 Subject: [PATCH 4/6] Remove extraneous HTML decode in Markdown::toBBCode --- src/Content/Text/Markdown.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Content/Text/Markdown.php b/src/Content/Text/Markdown.php index 8dfe00190..f5ad85e80 100644 --- a/src/Content/Text/Markdown.php +++ b/src/Content/Text/Markdown.php @@ -109,8 +109,6 @@ class Markdown */ public static function toBBCode($s) { - $s = html_entity_decode($s, ENT_COMPAT, 'UTF-8'); - // The parser cannot handle paragraphs correctly $s = str_replace(['

', '

', '

'], ['
', '
', '
'], $s); From bcf974f97e5dbc3ea70b50992bae4254cbb66f27 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Wed, 11 Mar 2020 09:02:26 -0400 Subject: [PATCH 5/6] Add test for extraneous HTML decode removed in Markdown::toBBCode --- tests/src/Content/Text/MarkdownTest.php | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/src/Content/Text/MarkdownTest.php b/tests/src/Content/Text/MarkdownTest.php index a22c2e25b..e98b15bdf 100644 --- a/tests/src/Content/Text/MarkdownTest.php +++ b/tests/src/Content/Text/MarkdownTest.php @@ -21,6 +21,7 @@ namespace Friendica\Test\src\Content\Text; +use Friendica\Content\Text\HTML; use Friendica\Content\Text\Markdown; use Friendica\Test\MockedTest; use Friendica\Test\Util\AppMockTrait; @@ -68,4 +69,30 @@ class MarkdownTest extends MockedTest $this->assertEquals($expected, $output); } + + public function dataMarkdownText() + { + return [ + 'bug-8358-double-decode' => [ + 'expectedBBCode' => 'with the and tag', + 'markdown' => 'with the <sup> and </sup> tag', + ], + ]; + } + + /** + * Test convert Markdown to BBCode + * + * @dataProvider dataMarkdownText + * + * @param string $expectedBBCode Expected BBCode output + * @param string $html Markdown text + * @throws \Friendica\Network\HTTPException\InternalServerErrorException + */ + public function testToBBCode($expectedBBCode, $html) + { + $actual = Markdown::toBBCode($html); + + $this->assertEquals($expectedBBCode, $actual); + } } From 82589a29cd8b37ab4c30983398d6ba94fc163ece Mon Sep 17 00:00:00 2001 From: Michael Date: Wed, 11 Mar 2020 20:49:23 +0000 Subject: [PATCH 6/6] Fix 8401: Don't let dbstructure think that it needs to update the table --- static/dbstructure.config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index b8daa4eee..7c400a892 100755 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -320,8 +320,8 @@ return [ "contact-relation" => [ "comment" => "Contact relations", "fields" => [ - "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "contact the related contact had interacted with"], - "relation-cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "comment" => "related contact who had interacted with the contact"], + "cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "primary" => "1", "comment" => "contact the related contact had interacted with"], + "relation-cid" => ["type" => "int unsigned", "not null" => "1", "default" => "0", "relation" => ["contact" => "id"], "primary" => "1", "comment" => "related contact who had interacted with the contact"], "last-interaction" => ["type" => "datetime", "not null" => "1", "default" => DBA::NULL_DATETIME, "comment" => "Date of the last interaction"], ], "indexes" => [