Skip to content

Angle brackets < > are escaped in git log #256

Description

@Abibibi

Description

The build-commit.js file includes this implementation:

const escapeSpecialChars = (result) => {
  // eslint-disable-next-line no-useless-escape, prettier/prettier
  const specialChars = ['`', '"', '\\$', '!', '<', '>', '&']
  let newResult = result

  specialChars.forEach((item) => {
    // If user types `feat: "string"`, the commit preview should show `feat: \"string\"`.
    // Don't worry. The git log will be `feat: "string"`
    newResult = newResult.replace(new RegExp(item, 'g'), `\\${item}`)
  })

  return newResult
}

This code includes this comment:

// If user types `feat: "string"`, the commit preview should show `feat: \"string\"`.
// Don't worry. The git log will be `feat: "string"`

However, when using angle brackets < and >, the \ are still displayed in the git log.

Example

When including a Co-Authored-By trailer in my commit:

Co-Authored-By: Abeba NGWE <abeba.ngwe@example.com>

Here is the result:

Stage Result
Preview Co-Authored-By: Abeba NGWE \<abeba.ngwe@example.com\>
Git log Co-Authored-By: Abeba NGWE \<abeba.ngwe@example.com\>

The backslashes remain in the actual git commit message for < and >, breaking the standard Co-Authored-By format.

How can this be fixed, @leonardoanalista?

Versions

  • cz-customizable: 7.5.4
  • Node: v22.x
  • OS: macOS

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