Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GeSHi highlight icon bug #4237

Open
respencer opened this issue Mar 7, 2024 · 0 comments
Open

GeSHi highlight icon bug #4237

respencer opened this issue Mar 7, 2024 · 0 comments

Comments

@respencer
Copy link

I noticed yesterday that a bash file I had in a code block has a broken icon:

Screen Shot 2024-03-07 at 14 47 27

<code bash updpkg>

Looking at the HTML I saw this for the class:

class="mediafile mf_"

It should have been:

class="mediafile mf_bash"

Looking at the code I see that the class name is being determined by the file extension:

public function _highlight($type, $text, $language = null, $filename = null, $options = null)
{
global $ID;
global $lang;
global $INPUT;
$language = preg_replace(PREG_PATTERN_VALID_LANGUAGE, '', $language ?? '');
if ($filename) {
// add icon
[$ext] = mimetype($filename, false);
$class = preg_replace('/[^_\-a-z0-9]+/i', '_', $ext);
$class = 'mediafile mf_' . $class;

Files don't always have extensions, especially on Unix like systems. If there is no extension, the code should fallback to using the language to determine the correct icon instead of failing with "mf_" as the result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant