Skip to content

Commit

Permalink
chore: update encoding of multiple xml files
Browse files Browse the repository at this point in the history
  • Loading branch information
dubyte committed Apr 3, 2024
1 parent 3ad9b4f commit dfe1754
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.0.4] - 2024-04-03

### Changed

- Handle encoding on xml header or not encoding.

## [0.0.3] - 2024-04-03

### Changed
Expand Down
7 changes: 6 additions & 1 deletion feedback/feedback.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io"
"os"
"regexp"
"strings"
)

Expand Down Expand Up @@ -81,7 +82,11 @@ func (r *AggregatedReports) ReadFromStdin() error {
return fmt.Errorf("error reading from stdin: %v", err)
}

xmlDocs := strings.Split(string(stdinData), `<?xml version="1.0" encoding="UTF-8" ?>`)
// Split the input data into individual XML documents using a regular expression.
xmlDeclPattern := `\<\?xml version="1.0"( encoding="UTF-8")?\s*\?\>`
re := regexp.MustCompile(xmlDeclPattern)
xmlDocs := re.Split(string(stdinData), -1)

for _, xmlDoc := range xmlDocs {
if strings.TrimSpace(xmlDoc) == "" {
continue
Expand Down

0 comments on commit dfe1754

Please sign in to comment.