Skip to content

Commit

Permalink
Merge pull request #3722 from andydotxyz/fix/3195
Browse files Browse the repository at this point in the history
XML Encode the windows XML data
  • Loading branch information
andydotxyz committed Mar 12, 2023
2 parents 99715c6 + ad59b28 commit 2ff2298
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
9 changes: 9 additions & 0 deletions cmd/fyne/internal/commands/encode.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package commands

import (
"html"
)

func encodeXMLString(in string) string {
return html.EscapeString(in)
}
16 changes: 16 additions & 0 deletions cmd/fyne/internal/commands/encode_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package commands

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestEncodeXMLString(t *testing.T) {
assert.Equal(t, "", encodeXMLString(""))
assert.Equal(t, "Hello", encodeXMLString("Hello"))
assert.Equal(t, "Hi & bye", encodeXMLString("Hi & bye"))
assert.Equal(t, "Hi & bye", encodeXMLString("Hi & bye"))

assert.Equal(t, "Hi &lt;&gt; bye", encodeXMLString("Hi <> bye"))
}
4 changes: 2 additions & 2 deletions cmd/fyne/internal/commands/package-windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (p *Packager) packageWindows(tags []string) error {
return fmt.Errorf("failed to decode source image: %w", err)
}

icoPath := filepath.Join(exePath, p.Name+".ico")
icoPath := filepath.Join(exePath, "FyneApp.ico")
file, err := os.Create(icoPath)
if err != nil {
return fmt.Errorf("failed to open image file: %w", err)
Expand All @@ -59,7 +59,7 @@ func (p *Packager) packageWindows(tags []string) error {
manifestFile, _ := os.Create(manifest)

tplData := windowsData{
Name: p.Name,
Name: encodeXMLString(p.Name),
CombinedVersion: p.combinedVersion(),
}
err := templates.ManifestWindows.Execute(manifestFile, tplData)
Expand Down
6 changes: 3 additions & 3 deletions cmd/fyne/internal/commands/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@ func (r *Releaser) packageWindowsRelease(outFile string) error {
manifestData := struct{ AppID, Developer, DeveloperName, Name, Version string }{
AppID: r.AppID,
// TODO read this info
Developer: r.developer,
DeveloperName: r.nameFromCertInfo(r.developer),
Name: r.Name,
Developer: encodeXMLString(r.developer),
DeveloperName: encodeXMLString(r.nameFromCertInfo(r.developer)),
Name: encodeXMLString(r.Name),
Version: r.combinedVersion(),
}
err = templates.AppxManifestWindows.Execute(manifest, manifestData)
Expand Down

0 comments on commit 2ff2298

Please sign in to comment.