Colon in title breaks server #64

Closed
opened 2021-11-14 16:46:38 +01:00 by are0h · 2 comments
are0h commented 2021-11-14 16:46:38 +01:00 (Migrated from koodu.ubiqueros.com)

I edited the Index page with a title that included the : character ("X presents: Y" seemed like a fun title format for it). This crashed the PHP server. Terminal log says this:

 [::1]:51350 [500]: POST /api/v1/page/write - Uncaught Symfony\Component\Yaml\Exception\ParseException: A colon cannot be used in an unquoted mapping value at line 3 (near "title: Mosafeti kynnir\: Rása? Hvernig?"). in /home/greatjoe/fipamo/vendor/symfony/yaml/Parser.php:815
Stack trace:
#0 /home/greatjoe/fipamo/vendor/symfony/yaml/Parser.php(352): Symfony\Component\Yaml\Parser->parseValue()
#1 /home/greatjoe/fipamo/vendor/symfony/yaml/Parser.php(97): Symfony\Component\Yaml\Parser->doParse()
#2 /home/greatjoe/fipamo/vendor/mnapoli/front-yaml/src/Bridge/Symfony/SymfonyYAMLParser.php(36): Symfony\Component\Yaml\Parser->parse()
#3 /home/greatjoe/fipamo/vendor/mnapoli/front-yaml/src/Parser.php(78): Mni\FrontYAML\Bridge\Symfony\SymfonyYAMLParser->parse()
#4 /home/greatjoe/fipamo/brain/data/Book.inc.php(280): Mni\FrontYAML\Parser->parse()
#5 /home/greatjoe/fipamo/brain/utility/Sorting.inc.php(16): Book->getContents()
#6 /home/greatjoe/fipamo/brain/data/Settings.inc.php(180): Sorting::tags()
#7 /home/greatjoe/fipamo/brain/data/Book.inc.php(187): Settings::updateTags()
#8 /home/greatjoe/fipamo/brain/api/v1/PagesAPI.inc.php(142): Book->editPage()
#9 /home/greatjoe/fipamo/brain/controller/APIControl.inc.php(172): PagesAPI::handlePageTask()
#10 /home/greatjoe/fipamo/brain/controller/RouteControl.inc.php(36): APIControl::post()
#11 /home/greatjoe/fipamo/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(43): RouteControl->post()
#12 /home/greatjoe/fipamo/vendor/slim/slim/Slim/Routing/Route.php(384): Slim\Handlers\Strategies\RequestResponse->__invoke()
#13 /home/greatjoe/fipamo/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Slim\Routing\Route->handle()
#14 /home/greatjoe/fipamo/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Slim\MiddlewareDispatcher->handle()
#15 /home/greatjoe/fipamo/vendor/slim/slim/Slim/Routing/Route.php(341): Slim\MiddlewareDispatcher->handle()
#16 /home/greatjoe/fipamo/vendor/slim/slim/Slim/Routing/RouteRunner.php(84): Slim\Routing\Route->run()
#17 /home/greatjoe/fipamo/vendor/slim/twig-view/src/TwigMiddleware.php(125): Slim\Routing\RouteRunner->handle()
#18 /home/greatjoe/fipamo/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\Views\TwigMiddleware->process()
#19 /home/greatjoe/fipamo/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Psr\Http\Server\RequestHandlerInterface@anonymous->handle()
#20 /home/greatjoe/fipamo/vendor/slim/slim/Slim/App.php(215): Slim\MiddlewareDispatcher->handle()
#21 /home/greatjoe/fipamo/vendor/slim/slim/Slim/App.php(199): Slim\App->handle()
#22 /home/greatjoe/fipamo/brain/App.inc.php(44): Slim\App->run()
#23 /home/greatjoe/fipamo/public/index.php(5): App->__construct()
#24 {main}
  thrown in /home/greatjoe/fipamo/vendor/symfony/yaml/Parser.php on line 815

I've since fixed the crash by going to /content/pages/start/index.md and putting "s around the title in a different text editor. Likewise adding " around the title in Fipamo's editor creates a working title and lets the server run as normal, although opening the file again to edit will not make it display the quotation marks.

I'm guessing the fix would be to have the Markdown editor write

title:"$usertitle"

with quotation marks included, before the YAML parser gets at it and freaks out.

I edited the Index page with a title that included the `:` character ("X presents: Y" seemed like a fun title format for it). This crashed the PHP server. Terminal log says this: ``` [::1]:51350 [500]: POST /api/v1/page/write - Uncaught Symfony\Component\Yaml\Exception\ParseException: A colon cannot be used in an unquoted mapping value at line 3 (near "title: Mosafeti kynnir\: Rása? Hvernig?"). in /home/greatjoe/fipamo/vendor/symfony/yaml/Parser.php:815 Stack trace: #0 /home/greatjoe/fipamo/vendor/symfony/yaml/Parser.php(352): Symfony\Component\Yaml\Parser->parseValue() #1 /home/greatjoe/fipamo/vendor/symfony/yaml/Parser.php(97): Symfony\Component\Yaml\Parser->doParse() #2 /home/greatjoe/fipamo/vendor/mnapoli/front-yaml/src/Bridge/Symfony/SymfonyYAMLParser.php(36): Symfony\Component\Yaml\Parser->parse() #3 /home/greatjoe/fipamo/vendor/mnapoli/front-yaml/src/Parser.php(78): Mni\FrontYAML\Bridge\Symfony\SymfonyYAMLParser->parse() #4 /home/greatjoe/fipamo/brain/data/Book.inc.php(280): Mni\FrontYAML\Parser->parse() #5 /home/greatjoe/fipamo/brain/utility/Sorting.inc.php(16): Book->getContents() #6 /home/greatjoe/fipamo/brain/data/Settings.inc.php(180): Sorting::tags() #7 /home/greatjoe/fipamo/brain/data/Book.inc.php(187): Settings::updateTags() #8 /home/greatjoe/fipamo/brain/api/v1/PagesAPI.inc.php(142): Book->editPage() #9 /home/greatjoe/fipamo/brain/controller/APIControl.inc.php(172): PagesAPI::handlePageTask() #10 /home/greatjoe/fipamo/brain/controller/RouteControl.inc.php(36): APIControl::post() #11 /home/greatjoe/fipamo/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(43): RouteControl->post() #12 /home/greatjoe/fipamo/vendor/slim/slim/Slim/Routing/Route.php(384): Slim\Handlers\Strategies\RequestResponse->__invoke() #13 /home/greatjoe/fipamo/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Slim\Routing\Route->handle() #14 /home/greatjoe/fipamo/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Slim\MiddlewareDispatcher->handle() #15 /home/greatjoe/fipamo/vendor/slim/slim/Slim/Routing/Route.php(341): Slim\MiddlewareDispatcher->handle() #16 /home/greatjoe/fipamo/vendor/slim/slim/Slim/Routing/RouteRunner.php(84): Slim\Routing\Route->run() #17 /home/greatjoe/fipamo/vendor/slim/twig-view/src/TwigMiddleware.php(125): Slim\Routing\RouteRunner->handle() #18 /home/greatjoe/fipamo/vendor/slim/slim/Slim/MiddlewareDispatcher.php(147): Slim\Views\TwigMiddleware->process() #19 /home/greatjoe/fipamo/vendor/slim/slim/Slim/MiddlewareDispatcher.php(81): Psr\Http\Server\RequestHandlerInterface@anonymous->handle() #20 /home/greatjoe/fipamo/vendor/slim/slim/Slim/App.php(215): Slim\MiddlewareDispatcher->handle() #21 /home/greatjoe/fipamo/vendor/slim/slim/Slim/App.php(199): Slim\App->handle() #22 /home/greatjoe/fipamo/brain/App.inc.php(44): Slim\App->run() #23 /home/greatjoe/fipamo/public/index.php(5): App->__construct() #24 {main} thrown in /home/greatjoe/fipamo/vendor/symfony/yaml/Parser.php on line 815 ``` I've since fixed the crash by going to `/content/pages/start/index.md` and putting `"`s around the title in a different text editor. Likewise adding `"` around the title in Fipamo's editor creates a working title and lets the server run as normal, although opening the file again to edit will not make it display the quotation marks. I'm guessing the fix would be to have the Markdown editor write ``` title:"$usertitle" ``` with quotation marks included, before the YAML parser gets at it and freaks out.
are0h commented 2021-11-14 22:24:03 +01:00 (Migrated from koodu.ubiqueros.com)

Sounds right. I'll take a look at see how it goes.

Sounds right. I'll take a look at see how it goes.
are0h commented 2021-11-14 22:45:57 +01:00 (Migrated from koodu.ubiqueros.com)

I took a look at how the markdown is being saved, changed saving the title to a quoted string and worked like a charm.

I'll push the update to beta when the next milestone is completed.

I took a look at how the markdown is being saved, changed saving the title to a quoted string and worked like a charm. I'll push the update to beta when the next milestone is completed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: projects/fipamo#64
No description provided.