Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Unified Diff: impl/memory/globalinfo.go

Issue 1253263002: Make rawdatastore API safer for writing filters. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix comments Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « impl/dummy/dummy_test.go ('k') | impl/memory/raw_datastore.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/memory/globalinfo.go
diff --git a/impl/memory/globalinfo.go b/impl/memory/globalinfo.go
index f5a21b1969359b7bf2484d121c02d0b38f7b9776..ea15b88553ed261044aff68e5f49c5e62efe708e 100644
--- a/impl/memory/globalinfo.go
+++ b/impl/memory/globalinfo.go
@@ -5,16 +5,21 @@
package memory
import (
- "golang.org/x/net/context"
+ "fmt"
+ "regexp"
"github.com/luci/gae/impl/dummy"
"github.com/luci/gae/service/info"
+ "golang.org/x/net/context"
)
type giContextKeyType int
var giContextKey giContextKeyType
+// validNamespace matches valid namespace names.
+var validNamespace = regexp.MustCompile(`^[0-9A-Za-z._-]{0,100}$`)
+
func curGID(c context.Context) *globalInfoData {
return c.Value(giContextKey).(*globalInfoData)
}
@@ -45,7 +50,14 @@ type giImpl struct {
var _ = info.Interface((*giImpl)(nil))
+func (gi *giImpl) GetNamespace() string {
+ return gi.namespace
+}
+
func (gi *giImpl) Namespace(ns string) (ret context.Context, err error) {
+ if !validNamespace.MatchString(ns) {
+ return nil, fmt.Errorf("appengine: namespace %q does not match /%s/", ns, validNamespace)
+ }
return context.WithValue(gi.c, giContextKey, &globalInfoData{ns}), nil
}
« no previous file with comments | « impl/dummy/dummy_test.go ('k') | impl/memory/raw_datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698