Skip to content

Commit

Permalink
Ignore not recognized characters (RedHatInsights#1471)
Browse files Browse the repository at this point in the history
There is an emoji in the last name, decoding it in utf-8 is failing
due to not recognized chars.
  • Loading branch information
astrozzc authored Jan 28, 2025
1 parent 36191d5 commit 1988e7b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion rbac/management/principal/cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ def process_umb_event(frame, umb_client: Stomp, bootstrap_service: TenantBootstr
return False

try:
data_dict = xmltodict.parse(frame.body)
body = frame.body.decode("utf-8", errors="ignore")
data_dict = xmltodict.parse(body)
canonical_message = data_dict.get("CanonicalMessage")

user = retrieve_user_info(canonical_message)
Expand Down
2 changes: 1 addition & 1 deletion tests/management/principal/test_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def test_principal_cleanup_principal_error(self, mock_request):
b'<Reference system="EBS" entity-name="Account" qualifier="number">11111111</Reference>\n '
b'</Identifiers>\n <Status primary="true">\n <State>Active</State>\n '
b"</Status>\n <Person>\n <FirstName>Test</FirstName>\n "
b"<LastName>Principal</LastName>\n <Salutation>Mr.</Salutation>\n <Title>QE</Title>\n "
b"<LastName>Principal \xed\xa0\xbd\xed\xb8\x8e</LastName>\n <Salutation>Mr.</Salutation>\n <Title>QE</Title>\n "
b"<Credentials>\n <Login>principal-test</Login>\n </Credentials>\n "
b"</Person>\n <Company>\n <Name>Shakespeare Birthplace Trust</Name>\n "
b"</Company>\n <Address>\n <Identifiers>\n <AuthoringOperatingUnit>\n"
Expand Down

0 comments on commit 1988e7b

Please sign in to comment.