Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML Encode the windows XML data #3722

Merged
merged 3 commits into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need the wrapper function nor the tests if we are to use the built in function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that HTML and XML are not actually the same I felt the clarity was helpful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

}
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