Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

comment out code that removes trailing slash as per 5823. #11224

Closed
Prev Previous commit
Next Next commit
fix path slash issue.
  • Loading branch information
src-r-r committed Nov 20, 2021
commit 68fa11bcc6cf3dc3659b91786da80cad40ae4c7b
4 changes: 2 additions & 2 deletions synapse/config/sso.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ def read_config(self, config, **kwargs):
# the client's.

_b_url = self.root.server.public_baseurl or "/"
if not _b_url.endswith("/"):
_b_url = _b_url + "/"
if _b_url.endswith("/"):
_b_url = _b_url[:-1]
login_fallback_url = (
_b_url + "_matrix/static/client/login"
)
Expand Down
4 changes: 2 additions & 2 deletions synapse/handlers/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ def __init__(
# We'll insert this into the Path= parameter of any session cookies we set.
public_baseurl_path = urlparse(hs.config.server.public_baseurl).path
_b_url = public_baseurl_path
if not _b_url.endswith("/"):
_b_url = _b_url + "/"
if _b_url.endswith("/"):
_b_url = _b_url[:-1]
self._callback_path_prefix = (
_b_url.encode("utf-8") + b"_synapse/client/oidc"
)
Expand Down
4 changes: 2 additions & 2 deletions synapse/module_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ def public_baseurl(self) -> str:
Added in Synapse v1.39.0.
"""
_b_url = self._hs.config.server.public_baseurl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As below, isn't the public_baseurl never going to end in a "/" and so I think line +358 will never run?

if not _b_url.endswith("/"):
_b_url = _b_url + "/"
if _b_url.endswith("/"):
_b_url = _b_url[:-1]
return _b_url

@property
Expand Down
4 changes: 2 additions & 2 deletions synapse/rest/client/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ async def on_GET(self, request: SynapseRequest, stagetype: str) -> None:
)
elif stagetype == LoginType.TERMS:
_b_url = self.hs.config.server.public_baseurl
if not _b_url.endswith("/"):
_b_url = _b_url + "/"
if _b_url.endswith("/"):
_b_url = _b_url[:-1]
html = self.terms_template.render(
session=session,
terms_url="%s_matrix/consent?v=%s"
Expand Down
4 changes: 2 additions & 2 deletions synapse/rest/well_known.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ def get_well_known(self) -> Optional[JsonDict]:
return None

_b_url = self._config.server.public_baseurl
if not _b_url.endswith("/"):
_b_url = _b_url + "/"
if _b_url.endswith("/"):
_b_url = _b_url[:-1]

result = {"m.homeserver": {"base_url": _b_url, }}

Expand Down
2 changes: 1 addition & 1 deletion tests/push/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def test_room_notifications_include_avatar(self):

# The other users send some messages.
# TODO It seems that two messages are required to trigger an email?
self.helper.send(room, body="Alpha", tok=self.others[0].token)
send_event = self.helper.send(room, body="Alpha", tok=self.others[0].token)
self.helper.send(room, body="Beta", tok=self.others[1].token)

# We should get emailed about those messages
Expand Down
2 changes: 2 additions & 0 deletions tests/rest/test_well_known.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ def create_test_resource(self):
{
"public_baseurl": "https://tesths",
"default_identity_server": "https://testis",
"serve_server_wellknown": True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are testing the client wellknown here---this doesn't look right.

}
)
def test_client_well_known(self):
channel = self.make_request(
"GET", "/.well-known/matrix/client", shorthand=False
)

# import ipdb; ipdb.set_trace()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this needs removing.

self.assertEqual(channel.code, 200)
self.assertEqual(
channel.json_body,
Expand Down
3 changes: 2 additions & 1 deletion tests/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def make_request(
):
if path.startswith(b"/"):
path = path[1:]
path = b"/_matrix/client/r0/" + path
path = b"_matrix/client/r0/" + path

if not path.startswith(b"/"):
path = b"/" + path
Expand Down Expand Up @@ -323,6 +323,7 @@ def make_request(
req.requestReceived(method, path, b"1.1")

if await_result:
import ipdb; ipdb.set_trace()
channel.await_result()

return channel
Expand Down