Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-ASCII character in application entity name is disruptive #568

Open
Enet4 opened this issue Oct 6, 2024 · 0 comments
Open

Non-ASCII character in application entity name is disruptive #568

Enet4 opened this issue Oct 6, 2024 · 0 comments
Labels
A-lib Area: library bug This is a bug C-object Crate: dicom-object

Comments

@Enet4
Copy link
Owner

Enet4 commented Oct 6, 2024

This issue already accounts for the fix in #566.
Given the following code:

let mut table = FileMetaTable {
    information_group_length: 0,
    information_version: [0u8, 1u8],
    media_storage_sop_class_uid: "1.2.840.10008.5.1.4.1.1.7".to_owned(),
    media_storage_sop_instance_uid: "2.25.137731752600317795446120660167595746868".to_owned(),
    transfer_syntax: "1.2.840.10008.1.2.4.91".to_owned(),
    implementation_class_uid: "2.25.305828488182831875890203105390285383139".to_owned(),
    implementation_version_name: Some("MYTOOL100".to_owned()),
    source_application_entity_title: Some("RUSTYÀ".to_owned()), // <-- see `À` in there
    receiving_application_entity_title: None,
    sending_application_entity_title: None,
    private_information_creator_uid: None,
    private_information: None,
};

table.update_information_group_length();

let mut buf = vec![b'D', b'I', b'C', b'M'];
table.write(&mut buf).unwrap();

let table2 = FileMetaTable::from_reader(&mut buf.as_slice())
    .expect("Should not fail to read the table from the written data");

assert_eq!(table.information_group_length, table2.information_group_length);

It panics with the following error:

Should not fail to read the table from the written data: DecodeElement {
  source: ReadHeaderTag {
    backtrace: None,
    source: Error {
      kind: UnexpectedEof,
      message: "failed to fill whole buffer"
    }
  }
}

If I add one more character to the source application entity title:

let mut table = FileMetaTable {
    // ...
    source_application_entity_title: Some("RUSTYÀ-".to_owned()), // <--
    // ...
};

It parses correctly but then the information group length no longer matches the version previously calculated.

assertion `left == right` failed
  left: 216
 right: 218

It does not happen if the non-ASCII character is removed. This could have to do with the text encoding/decoding process from dicom-encoding.

@Enet4 Enet4 added bug This is a bug A-lib Area: library C-object Crate: dicom-object labels Oct 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lib Area: library bug This is a bug C-object Crate: dicom-object
Projects
None yet
Development

No branches or pull requests

1 participant