diff --git a/swift/common/middleware/name_check.py b/swift/common/middleware/name_check.py index c2ddbbaf0f..c6fb974011 100644 --- a/swift/common/middleware/name_check.py +++ b/swift/common/middleware/name_check.py @@ -79,12 +79,7 @@ class NameCheckMiddleware(object): self.logger.debug("name_check: self.forbidden_chars %s" % self.forbidden_chars) - for c in unquote(req.path): - if c in self.forbidden_chars: - return True - else: - pass - return False + return any((c in unquote(req.path)) for c in self.forbidden_chars) def check_length(self, req): ''' @@ -93,10 +88,7 @@ class NameCheckMiddleware(object): Returns False if the length is <= the maximum ''' length = len(unquote(req.path)) - if length > self.maximum_length: - return True - else: - return False + return length > self.maximum_length def check_regexp(self, req): '''