forked from MirrorHub/synapse
Merge branch 'develop' into anoa/trailing_slashes_client
This commit is contained in:
commit
a8a028dfce
8 changed files with 57 additions and 19 deletions
1
changelog.d/2090.bugfix
Normal file
1
changelog.d/2090.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix a bug where media with spaces in the name would get a corrupted name.
|
1
changelog.d/4837.bugfix
Normal file
1
changelog.d/4837.bugfix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Fix bug where synapse expected an un-specced `prev_state` field on state events.
|
1
changelog.d/4839.misc
Normal file
1
changelog.d/4839.misc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Disable captcha registration by default in unit tests.
|
|
@ -141,7 +141,6 @@ class EventBase(object):
|
||||||
origin = _event_dict_property("origin")
|
origin = _event_dict_property("origin")
|
||||||
origin_server_ts = _event_dict_property("origin_server_ts")
|
origin_server_ts = _event_dict_property("origin_server_ts")
|
||||||
prev_events = _event_dict_property("prev_events")
|
prev_events = _event_dict_property("prev_events")
|
||||||
prev_state = _event_dict_property("prev_state")
|
|
||||||
redacts = _event_dict_property("redacts")
|
redacts = _event_dict_property("redacts")
|
||||||
room_id = _event_dict_property("room_id")
|
room_id = _event_dict_property("room_id")
|
||||||
sender = _event_dict_property("sender")
|
sender = _event_dict_property("sender")
|
||||||
|
|
|
@ -100,10 +100,29 @@ def add_file_headers(request, media_type, file_size, upload_name):
|
||||||
|
|
||||||
request.setHeader(b"Content-Type", media_type.encode("UTF-8"))
|
request.setHeader(b"Content-Type", media_type.encode("UTF-8"))
|
||||||
if upload_name:
|
if upload_name:
|
||||||
if is_ascii(upload_name):
|
# RFC6266 section 4.1 [1] defines both `filename` and `filename*`.
|
||||||
disposition = "inline; filename=%s" % (_quote(upload_name),)
|
#
|
||||||
|
# `filename` is defined to be a `value`, which is defined by RFC2616
|
||||||
|
# section 3.6 [2] to be a `token` or a `quoted-string`, where a `token`
|
||||||
|
# is (essentially) a single US-ASCII word, and a `quoted-string` is a
|
||||||
|
# US-ASCII string surrounded by double-quotes, using backslash as an
|
||||||
|
# escape charater. Note that %-encoding is *not* permitted.
|
||||||
|
#
|
||||||
|
# `filename*` is defined to be an `ext-value`, which is defined in
|
||||||
|
# RFC5987 section 3.2.1 [3] to be `charset "'" [ language ] "'" value-chars`,
|
||||||
|
# where `value-chars` is essentially a %-encoded string in the given charset.
|
||||||
|
#
|
||||||
|
# [1]: https://tools.ietf.org/html/rfc6266#section-4.1
|
||||||
|
# [2]: https://tools.ietf.org/html/rfc2616#section-3.6
|
||||||
|
# [3]: https://tools.ietf.org/html/rfc5987#section-3.2.1
|
||||||
|
|
||||||
|
# We avoid the quoted-string version of `filename`, because (a) synapse didn't
|
||||||
|
# correctly interpret those as of 0.99.2 and (b) they are a bit of a pain and we
|
||||||
|
# may as well just do the filename* version.
|
||||||
|
if _can_encode_filename_as_token(upload_name):
|
||||||
|
disposition = 'inline; filename=%s' % (upload_name, )
|
||||||
else:
|
else:
|
||||||
disposition = "inline; filename*=utf-8''%s" % (_quote(upload_name),)
|
disposition = "inline; filename*=utf-8''%s" % (_quote(upload_name), )
|
||||||
|
|
||||||
request.setHeader(b"Content-Disposition", disposition.encode('ascii'))
|
request.setHeader(b"Content-Disposition", disposition.encode('ascii'))
|
||||||
|
|
||||||
|
@ -116,6 +135,35 @@ def add_file_headers(request, media_type, file_size, upload_name):
|
||||||
request.setHeader(b"Content-Length", b"%d" % (file_size,))
|
request.setHeader(b"Content-Length", b"%d" % (file_size,))
|
||||||
|
|
||||||
|
|
||||||
|
# separators as defined in RFC2616. SP and HT are handled separately.
|
||||||
|
# see _can_encode_filename_as_token.
|
||||||
|
_FILENAME_SEPARATOR_CHARS = set((
|
||||||
|
"(", ")", "<", ">", "@", ",", ";", ":", "\\", '"',
|
||||||
|
"/", "[", "]", "?", "=", "{", "}",
|
||||||
|
))
|
||||||
|
|
||||||
|
|
||||||
|
def _can_encode_filename_as_token(x):
|
||||||
|
for c in x:
|
||||||
|
# from RFC2616:
|
||||||
|
#
|
||||||
|
# token = 1*<any CHAR except CTLs or separators>
|
||||||
|
#
|
||||||
|
# separators = "(" | ")" | "<" | ">" | "@"
|
||||||
|
# | "," | ";" | ":" | "\" | <">
|
||||||
|
# | "/" | "[" | "]" | "?" | "="
|
||||||
|
# | "{" | "}" | SP | HT
|
||||||
|
#
|
||||||
|
# CHAR = <any US-ASCII character (octets 0 - 127)>
|
||||||
|
#
|
||||||
|
# CTL = <any US-ASCII control character
|
||||||
|
# (octets 0 - 31) and DEL (127)>
|
||||||
|
#
|
||||||
|
if ord(c) >= 127 or ord(c) <= 32 or c in _FILENAME_SEPARATOR_CHARS:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def respond_with_responder(request, responder, media_type, file_size, upload_name=None):
|
def respond_with_responder(request, responder, media_type, file_size, upload_name=None):
|
||||||
"""Responds to the request with given responder. If responder is None then
|
"""Responds to the request with given responder. If responder is None then
|
||||||
|
|
|
@ -1407,21 +1407,6 @@ class EventsStore(StateGroupWorkerStore, EventFederationStore, EventsWorkerStore
|
||||||
values=state_values,
|
values=state_values,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._simple_insert_many_txn(
|
|
||||||
txn,
|
|
||||||
table="event_edges",
|
|
||||||
values=[
|
|
||||||
{
|
|
||||||
"event_id": event.event_id,
|
|
||||||
"prev_event_id": prev_id,
|
|
||||||
"room_id": event.room_id,
|
|
||||||
"is_state": True,
|
|
||||||
}
|
|
||||||
for event, _ in state_events_and_contexts
|
|
||||||
for prev_id, _ in event.prev_state
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
# Prefill the event cache
|
# Prefill the event cache
|
||||||
self._add_to_cache(txn, events_and_contexts)
|
self._add_to_cache(txn, events_and_contexts)
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ CREATE TABLE IF NOT EXISTS event_edges(
|
||||||
event_id TEXT NOT NULL,
|
event_id TEXT NOT NULL,
|
||||||
prev_event_id TEXT NOT NULL,
|
prev_event_id TEXT NOT NULL,
|
||||||
room_id TEXT NOT NULL,
|
room_id TEXT NOT NULL,
|
||||||
|
-- We no longer insert prev_state into this table, so all new rows will have
|
||||||
|
-- is_state as false.
|
||||||
is_state BOOL NOT NULL,
|
is_state BOOL NOT NULL,
|
||||||
UNIQUE (event_id, prev_event_id, room_id, is_state)
|
UNIQUE (event_id, prev_event_id, room_id, is_state)
|
||||||
);
|
);
|
||||||
|
|
|
@ -115,6 +115,7 @@ def default_config(name):
|
||||||
config.signing_key = [MockKey()]
|
config.signing_key = [MockKey()]
|
||||||
config.event_cache_size = 1
|
config.event_cache_size = 1
|
||||||
config.enable_registration = True
|
config.enable_registration = True
|
||||||
|
config.enable_registration_captcha = False
|
||||||
config.macaroon_secret_key = "not even a little secret"
|
config.macaroon_secret_key = "not even a little secret"
|
||||||
config.expire_access_token = False
|
config.expire_access_token = False
|
||||||
config.server_name = name
|
config.server_name = name
|
||||||
|
|
Loading…
Reference in a new issue