diff options
-rw-r--r-- | app/ExternalLink/FileLinkProvider.php | 17 | ||||
-rw-r--r-- | app/Template/task_external_link/table.php | 10 | ||||
-rw-r--r-- | tests/units/ExternalLink/FileLinkProviderTest.php | 15 |
3 files changed, 39 insertions, 3 deletions
diff --git a/app/ExternalLink/FileLinkProvider.php b/app/ExternalLink/FileLinkProvider.php index 901f78f8..eb8c1084 100644 --- a/app/ExternalLink/FileLinkProvider.php +++ b/app/ExternalLink/FileLinkProvider.php @@ -12,6 +12,11 @@ use Kanboard\Core\ExternalLink\ExternalLinkProviderInterface; */ class FileLinkProvider extends BaseLinkProvider implements ExternalLinkProviderInterface { + protected $excludedPrefixes= array( + 'http', + 'ftp', + ); + /** * Get provider name * @@ -55,7 +60,17 @@ class FileLinkProvider extends BaseLinkProvider implements ExternalLinkProviderI */ public function match() { - return strpos($this->userInput, 'file://') === 0; + if (strpos($this->userInput, '://') === false) { + return false; + } + + foreach ($this->excludedPrefixes as $prefix) { + if (strpos($this->userInput, $prefix) === 0) { + return false; + } + } + + return true; } /** diff --git a/app/Template/task_external_link/table.php b/app/Template/task_external_link/table.php index cdfe0028..a5fc7a33 100644 --- a/app/Template/task_external_link/table.php +++ b/app/Template/task_external_link/table.php @@ -32,8 +32,14 @@ <div class="dropdown"> <a href="#" class="dropdown-menu dropdown-menu-link-icon"><i class="fa fa-cog fa-fw"></i><i class="fa fa-caret-down"></i></a> <ul> - <li><?= $this->url->link(t('Edit'), 'TaskExternalLinkController', 'edit', array('link_id' => $link['id'], 'task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li> - <li><?= $this->url->link(t('Remove'), 'TaskExternalLinkController', 'confirm', array('link_id' => $link['id'], 'task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?></li> + <li> + <i class="fa fa-edit fa-fw"></i> + <?= $this->url->link(t('Edit'), 'TaskExternalLinkController', 'edit', array('link_id' => $link['id'], 'task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> + </li> + <li> + <i class="fa fa-trash-o fa-fw"></i> + <?= $this->url->link(t('Remove'), 'TaskExternalLinkController', 'confirm', array('link_id' => $link['id'], 'task_id' => $task['id'], 'project_id' => $task['project_id']), false, 'popover') ?> + </li> </ul> </div> </td> diff --git a/tests/units/ExternalLink/FileLinkProviderTest.php b/tests/units/ExternalLink/FileLinkProviderTest.php index 8cef82f8..8698e174 100644 --- a/tests/units/ExternalLink/FileLinkProviderTest.php +++ b/tests/units/ExternalLink/FileLinkProviderTest.php @@ -31,6 +31,21 @@ class FileLinkProviderTest extends Base $attachmentLinkProvider->setUserTextInput('file:///tmp/test.txt'); $this->assertTrue($attachmentLinkProvider->match()); + $attachmentLinkProvider->setUserTextInput('owncloud:///tmp/test.txt'); + $this->assertTrue($attachmentLinkProvider->match()); + + $attachmentLinkProvider->setUserTextInput('notebooks:///tmp/test.txt'); + $this->assertTrue($attachmentLinkProvider->match()); + + $attachmentLinkProvider->setUserTextInput('http://google.com/'); + $this->assertFalse($attachmentLinkProvider->match()); + + $attachmentLinkProvider->setUserTextInput('https://google.com/'); + $this->assertFalse($attachmentLinkProvider->match()); + + $attachmentLinkProvider->setUserTextInput('ftp://google.com/'); + $this->assertFalse($attachmentLinkProvider->match()); + $attachmentLinkProvider->setUserTextInput(''); $this->assertFalse($attachmentLinkProvider->match()); } |