Skip to content

Commit

Permalink
add fix to split to handle an equal sign in the filename.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWheelerMT committed Dec 11, 2024
1 parent 58331ee commit e1e5e37
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 23 deletions.
6 changes: 3 additions & 3 deletions mhs/common/mhs_common/messages/ebxml_envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,12 @@ def parse_external_attachments(xml_tree: Element) -> Dict[str, str]:
description_variables = dict(pair.split("=", 1) for pair in variables)
if "Filename" in description_variables:
filename = description_variables["Filename"].replace('\\', '')

mid = mid_attribute.split(":")[1]
external_attachment = {
external_attachment = {
EXTERNAL_ATTACHMENT_DOCUMENT_ID :document_id_attribute,
EXTERNAL_ATTACHMENT_MESSAGE_ID :mid_attribute.split(":")[1],
EXTERNAL_ATTACHMENT_DESCRIPTION: description,
EXTERNAL_ATTACHMENT_DESCRIPTION: description,
EXTERNAL_ATTACHMENT_TITLE: filename
}

Expand Down
17 changes: 7 additions & 10 deletions mhs/common/mhs_common/messages/tests/test_ebxml_envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,13 @@ def test_cant_find_optional_text_value_during_parsing(self):
self.assertEqual({}, values_dict)

def test_filename_contains_equals_sign(self):
expected_external_attachment1 = {
'document_id': 'EB653254-7854-450E-A3D3-B1711D99D665_adrian=marbles.BMP',
'message_id': 'MESSAGE GOES HERE',
'description': 'DESCRIPTION GOES HERE',
'title': 'EB653254-7854-450E-A3D3-B1711D99D665_adrian=marbles.BMP'
},
expected_external_attachment2 = {
expected_external_attachment = {
'document_id': '_735BB673-D9C0-4B85-951E-98DD045C4713',
'message_id': 'E54DEC57-6BA5-40AB-ACD0-1E383209C034',
'description': 'DESCRIPTION GOES HERE',
'title': 'EB653254-7854-450E-A3D3-B1711D99D665_adrian=marbles.BMP'
'description': 'Filename="735BB673-D9C0-4B85-951E-98DD045C4713_adrian=marbles2.BMP" '
'ContentType=application/octet-stream Compressed=Yes LargeAttachment=No '
'OriginalBase64=No Length=3345444',
'title': '"735BB673-D9C0-4B85-951E-98DD045C4713_adrian=marbles2.BMP"'
}

message = file_utilities.get_file_string(
Expand All @@ -65,5 +61,6 @@ def test_filename_contains_equals_sign(self):
xml_tree = ElementTree.fromstring(message)

external_attachments = ebxml_envelope.EbxmlEnvelope.parse_external_attachments(xml_tree)['external_attachments']
self.assertEqual(external_attachments[0], expected_external_attachment1)

self.assertEqual(external_attachments[0], expected_external_attachment)

Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,12 @@
<eb:Description xml:lang="en">RCMR_IN030000UK07</eb:Description>
<hl7ebxml:Payload style="HL7" encoding="XML" version="3.0" />
</eb:Reference>
<eb:Reference xlink:href="cid:[email protected]/EMISWeb/GP2GP2.2A"
eb:id="_EB653254-7854-450E-A3D3-B1711D99D665"
xmlns:xlink="http://www.w3.org/1999/xlink">
<eb:Description xml:lang="en">Filename="EB653254-7854-450E-A3D3-B1711D99D665_adrian=marbles.BMP"
ContentType=application/octet-stream Compressed=Yes LargeAttachment=No
OriginalBase64=No Length=3345444</eb:Description>
</eb:Reference>
<eb:Reference xlink:href="mid:E54DEC57-6BA5-40AB-ACD0-1E383209C034"
eb:id="_735BB673-D9C0-4B85-951E-98DD045C4713"
xmlns:xlink="http://www.w3.org/1999/xlink">
<eb:Description xml:lang="en">Filename="735BB673-D9C0-4B85-951E-98DD045C4713_adrian=marbles2.BMP"
ContentType=application/octet-stream Compressed=Yes LargeAttachment=No
OriginalBase64=No Length=3345444</eb:Description>
<eb:Description xml:lang="en">
Filename="735BB673-D9C0-4B85-951E-98DD045C4713_adrian=marbles2.BMP" ContentType=application/octet-stream Compressed=Yes LargeAttachment=No OriginalBase64=No Length=3345444
</eb:Description>
</eb:Reference>
</eb:Manifest>
</soap:Body>
Expand Down

0 comments on commit e1e5e37

Please sign in to comment.