Content file extension: html no longer possible?

Is there a reason why .html is no longer supported (content | Kirby CMS) as content file extension in v3? I worked with it in v2 without problems and because of syntax highlighting in the files (we are currently using html in 90% of the content) would like to use it in v3 too.

1 Like

Out of the box, that doesn’t seem to be possible (actually, I never knew you could in Kirby 2). But if I understand the Data class correctly, you could extend it with a custom handler.

Thank you, Sonja. I’m actually back on track. So I found the Data class and the Handlers. The creation of the class is no problem but how would I register the handler so the Data class uses ist? (I would like to add it to a plugin).

Oh, I can’t actually remember what I looked into 10 months ago. So I have to look again.

Very kind of you, thanks.

@oliverschneider:

Think of “.html”: it may be not secure, because such a file could be opened in a browser.

Thank you, Heiner, but this could be blocked via .htaccess (as it is for the standard-txt-files of Kirby, too, since the browser would display them too.)

Exactly.

But I think the problem here is actually the code in Dir::inventory() that is preventing the use of html files:

 switch ($extension) {
                    case 'htm':
                    case 'html':
                    case 'php':
                        // don't track those files
                        break;
                    case $contentExtension:
                        $content[] = pathinfo($item, PATHINFO_FILENAME);
                        break;
                    default:
                        $inventory['files'][$item] = [
                            'filename'  => $item,
                            'extension' => $extension,
                            'root'      => $root,
                        ];
                }

So extending the Data class is –contrary to what I thought– actually not helpful, I’m afraid.

Do you actually edit files in an editor instead of via the Panel? Why do you use that much HTML in content files?

Can’t you add file associations in your editor settings to get syntax highlighting in .txt files?

1 Like

Uuh, seems Bastian (or someone else) really doesn’t like html-files. Yeah, we use html a lot, it’s kind of a legacy from the system we used before Kirby (selfmade) and for now, a transition would not be that easy (3200+ pages, www.inf-schule.de).

Perhaps we should go with file asscociations for some editors (since we have a large number of authors).

I’d convert the files to .txt and move to using more markdown/kirbytags. Then use files associations in editor to enable code highlighting for legacy stuff.

Yeah, perhaps it’s the right time to go down that horrible “path of converting” :smiley:

Notwithstanding this, I would be interested why html-files are blocked by the inventory function @bastianallgeier?

We blocked HTML and PHP files to avoid that they are accessed directly and could contain harmful code snippets. They are basically a potential attack vector.

1 Like

HTML because of JS? Since direct access ist not my problem, the could only be in the panel?

Yes, because of JS or external images or a multitude of other possible attacks.