Skip to content

fix(scripts): the frontmatter regex rewrite drops a field ending in a stray CR #1207

Description

@BryanFRD

Raised in review on #1206, merged before the follow-up could land.

#1206 replaced \s*(.*?)\s*$ with (.*)$ plus trim(), and claimed no behaviour change. That held for the alphabet I tested, which had no line terminator in it. . excludes \r, U+2028 and U+2029 while \s includes them, so a line whose value ends in one of them no longer matches at all:

line before #1206 after #1206
title:a + CR a no match, so "frontmatter needs a non-empty title"

Measured over 400,000 random lines including CR, U+2028 and U+2029: 1338 lines where the field is now lost, all of them with the terminator in leading or trailing whitespace.

Not reachable through the normal path, since the block is split on \r?\n first; it takes something like \r\r\n line endings. Still a regression I introduced, and [\s\S]* closes it at no cost.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions