picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 615 forks source link

Tab in code block bombs pico #521

Closed maglub closed 4 years ago

maglub commented 4 years ago

Hi,

If i create a code block with code indented with "tab", pico dies with the following error log:

2019/12/02 17:03:30 [error] 1028#1028: *20384 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Uncaught Error: Call to undefined function mb_strlen() in /srv/www/kmg.group/pico.dev/vendor/erusev/parsedown/Parsedown.php:170
Stack trace:
#0 /srv/www/kmg.group/pico.dev/vendor/erusev/parsedown/Parsedown.php(39): Parsedown->lines(Array)
#1 /srv/www/kmg.group/pico.dev/vendor/erusev/parsedown-extra/ParsedownExtra.php(46): Parsedown->text('# Introduction\n...')
#2 /srv/www/kmg.group/pico.dev/vendor/picocms/pico/lib/Pico.php(1514): ParsedownExtra->text('\n# Introduction...')
#3 /srv/www/kmg.group/pico.dev/vendor/picocms/pico/lib/Pico.php(453): Pico->parseFileContent('\n# Introduction...')
#4 /srv/www/kmg.group/pico.dev/index.php(33): Pico->run()
#5 {main}
  thrown in /srv/www/kmg.group/pico.dev/vendor/erusev/parsedown/Parsedown.php on line 170" while reading response header from upstream, client: 10.0.90.10, server: dev.kmg.group, request: "GET /?magnus-blog%2F2019-12-02-Powershell-disable-uri-parsing-temporarily HTTP/1.0", upstream: "fastcgi://unix:/var/run/php/php7.0-fpm.sock:", host: "dev.kmg.group", referrer: "https://dev.kmg.group/?magnus-blog"

Way to reproduce:

Create a page with the following markdown (where the indentation is a "tab", not spaces):

    arne

Environment

My composer.lock file:

{
    "_readme": [
        "This file locks the dependencies of your project to a known state",
        "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
        "This file is @generated automatically"
    ],
    "content-hash": "c9bf243f8b4a442809c53203f84ff1c2",
    "packages": [
        {
            "name": "erusev/parsedown",
            "version": "1.7.0",
            "source": {
                "type": "git",
                "url": "https://github.com/erusev/parsedown.git",
                "reference": "6678d59be48c4be64eaca6ce70bea48a09488cc2"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/erusev/parsedown/zipball/6678d59be48c4be64eaca6ce70bea48a09488cc2",
                "reference": "6678d59be48c4be64eaca6ce70bea48a09488cc2",
                "shasum": ""
            },
            "require": {
                "php": ">=5.3.0"
            },
            "require-dev": {
                "phpunit/phpunit": "^4.8.35"
            },
            "type": "library",
            "autoload": {
                "psr-0": {
                    "Parsedown": ""
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Emanuil Rusev",
                    "email": "hello@erusev.com",
                    "homepage": "http://erusev.com"
                }
            ],
            "description": "Parser for Markdown.",
            "homepage": "http://parsedown.org",
            "keywords": [
                "markdown",
                "parser"
            ],
            "time": "2018-02-28T11:41:37+00:00"
        },
        {
            "name": "erusev/parsedown-extra",
            "version": "0.7.1",
            "source": {
                "type": "git",
                "url": "https://github.com/erusev/parsedown-extra.git",
                "reference": "0db5cce7354e4b76f155d092ab5eb3981c21258c"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/erusev/parsedown-extra/zipball/0db5cce7354e4b76f155d092ab5eb3981c21258c",
                "reference": "0db5cce7354e4b76f155d092ab5eb3981c21258c",
                "shasum": ""
            },
            "require": {
                "erusev/parsedown": "~1.4"
            },
            "type": "library",
            "autoload": {
                "psr-0": {
                    "ParsedownExtra": ""
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Emanuil Rusev",
                    "email": "hello@erusev.com",
                    "homepage": "http://erusev.com"
                }
            ],
            "description": "An extension of Parsedown that adds support for Markdown Extra.",
            "homepage": "https://github.com/erusev/parsedown-extra",
            "keywords": [
                "markdown",
                "markdown extra",
                "parsedown",
                "parser"
            ],
            "time": "2015-11-01T10:19:22+00:00"
        },
        {
            "name": "picocms/composer-installer",
            "version": "v1.0.1",
            "source": {
                "type": "git",
                "url": "https://github.com/picocms/composer-installer.git",
                "reference": "6b5036c83aa091ed76e2a76ed9335885f95a7db7"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/picocms/composer-installer/zipball/6b5036c83aa091ed76e2a76ed9335885f95a7db7",
                "reference": "6b5036c83aa091ed76e2a76ed9335885f95a7db7",
                "shasum": ""
            },
            "type": "composer-installer",
            "extra": {
                "class": "Pico\\Composer\\Installer\\PluginInstaller"
            },
            "autoload": {
                "psr-4": {
                    "Pico\\Composer\\": "src"
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Daniel Rudolf",
                    "email": "picocms.org@daniel-rudolf.de",
                    "role": "Lead Developer"
                },
                {
                    "name": "The Pico Community",
                    "homepage": "http://picocms.org/"
                },
                {
                    "name": "Contributors",
                    "homepage": "https://github.com/picocms/composer-installer/graphs/contributors"
                }
            ],
            "description": "A composer plugin responsible for installing plugins and themes for Pico, a stupidly simple, blazing fast, flat file CMS.",
            "homepage": "http://picocms.org/",
            "keywords": [
                "composer",
                "composer-installer",
                "composer-plugin",
                "pico",
                "pico-cms",
                "picocms",
                "picocms-installer",
                "picocms-plugin",
                "picocms-theme"
            ],
            "time": "2019-11-24T22:50:47+00:00"
        },
        {
            "name": "picocms/pico",
            "version": "v2.0.4",
            "source": {
                "type": "git",
                "url": "https://github.com/picocms/Pico.git",
                "reference": "bbf4aa4f6b6633a9bddef59e23d04479f42e73ba"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/picocms/Pico/zipball/bbf4aa4f6b6633a9bddef59e23d04479f42e73ba",
                "reference": "bbf4aa4f6b6633a9bddef59e23d04479f42e73ba",
                "shasum": ""
            },
            "require": {
                "erusev/parsedown": "^1.7",
                "erusev/parsedown-extra": "^0.7",
                "ext-dom": "*",
                "php": ">=5.3.6",
                "symfony/yaml": "^2.8",
                "twig/twig": "^1.35"
            },
            "require-dev": {
                "phpdocumentor/phpdocumentor": "^2.8",
                "squizlabs/php_codesniffer": "^2.4"
            },
            "suggest": {
                "picocms/composer-installer": "This Composer plugin is responsible for installing Pico plugins and themes using the Composer package manager.",
                "picocms/pico-deprecated": "PicoDeprecated's purpose is to maintain backward compatibility to older versions of Pico.",
                "picocms/pico-theme": "Pico requires a theme to actually display the contents of your website. This is Pico's official default theme."
            },
            "type": "library",
            "autoload": {
                "psr-0": {
                    "Pico": "lib/",
                    "PicoPluginInterface": "lib/",
                    "AbstractPicoPlugin": "lib/"
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Gilbert Pellegrom",
                    "email": "gilbert@pellegrom.me",
                    "role": "Project Founder"
                },
                {
                    "name": "The Pico Community",
                    "homepage": "http://picocms.org/"
                },
                {
                    "name": "Contributors",
                    "homepage": "https://github.com/picocms/Pico/graphs/contributors"
                }
            ],
            "description": "Pico is a flat file CMS, this means there is no administration backend and database to deal with. You simply create .md files in the \"content\" folder and that becomes a page.",
            "homepage": "http://picocms.org/",
            "keywords": [
                "Simple",
                "cms",
                "content-management",
                "flat-file",
                "markdown",
                "markdown-to-html",
                "php",
                "pico",
                "pico-cms",
                "picocms",
                "twig",
                "website",
                "yaml"
            ],
            "time": "2018-12-17T14:57:47+00:00"
        },
        {
            "name": "picocms/pico-deprecated",
            "version": "v2.0.4",
            "source": {
                "type": "git",
                "url": "https://github.com/picocms/pico-deprecated.git",
                "reference": "82bcf74c6aef78c84888360fdf69ae1896443c7e"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/picocms/pico-deprecated/zipball/82bcf74c6aef78c84888360fdf69ae1896443c7e",
                "reference": "82bcf74c6aef78c84888360fdf69ae1896443c7e",
                "shasum": ""
            },
            "require": {
                "php": ">=5.3.0",
                "picocms/pico": "self.version"
            },
            "type": "pico-plugin",
            "autoload": {
                "classmap": [
                    "PicoDeprecated.php"
                ]
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "The Pico Community",
                    "homepage": "http://picocms.org/"
                },
                {
                    "name": "Contributors",
                    "homepage": "https://github.com/picocms/pico-deprecated/graphs/contributors"
                }
            ],
            "description": "This is Pico's official PicoDeprecated plugin. Pico is a stupidly simple, blazing fast, flat file CMS.",
            "homepage": "http://picocms.org/",
            "keywords": [
                "compatibility",
                "deprecation",
                "pico",
                "pico-deprecated",
                "picocms",
                "picocms-plugin"
            ],
            "time": "2018-12-17T14:56:33+00:00"
        },
        {
            "name": "picocms/pico-theme",
            "version": "v2.0.4",
            "source": {
                "type": "git",
                "url": "https://github.com/picocms/pico-theme.git",
                "reference": "c3666492438410610e4b715264d1630cb3d85ee2"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/picocms/pico-theme/zipball/c3666492438410610e4b715264d1630cb3d85ee2",
                "reference": "c3666492438410610e4b715264d1630cb3d85ee2",
                "shasum": ""
            },
            "require": {
                "picocms/pico": "self.version"
            },
            "type": "pico-theme",
            "extra": {
                "installer-name": "default"
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "The Pico Community",
                    "homepage": "http://picocms.org/"
                },
                {
                    "name": "Contributors",
                    "homepage": "https://github.com/picocms/pico-theme/graphs/contributors"
                }
            ],
            "description": "This is Pico's official default theme. Pico is a stupidly simple, blazing fast, flat file CMS.",
            "homepage": "http://picocms.org/",
            "keywords": [
                "default-theme",
                "pico",
                "pico-theme",
                "picocms",
                "picocms-theme"
            ],
            "time": "2018-12-17T14:57:19+00:00"
        },
        {
            "name": "symfony/polyfill-ctype",
            "version": "v1.13.1",
            "source": {
                "type": "git",
                "url": "https://github.com/symfony/polyfill-ctype.git",
                "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3",
                "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3",
                "shasum": ""
            },
            "require": {
                "php": ">=5.3.3"
            },
            "suggest": {
                "ext-ctype": "For best performance"
            },
            "type": "library",
            "extra": {
                "branch-alias": {
                    "dev-master": "1.13-dev"
                }
            },
            "autoload": {
                "psr-4": {
                    "Symfony\\Polyfill\\Ctype\\": ""
                },
                "files": [
                    "bootstrap.php"
                ]
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Gert de Pagter",
                    "email": "BackEndTea@gmail.com"
                },
                {
                    "name": "Symfony Community",
                    "homepage": "https://symfony.com/contributors"
                }
            ],
            "description": "Symfony polyfill for ctype functions",
            "homepage": "https://symfony.com",
            "keywords": [
                "compatibility",
                "ctype",
                "polyfill",
                "portable"
            ],
            "time": "2019-11-27T13:56:44+00:00"
        },
        {
            "name": "symfony/yaml",
            "version": "v2.8.52",
            "source": {
                "type": "git",
                "url": "https://github.com/symfony/yaml.git",
                "reference": "02c1859112aa779d9ab394ae4f3381911d84052b"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/symfony/yaml/zipball/02c1859112aa779d9ab394ae4f3381911d84052b",
                "reference": "02c1859112aa779d9ab394ae4f3381911d84052b",
                "shasum": ""
            },
            "require": {
                "php": ">=5.3.9",
                "symfony/polyfill-ctype": "~1.8"
            },
            "type": "library",
            "extra": {
                "branch-alias": {
                    "dev-master": "2.8-dev"
                }
            },
            "autoload": {
                "psr-4": {
                    "Symfony\\Component\\Yaml\\": ""
                },
                "exclude-from-classmap": [
                    "/Tests/"
                ]
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "MIT"
            ],
            "authors": [
                {
                    "name": "Fabien Potencier",
                    "email": "fabien@symfony.com"
                },
                {
                    "name": "Symfony Community",
                    "homepage": "https://symfony.com/contributors"
                }
            ],
            "description": "Symfony Yaml Component",
            "homepage": "https://symfony.com",
            "time": "2018-11-11T11:18:13+00:00"
        },
        {
            "name": "twig/twig",
            "version": "v1.42.4",
            "source": {
                "type": "git",
                "url": "https://github.com/twigphp/Twig.git",
                "reference": "e587180584c3d2d6cb864a0454e777bb6dcb6152"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/twigphp/Twig/zipball/e587180584c3d2d6cb864a0454e777bb6dcb6152",
                "reference": "e587180584c3d2d6cb864a0454e777bb6dcb6152",
                "shasum": ""
            },
            "require": {
                "php": ">=5.5.0",
                "symfony/polyfill-ctype": "^1.8"
            },
            "require-dev": {
                "psr/container": "^1.0",
                "symfony/debug": "^3.4|^4.2",
                "symfony/phpunit-bridge": "^4.4@dev|^5.0"
            },
            "type": "library",
            "extra": {
                "branch-alias": {
                    "dev-master": "1.42-dev"
                }
            },
            "autoload": {
                "psr-0": {
                    "Twig_": "lib/"
                },
                "psr-4": {
                    "Twig\\": "src/"
                }
            },
            "notification-url": "https://packagist.org/downloads/",
            "license": [
                "BSD-3-Clause"
            ],
            "authors": [
                {
                    "name": "Fabien Potencier",
                    "email": "fabien@symfony.com",
                    "homepage": "http://fabien.potencier.org",
                    "role": "Lead Developer"
                },
                {
                    "name": "Twig Team",
                    "homepage": "https://twig.symfony.com/contributors",
                    "role": "Contributors"
                },
                {
                    "name": "Armin Ronacher",
                    "email": "armin.ronacher@active-4.com",
                    "role": "Project Founder"
                }
            ],
            "description": "Twig, the flexible, fast, and secure template language for PHP",
            "homepage": "https://twig.symfony.com",
            "keywords": [
                "templating"
            ],
            "time": "2019-11-11T16:49:32+00:00"
        }
    ],
    "packages-dev": [],
    "aliases": [],
    "minimum-stability": "stable",
    "stability-flags": [],
    "prefer-stable": false,
    "prefer-lowest": false,
    "platform": [],
    "platform-dev": []
}
PhrozenByte commented 4 years ago

Pico (to be more precise: Parsedown, the Markdown parser Pico depends on) requires the PHP extensions mbstring and dom to run. If you're using a Composer-based installation, this is checked when running composer install. If you're using one of Pico's pre-bundled releases, it is checked on runtime.

If you don't know how to install PHP's mbstring and dom extensions on your server, ask your webserver admin resp. your web hoster. If you're running your own server, the steps you must take differ from distribution to distribution. For example, if you're running Debian or Ubuntu, you can install the missing PHP extensions by running sudo apt install php-mbstring php-xml in a shell on your server.

maglub commented 4 years ago

Thanks a lot for the quick answer.

I did install pico like this:

sudo apt-get install php-xml

curl -sSL https://getcomposer.org/installer | php
php composer.phar create-project picocms/pico-composer pico

I now installed mbstring:

sudo apt-get install php-mbstring

And viola! It works again. Funny that mbstring was needed for "tab" but not indentations with "space".

Sorry if I did not read the installation manual properly. Again, thanks a million for the heads up!