diff --git a/filter.php b/filter.php index 409e023..69e8258 100644 --- a/filter.php +++ b/filter.php @@ -44,7 +44,7 @@ class filter_fontawesome extends moodle_text_filter { public function filter($text, array $options = array()) { // We should search only for reference to FontAwesome icons and if optional icon and fab classes are set. - $search = "(\[((?:icon\s)?)((?:fab\s)?)(fa-[a-z0-9 -]+)\])is"; + $search = "(\[((?:icon\s)?)((?:fa[a-z]\s)?)(fa-[a-z0-9 -]+)\])is"; $result = preg_replace_callback($search, array($this, 'filter_fontawesome_callback'), $text); return $result; diff --git a/tests/filter_test.php b/tests/filter_test.php index 51f386a..15288c5 100644 --- a/tests/filter_test.php +++ b/tests/filter_test.php @@ -80,6 +80,10 @@ public function test_cases() { $this->run_with_content('icon fa-check fa-4x', true); $this->run_with_content('fab fa-telegram', true); $this->run_with_content('fab fa-telegram fa-5x', true); + $this->run_with_content('fad fa-angel', true); + $this->run_with_content('fal fa-child fa-2x', true); + $this->run_with_content('fas fa-smile', true); + $this->run_with_content('far fa-book', true); // Now test some cases that shouldn't be executed. $this->run_with_content('Some text fa-check', false); $this->run_with_content('fas-check', false); @@ -89,5 +93,6 @@ public function test_cases() { $this->run_with_content('f-check', false); $this->run_with_content('fa-check onmouseover="alert(1)"', false); $this->run_with_content('fa-check" onmouseover="alert(1)""', false); + $this->run_with_content('fad-angel', false); } }