Files
Reims-Go/internal/app/runtime_bindings_test.go
T
Dnyo666 3ab04c3627 fix(runtime,guesttools,app): harden fallback channel isolation, guest config escaping, and OpenURL validation
Fail closed in listRemoteWeb when release tag HTML cannot be verified and sort entries with sortRemotesNewestFirst; bump Guest Tools agent_version and DriveShareAgentVersion to 8, single-quote escape config values with 0600 permissions, harden mount_drive_readonly (fd 3 read-only at offset 0, parent symlink/VM/byte-length checks, ENVIRON in awk); validate external HTTPS URLs via net/url in OpenURL; add regression unit tests for all three.
2026-12-01 18:53:40 +08:00

35 lines
908 B
Go

package app
import "testing"
func TestValidateExternalHTTPSURL(t *testing.T) {
valid := []string{
"https://github.com/Nwflower/Reims-Go",
" https://discord.gg/Tj682rW5rS ",
"https://github.com/Nwflower/Reims-Go/releases/tag/v0.2.10?foo=1#notes",
}
for _, raw := range valid {
if _, err := validateExternalHTTPSURL(raw); err != nil {
t.Errorf("validateExternalHTTPSURL(%q) unexpected error: %v", raw, err)
}
}
invalid := []string{
"",
"http://example.com",
"javascript:alert(1)",
"file:///C:/Windows/System32/calc.exe",
"https://",
"https://user:pass@example.com/path",
"https://example.com/a b",
"https://example.com/a\nfoo",
"https://example.com/\"quoted\"",
"https://example.com/a\x00b",
}
for _, raw := range invalid {
if got, err := validateExternalHTTPSURL(raw); err == nil {
t.Errorf("validateExternalHTTPSURL(%q) = %q, want error", raw, got)
}
}
}