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

In Synapse Admin API's Rooms query seach_term don't accept non-ASCII characters #10841

Closed
MurzNN opened this issue Sep 17, 2021 · 2 comments · Fixed by #10859
Closed

In Synapse Admin API's Rooms query seach_term don't accept non-ASCII characters #10841

MurzNN opened this issue Sep 17, 2021 · 2 comments · Fixed by #10859
Assignees
Labels
A-Admin-API good first issue Good for newcomers T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements.

Comments

@MurzNN
Copy link

MurzNN commented Sep 17, 2021

Description

Not all rooms use English characters, but In Synapse Admin API's Rooms query seach_term don't accept non-ASCII characters.

Steps to reproduce

For example query to search rooms with Russian symbol "ж" using path /_synapse/admin/v1/rooms?dir=f&from=0&limit=10&order_by=name&search_term=%D0%B6 shows the error:

{
  "errcode":"M_UNKNOWN",
  "error":"Query parameter 'search_term' must be ascii"
}

Version information

  • Synapse Version:
    "server_version": "1.42.0",
    "python_version": "3.8.10"
@DMRobertson DMRobertson added T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements. X-Needs-Discussion A-Admin-API good first issue Good for newcomers labels Sep 17, 2021
@DMRobertson
Copy link
Contributor

DMRobertson commented Sep 17, 2021

Thanks for the report. Looks like the call to parse_string here

search_term = parse_string(request, "search_term")
assumes an encoding of ascii by default. I wonder if it suffices to relax this to encoding="utf-8"? get_rooms_paginate claims to accept any string. We'll end up searching based on room_name LIKE %search_term%. We strongly recommend configuring postgres to use the C.UTF-8 locale; if so, I think that query might just work?

@MurzNN
Copy link
Author

MurzNN commented Sep 17, 2021

For me the raw SQL query works well:

# SELECT COUNT(*) FROM room_stats_state WHERE "name" LIKE '%ж%';
 count 
-------
    32
(1 row)

# show LC_COLLATE;
 lc_collate 
------------
 C
(1 row)

# SHOW SERVER_ENCODING;
 server_encoding 
-----------------
 UTF8
(1 row)

And encoding is ok too:

                                             List of databases
       Name       |    Owner     | Encoding |   Collate   |    Ctype    |         Access privileges         
------------------+--------------+----------+-------------+-------------+-----------------------------------
 synapse          | postgres     | UTF8     | C           | C           | =Tc/postgres                     +

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Admin-API good first issue Good for newcomers T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants