-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix invalid XML template for metainfo, causing MacOS to fail on speci…
…al chars
- Loading branch information
Showing
2 changed files
with
47 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package main | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
// TestReplacePlaceholders checks if the placeholders are replaced and escaped correctly | ||
func TestReplacePlaceholders(t *testing.T) { | ||
os.Setenv("LAUNCHER_BINARY", "launcher&binary") | ||
launcherConfig = &config.LauncherConfig{ | ||
VendorName: "Example<Vendor>", | ||
BrandingName: "Brand\"Name", | ||
BrandingNameShort: "Short'Name", | ||
ReverseDnsProductId: "com.example>product", | ||
ProductVersion: config.ProductVersionStruct{ | ||
Major: 1, | ||
Minor: 2, | ||
Patch: 3, | ||
Build: 4, | ||
}, | ||
} | ||
|
||
versionSemantic = "1.2.3" | ||
versionFull = "1.2.3.4" | ||
|
||
// Simulating a template with all placeholders | ||
template := `${LAUNCHER_BINARY} ${LAUNCHER_BINARY_EXT} ${LAUNCHER_VENDOR_NAME} ${LAUNCHER_BRANDING_NAME} ${LAUNCHER_BRANDING_NAME_SHORT} ${LAUNCHER_REVERSE_DNS_PRODUCT_ID} ${LAUNCHER_VERSION_MAJOR} ${LAUNCHER_VERSION_MINOR} ${LAUNCHER_VERSION_PATCH} ${LAUNCHER_VERSION_BUILD} ${LAUNCHER_VERSION_SEMANTIC} ${LAUNCHER_VERSION_FULL}` | ||
|
||
expected := `launcher&binary ${LAUNCHER_BINARY_EXT} Example<Vendor> Brand"Name Short'Name com.example>product 1 2 3 4 1.2.3 1.2.3.4` | ||
result := replacePlaceholders(template) | ||
|
||
if result != expected { | ||
t.Errorf("Expected '%s', got '%s'", expected, result) | ||
} | ||
} |