diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Chat/ChatManager.php | 2 | ||||
-rw-r--r-- | lib/Chat/Parser/SystemMessage.php | 9 | ||||
-rw-r--r-- | lib/Controller/ChatController.php | 5 | ||||
-rw-r--r-- | lib/Migration/Version10000Date20201012144235.php | 12 | ||||
-rw-r--r-- | lib/TalkSession.php | 4 |
5 files changed, 25 insertions, 7 deletions
diff --git a/lib/Chat/ChatManager.php b/lib/Chat/ChatManager.php index c7de834b3..627af40fa 100644 --- a/lib/Chat/ChatManager.php +++ b/lib/Chat/ChatManager.php @@ -62,6 +62,8 @@ class ChatManager { public const MAX_CHAT_LENGTH = 32000; + public const GEO_LOCATION_VALIDATOR = '/^geo:-?\d{1,2}(\.\d+)?,-?\d{1,3}(\.\d+)?(,-?\d+(\.\d+)?)?(;crs=wgs84)?(;u=\d+(\.\d+)?)?$/i'; + /** @var ICommentsManager */ private $commentsManager; /** @var IEventDispatcher */ diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index 00029c2be..8a2b34f5a 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace OCA\Talk\Chat\Parser; use OCA\DAV\CardDAV\PhotoCache; +use OCA\Talk\Chat\ChatManager; use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\GuestManager; use OCA\Talk\Model\Attendee; @@ -373,6 +374,14 @@ class SystemMessage { } elseif ($message === 'object_shared') { $parsedParameters['object'] = $parameters['metaData']; $parsedMessage = '{object}'; + + if (isset($parsedParameters['object']['type']) + && $parsedParameters['object']['type'] === 'geo-location' + && !preg_match(ChatManager::GEO_LOCATION_VALIDATOR, $parsedParameters['object']['id'])) { + $parsedParameters = []; + $parsedMessage = $this->l->t('The shared location is malformed'); + } + $chatMessage->setMessageType('comment'); } elseif ($message === 'matterbridge_config_added') { $parsedMessage = $this->l->t('{actor} set up Matterbridge to synchronize this conversation with other chats'); diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index af9e13b31..10a807659 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -288,6 +288,11 @@ class ChatController extends AEnvironmentAwareController { return new DataResponse([], Http::STATUS_BAD_REQUEST); } + if ($data['type'] === 'geo-location' + && !preg_match(ChatManager::GEO_LOCATION_VALIDATOR, $data['id'])) { + return new DataResponse([], Http::STATUS_BAD_REQUEST); + } + $this->participantService->ensureOneToOneRoomIsFilled($this->room); $creationDateTime = $this->timeFactory->getDateTime('now', new \DateTimeZone('UTC')); diff --git a/lib/Migration/Version10000Date20201012144235.php b/lib/Migration/Version10000Date20201012144235.php index f7d22cb51..3705cbebd 100644 --- a/lib/Migration/Version10000Date20201012144235.php +++ b/lib/Migration/Version10000Date20201012144235.php @@ -43,11 +43,13 @@ class Version10000Date20201012144235 extends SimpleMigrationStep { $schema = $schemaClosure(); $table = $schema->getTable('talk_rooms'); - $table->addColumn('sip_enabled', Types::SMALLINT, [ - 'notnull' => true, - 'default' => 0, - 'unsigned' => true, - ]); + if (!$table->hasColumn('sip_enabled')) { + $table->addColumn('sip_enabled', Types::SMALLINT, [ + 'notnull' => true, + 'default' => 0, + 'unsigned' => true, + ]); + } return $schema; } diff --git a/lib/TalkSession.php b/lib/TalkSession.php index 44ef46c98..4c3b02c7e 100644 --- a/lib/TalkSession.php +++ b/lib/TalkSession.php @@ -133,7 +133,7 @@ class TalkSession { $this->session->set($key, json_encode($values)); } - public function renewSessionId() { - $this->session->regenerateId(); + public function renewSessionId(): void { + $this->session->regenerateId(true, true); } } |