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 |
} |