File tree Expand file tree Collapse file tree 1 file changed +15
-7
lines changed
Expand file tree Collapse file tree 1 file changed +15
-7
lines changed Original file line number Diff line number Diff line change @@ -33,14 +33,22 @@ func (a *BasicHMACAuthHandler) Run(input io.Reader, output io.Writer) error {
3333 emitter := proto .NewResponseEmitter (output )
3434
3535 for scanner .Scan () {
36- parts := bytes .SplitN (scanner .Bytes (), []byte {' ' }, 4 )
37- if len (parts ) < 3 {
38- err := fmt .Errorf ("bad request line sent to auth helper: %q" , string (scanner .Bytes ()))
39- return err
36+ line := scanner .Bytes ()
37+
38+ before , after , found := bytes .Cut (line , []byte {' ' })
39+ if ! found {
40+ return fmt .Errorf ("bad request line sent to auth helper: %q" , line )
41+ }
42+ channelID := before
43+
44+ before , after , found = bytes .Cut (after , []byte {' ' })
45+ if ! found {
46+ return fmt .Errorf ("bad request line sent to auth helper: %q" , line )
4047 }
41- channelID := parts [0 ]
42- username := proto .RFC1738Unescape (parts [1 ])
43- password := proto .RFC1738Unescape (parts [2 ])
48+ username := proto .RFC1738Unescape (before )
49+
50+ before , _ , _ = bytes .Cut (after , []byte {' ' })
51+ password := proto .RFC1738Unescape (before )
4452
4553 if verifier .VerifyLoginAndPassword (username , password ) {
4654 if err := emitter .EmitOK (channelID ); err != nil {
You can’t perform that action at this time.
0 commit comments