Skip to content

XML validation error when using the -x flag due to unescaped special characters #15

@imertz

Description

@imertz

Problem

When using the -x flag to export a Git repository as XML, the tool fails with the following error:

Error: XML validation error on line 494: invalid character entity & (no semicolon)

Steps to Reproduce

  1. Clone any repository containing files with special XML characters (like '&')
  2. Run the following command:
    git2gpt -x -s -e -o output.xml /path/to/repository
  3. Observe the XML validation error

Cause

The issue is in the OutputGitRepoXML function in prompt/prompt.go. The current implementation doesn't properly escape special characters in XML content or handle CDATA sections correctly.

Special XML characters (&, <, >, ", ') need proper escaping when outside CDATA sections, and the CDATA terminator sequence ]]> needs special handling when it appears within file contents.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions