mirror of
https://github.com/astaxie/beego.git
synced 2025-07-10 08:30:18 +00:00
fix index out of range
when sid len = 1
add unit test for sess_file.go
This commit is contained in:
@ -15,11 +15,11 @@
|
||||
package session
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"errors"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -180,6 +180,10 @@ func (fp *FileProvider) SessionExist(sid string) bool {
|
||||
filepder.lock.Lock()
|
||||
defer filepder.lock.Unlock()
|
||||
|
||||
if len(sid) < 2 {
|
||||
return false
|
||||
}
|
||||
|
||||
_, err := os.Stat(path.Join(fp.savePath, string(sid[0]), string(sid[1]), sid))
|
||||
return err == nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user