Merge pull request #985 from zlabjp/avoid-id-beginning-with-number

bugfix: avoid generating an invalid ID attribute in SAML's AuthenRequest element
This commit is contained in:
rithu leena john 2017-07-10 09:42:37 -07:00 committed by GitHub
commit 377d9b44b7

View File

@ -30,8 +30,8 @@ func NewID() string {
if _, err := io.ReadFull(rand.Reader, buff); err != nil {
panic(err)
}
// Trim padding
return strings.TrimRight(encoding.EncodeToString(buff), "=")
// Avoid the identifier to begin with number and trim padding
return string(buff[0]%26+'a') + strings.TrimRight(encoding.EncodeToString(buff[1:]), "=")
}
// GCResult returns the number of objects deleted by garbage collection.