diff --git a/login.go b/login.go
index 8329600..a93df7c 100644
--- a/login.go
+++ b/login.go
@@ -2,9 +2,11 @@ package main
import (
"fmt"
+ "html"
"html/template"
"log"
"net/http"
+ "net/url"
"strings"
"github.com/go-ldap/ldap/v3"
@@ -55,16 +57,23 @@ func tryLogin(w http.ResponseWriter, r *http.Request) {
cnt := "
"
for _, e := range entries {
for i, v := range e.Values {
+ safeName := html.EscapeString(e.Name)
+ safeVal := html.EscapeString(v)
+ elemID := fmt.Sprintf("mailAlias-%d", i)
if e.Name == "userPassword" || e.Name == "krbPrincipalKey" {
- cnt += "- " + e.Name + ": [...]
"
+ cnt += "- " + safeName + ": [...]
"
} else if e.Name == "mailAlias" && len(strings.SplitN(v, "@", 2)[0]) == 10 {
- cnt += "- " + e.Name + ": " + v + `
`
+ safeURL := url.PathEscape(v)
+ safeToken := html.EscapeString(apiToken)
+ safeElemID := html.EscapeString(elemID)
+ cnt += `- ` + safeName + `: ` + safeVal +
+ `
`
} else {
- cnt += "- " + e.Name + ": " + v + "
"
+ cnt += "- " + safeName + ": " + safeVal + "
"
}
}
}
- displayTmpl(w, "message.html", map[string]interface{}{"details": template.HTML(`Login ok
Here are the information we have about you:` + cnt + "
To use our Addy.io compatible API, use the following token: " + apiToken + "
")})
+ displayTmpl(w, "message.html", map[string]interface{}{"details": template.HTML(`Login ok
Here are the information we have about you:` + cnt + "To use our Addy.io compatible API, use the following token: " + html.EscapeString(apiToken) + "
")})
}
}