From 3fa745ebe39d2ba48af4848fa2ac0847089e1743 Mon Sep 17 00:00:00 2001 From: Steve Howell Date: Tue, 26 Jul 2016 16:49:26 -0700 Subject: [PATCH] Remove untested code in is_public_stream(). We were calling valid_stream_name(), but more appropriate validation checks for stream names happen elsewhere in the codepath. --- zerver/views/messages.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/zerver/views/messages.py b/zerver/views/messages.py index 66c7aef3ec..7f2f9eccc7 100644 --- a/zerver/views/messages.py +++ b/zerver/views/messages.py @@ -29,7 +29,7 @@ from zerver.lib.validator import \ check_list, check_int, check_dict, check_string, check_bool from zerver.models import Message, UserProfile, Stream, Subscription, \ Recipient, UserMessage, bulk_get_recipients, get_recipient, \ - get_user_profile_by_email, get_stream, valid_stream_name, \ + get_user_profile_by_email, get_stream, \ parse_usermessage_flags, to_dict_cache_key_id, extract_message_dict, \ stringify_message_dict, \ resolve_email_to_domain, get_realm, get_active_streams, \ @@ -322,8 +322,16 @@ def narrow_parameter(json): return list(map(convert_term, data)) def is_public_stream(stream, realm): - if not valid_stream_name(stream): - raise JsonableError(_("Invalid stream name")) + """ + Determine whether a stream is public, so that + our caller can decide whether we can get + historical messages for a narrowing search. + + Because of the way our search is currently structured, + we may be passed an invalid stream here. We return + False in that situation, and subsequent code will do + validation and raise the appropriate JsonableError. + """ stream = get_stream(stream, realm) if stream is None: return False