]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #6931 from MrPetovan/task/6903-collapse-connector-list
authorMichael Vogel <icarus@dabo.de>
Tue, 26 Mar 2019 07:27:40 +0000 (08:27 +0100)
committerGitHub <noreply@github.com>
Tue, 26 Mar 2019 07:27:40 +0000 (08:27 +0100)
Collapse connector list

CHANGELOG
config/dbstructure.config.php
database.sql
src/App.php
src/Content/Smilies.php
tests/src/Content/SmiliesTest.php [new file with mode: 0644]

index 91ba1dc6b27d5174e6fff0c45d49535f83d68c60..4e88d864c4554729494f6a5f15882459e2d143a2 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,7 @@ Version 2019.06 (UNRELEASED) (2019-06-?)
     Fixed the timezone of Friendica logs [nupplaphil]
     Fixed tag completion painfully slow [AlfredSK]
     Fixed a regression in notifications [MrPetovan]
+    Fixed an issue with smilies and code blocks [MrPetovan]
     General Code cleaning and restructuring [nupplaphil]
     Added frio color scheme sharing [JeroenED]
     Added syslog and stream Logger [nupplaphil]
index 7488787a6a7ca6b0dcfc23dfcff5ec43e8e0a63e..c2bf5c5eb9eaa8571deea0a9b2b40164e1525d83 100644 (file)
@@ -34,7 +34,7 @@
 use Friendica\Database\DBA;
 
 if (!defined('DB_UPDATE_VERSION')) {
-       define('DB_UPDATE_VERSION', 1305);
+       define('DB_UPDATE_VERSION', 1306);
 }
 
 return [
@@ -1195,7 +1195,7 @@ return [
                ],
                "indexes" => [
                        "PRIMARY" => ["tid"],
-                       "term_type" => ["term", "type"],
+                       "term_type" => ["term(64)", "type"],
                        "oid_otype_type_term" => ["oid", "otype", "type", "term(32)"],
                        "uid_otype_type_term_global_created" => ["uid", "otype", "type", "term(32)", "global", "created"],
                        "uid_otype_type_url" => ["uid", "otype", "type", "url(64)"],
index 0e7e5a3437042fb409eb5e6799c2db0b8fa4d0da..6334a92023cd323ad0401cbfd54b2c4bc518e41f 100644 (file)
@@ -1099,7 +1099,7 @@ CREATE TABLE IF NOT EXISTS `term` (
        `global` boolean NOT NULL DEFAULT '0' COMMENT '',
        `uid` mediumint unsigned NOT NULL DEFAULT 0 COMMENT 'User id',
         PRIMARY KEY(`tid`),
-        INDEX `term_type` (`term`, `type`),
+        INDEX `term_type` (`term`(64), `type`),
         INDEX `oid_otype_type_term` (`oid`,`otype`,`type`,`term`(32)),
         INDEX `uid_otype_type_term_global_created` (`uid`,`otype`,`type`,`term`(32),`global`,`created`),
         INDEX `uid_otype_type_url` (`uid`,`otype`,`type`,`url`(64)),
index 1ed6390b432d7f53d101e3965d49c9278835aa4f..c0afd514d036068983afd1cf6c6b8a6f16b3f008 100644 (file)
@@ -724,6 +724,7 @@ class App
                        'fetch',
                        'hcard',
                        'hostxrd',
+                       'manifest',
                        'nodeinfo',
                        'noscrape',
                        'p',
index 902395997835cd3becc5decb37d10ee6162d5271..9fbfd2d629c7109a4c4ca0777d393a363055c1a2 100644 (file)
@@ -213,7 +213,6 @@ class Smilies
                        return $text;
                }
 
-               $text = preg_replace_callback('/<pre>(.*?)<\/pre>/ism'  , 'self::encode', $text);
                $text = preg_replace_callback('/<code>(.*?)<\/code>/ism', 'self::encode', $text);
 
                if ($no_images) {
@@ -231,7 +230,6 @@ class Smilies
                $text = preg_replace_callback('/&lt;(3+)/', 'self::pregHeart', $text);
                $text = self::strOrigReplace($smilies['texts'], $smilies['icons'], $text);
 
-               $text = preg_replace_callback('/<pre>(.*?)<\/pre>/ism', 'self::decode', $text);
                $text = preg_replace_callback('/<code>(.*?)<\/code>/ism', 'self::decode', $text);
 
                return $text;
@@ -244,7 +242,7 @@ class Smilies
         */
        private static function encode($m)
        {
-               return(str_replace($m[1], Strings::base64UrlEncode($m[1]), $m[0]));
+               return '<code>' . Strings::base64UrlEncode($m[1]) . '</code>';
        }
 
        /**
@@ -255,7 +253,7 @@ class Smilies
         */
        private static function decode($m)
        {
-               return(str_replace($m[1], Strings::base64UrlDecode($m[1]), $m[0]));
+               return '<code>' . Strings::base64UrlDecode($m[1]) . '</code>';
        }
 
 
diff --git a/tests/src/Content/SmiliesTest.php b/tests/src/Content/SmiliesTest.php
new file mode 100644 (file)
index 0000000..40d126e
--- /dev/null
@@ -0,0 +1,69 @@
+<?php\r
+/**\r
+ * Created by PhpStorm.\r
+ * User: benlo\r
+ * Date: 25/03/19\r
+ * Time: 21:36\r
+ */\r
+\r
+namespace Friendica\Test\src\Content;\r
+\r
+use Friendica\Content\Smilies;\r
+use Friendica\Test\MockedTest;\r
+use Friendica\Test\Util\AppMockTrait;\r
+use Friendica\Test\Util\L10nMockTrait;\r
+use Friendica\Test\Util\VFSTrait;\r
+\r
+class SmiliesTest extends MockedTest\r
+{\r
+       use VFSTrait;\r
+       use AppMockTrait;\r
+       use L10nMockTrait;\r
+\r
+       protected function setUp()\r
+       {\r
+               parent::setUp();\r
+               $this->setUpVfsDir();\r
+               $this->mockApp($this->root);\r
+               $this->app->videowidth = 425;\r
+               $this->app->videoheight = 350;\r
+               $this->configMock->shouldReceive('get')\r
+                       ->with('system', 'no_smilies')\r
+                       ->andReturn(false);\r
+               $this->configMock->shouldReceive('get')\r
+                       ->with(false, 'system', 'no_smilies')\r
+                       ->andReturn(false);\r
+       }\r
+\r
+       public function dataLinks()\r
+       {\r
+               return [\r
+                       /** @see https://github.com/friendica/friendica/pull/6933 */\r
+                       'bug-6933-1' => [\r
+                               'data' => '<code>/</code>',\r
+                               'smilies' => ['texts' => [], 'icons' => []],\r
+                               'expected' => '<code>/</code>',\r
+                       ],\r
+                       'bug-6933-2' => [\r
+                               'data' => '<code>code</code>',\r
+                               'smilies' => ['texts' => [], 'icons' => []],\r
+                               'expected' => '<code>code</code>',\r
+                       ],\r
+               ];\r
+       }\r
+\r
+       /**\r
+        * Test replace smilies in different texts\r
+        * @dataProvider dataLinks\r
+        *\r
+        * @param string $text     Test string\r
+        * @param array  $smilies  List of smilies to replace\r
+        * @param string $expected Expected result\r
+        * @throws \Friendica\Network\HTTPException\InternalServerErrorException\r
+        */\r
+       public function testReplaceFromArray($text, $smilies, $expected)\r
+       {\r
+               $output = Smilies::replaceFromArray($text, $smilies);\r
+               $this->assertEquals($expected, $output);\r
+       }\r
+}\r