aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/cgi/host.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/http/cgi/host.go')
-rw-r--r--src/net/http/cgi/host.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/net/http/cgi/host.go b/src/net/http/cgi/host.go
index 1ae66e097c..9b4d875418 100644
--- a/src/net/http/cgi/host.go
+++ b/src/net/http/cgi/host.go
@@ -77,15 +77,15 @@ type Handler struct {
// Env: []string{"SCRIPT_FILENAME=foo.php"},
// }
func removeLeadingDuplicates(env []string) (ret []string) {
- n := len(env)
- for i := 0; i < n; i++ {
- e := env[i]
- s := strings.SplitN(e, "=", 2)[0]
+ for i, e := range env {
found := false
- for j := i + 1; j < n; j++ {
- if s == strings.SplitN(env[j], "=", 2)[0] {
- found = true
- break
+ if eq := strings.IndexByte(e, '='); eq != -1 {
+ keq := e[:eq+1] // "key="
+ for _, e2 := range env[i+1:] {
+ if strings.HasPrefix(e2, keq) {
+ found = true
+ break
+ }
}
}
if !found {