summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
Diffstat (limited to 'application')
-rw-r--r--application/libraries/Pygments.php3
-rw-r--r--application/test/tests/test_libraries_pygments.php9
2 files changed, 11 insertions, 1 deletions
diff --git a/application/libraries/Pygments.php b/application/libraries/Pygments.php
index 5d37b69c3..81963bc68 100644
--- a/application/libraries/Pygments.php
+++ b/application/libraries/Pygments.php
@@ -173,6 +173,9 @@ class Pygments {
if (strpos($this->filename, ".") !== false) {
$extension = substr($this->filename, strrpos($this->filename, ".") + 1);
+ if ($extension === false) {
+ return false;
+ }
$extensionarray = array(
'awk' => 'awk',
diff --git a/application/test/tests/test_libraries_pygments.php b/application/test/tests/test_libraries_pygments.php
index 768bca439..d6bb559ee 100644
--- a/application/test/tests/test_libraries_pygments.php
+++ b/application/test/tests/test_libraries_pygments.php
@@ -80,7 +80,14 @@ class test_libraries_pygments extends \test\Test {
{
$p = new \libraries\Pygments('/invalid/filepath', 'image/svg+xml', 'foo.svg');
$this->t->is($p->can_highlight(), true, "image/svg+xml can highlight");
- }
+ }
+
+ public function test_autodetect_lexer_strangeFilenames()
+ {
+ $p = new \libraries\Pygments('/invalid/filepath', 'text/plain', 'foo.');
+ $this->t->is($p->autodetect_lexer(), 'text', "foo. should be text");
+
+ }
}