summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2015-11-23 14:43:55 +0100
committerFlorian Pritz <bluewind@xinu.at>2015-11-23 14:43:55 +0100
commit9c695761a303b7cf1b37905bda3395ed60adeb30 (patch)
treed2a04ffe1e3eb75b6cdc43ca087e4bf47759f7f4
parent9eed447539bb2c2bdab13a2306c2be36963df37b (diff)
l/Pygments: Fix exception for filenames ending with a dot
Signed-off-by: Florian Pritz <bluewind@xinu.at>
-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");
+
+ }
}