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

Jekyll: unquoted dates in frontmatter cause a crash #511

Closed
markstos opened this issue Jun 6, 2022 · 0 comments
Closed

Jekyll: unquoted dates in frontmatter cause a crash #511

markstos opened this issue Jun 6, 2022 · 0 comments

Comments

@markstos
Copy link
Contributor

markstos commented Jun 6, 2022

In frontmatter, dates can be quoted as strings, or unquoted.

The Jekyll migration tool works for the case when the date is quoted, but it has no test coverage for unquoted dates and crashes in that case.

The difference is that the front-matter library will parse the date directly into a date object if it's not quoted. Because the importing code only expects strings, it fails like this:

 TypeError: frontmatterAttributes.date.match is not a function

To trigger it in the test suite, add a post with a date formatting like this:

date: 2022-06-05

(With no quotes around the date!)

Look into this uncovered another minor issue with date handing: If front-matter parses a date with no time, it will set the time to midnight. But if the Jekyll importing code parses a date with no time as string, the time gets set to noon. For consistency, the importing code should just not set the hour, minute and second fields in the date object so the default values are used.

markstos added a commit to markstos/migrate that referenced this issue Jun 7, 2022
Unlike quoted dates, the underlying js-yaml library parses these
directly into date objects.

Fixes TryGhost#511
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