Merge pull request #4740 from zh199225/develop

set a default value "/" for "Path" in the Cookie function when there is not parameter "Path" or the parameter is ""
This commit is contained in:
Ming Deng 2021-08-20 17:53:38 +08:00
commit 745dcf1ead
4 changed files with 7 additions and 12 deletions

View File

@ -58,8 +58,8 @@
- Refactor: Move `BindXXX` and `XXXResp` methods to `context.Context`. [4718](https://github.com/beego/beego/pull/4718)
- Fix 4728: Print wrong file name. [4737](https://github.com/beego/beego/pull/4737)
- fix bug:reflect.ValueOf(nil) in getFlatParams [4715](https://github.com/beego/beego/pull/4715)
- Fix 4736: set a fixed value "/" to the "Path" of "_xsrf" cookie. [4736](https://github.com/beego/beego/issues/4735)
- Fix 4734: do not reset id in Delete function. [4738](https://github.com/beego/beego/pull/4738)
- Fix 4736: set a fixed value "/" to the "Path" of "_xsrf" cookie. [4736](https://github.com/beego/beego/issues/4735) [4739](https://github.com/beego/beego/issues/4739)
- Fix 4734: do not reset id in Delete function. [4738](https://github.com/beego/beego/pull/4738) [4742](https://github.com/beego/beego/pull/4742)
## Fix Sonar

View File

@ -715,13 +715,6 @@ func (d *dbBase) Delete(ctx context.Context, q dbQuerier, mi *modelInfo, ind ref
return 0, err
}
if num > 0 {
if mi.fields.pk.auto {
if mi.fields.pk.fieldType&IsPositiveIntegerField > 0 {
ind.FieldByIndex(mi.fields.pk.fieldIndex).SetUint(0)
} else {
ind.FieldByIndex(mi.fields.pk.fieldIndex).SetInt(0)
}
}
err := d.deleteRels(ctx, q, mi, args, tz)
if err != nil {
return num, err

View File

@ -2403,8 +2403,10 @@ func TestReadOrCreate(t *testing.T) {
throwFail(t, AssertIs(nu.Status, u.Status))
throwFail(t, AssertIs(nu.IsStaff, u.IsStaff))
throwFail(t, AssertIs(nu.IsActive, u.IsActive))
assert.True(t, u.ID > 0)
dORM.Delete(u)
assert.True(t, u.ID > 0)
}
func TestInLine(t *testing.T) {

View File

@ -118,13 +118,13 @@ func (output *BeegoOutput) Cookie(name string, value string, others ...interface
// can use nil skip set
// default "/"
tmpPath := "/"
if len(others) > 1 {
if v, ok := others[1].(string); ok && len(v) > 0 {
fmt.Fprintf(&b, "; Path=%s", sanitizeValue(v))
tmpPath = sanitizeValue(v)
}
} else {
fmt.Fprintf(&b, "; Path=%s", "/")
}
fmt.Fprintf(&b, "; Path=%s", tmpPath)
// default empty
if len(others) > 2 {