@@ -0,0 +1,1539 @@
+import pytest%0Aimport fixtures%0A%0Aimport dnfile%0A%0A%0Adef test_unpaired_surrogate():%0A    path = fixtures.DATA / %22invalid-strings%22 / %22unpaired-surrogate.exe%22%0A%0A    dn = dnfile.dnPE(path)%0A%0A    assert dn.net is not None%0A    assert dn.net.metadata is not None%0A    assert dn.net.user_strings is not None%0A%0A    assert b%22#US%22 in dn.net.metadata.streams%0A    assert dn.net.user_strings.get(1) == b%22%5CxD0%5CxDD%22%0A    with pytest.raises(UnicodeDecodeError):%0A        assert dn.net.user_strings.get_us(1)%0A%0A%0Adef test_raw_binary():%0A    path = fixtures.DATA / %22invalid-strings%22 / %22raw-binary.exe%22%0A%0A    dn = dnfile.dnPE(path)%0A%0A    assert dn.net is not None%0A    assert dn.net.metadata is not None%0A    assert dn.net.user_strings is not None%0A%0A    # short MZ header%0A    assert b%22#US%22 in dn.net.metadata.streams%0A    assert dn.net.user_strings.get(1) == b%22%5Cx4D%5Cx5A%5Cx90%5Cx00%22%0A%0A    # somehow this is valid utf-16%0A    s = dn.net.user_strings.get_us(1)%0A    assert s is not None%0A    assert s.value == b%22%5Cx4D%5Cx5A%5Cx90%5Cx00%22.decode(%22utf-16%22)%0A%0A%0Adef test_string_decoder():%0A    path = fixtures.DATA / %22invalid-strings%22 / %22string-decoder.exe%22%0A%0A    dn = dnfile.dnPE(path)%0A%0A    assert dn.net is not None%0A    assert dn.net.metadata is not None%0A    assert dn.net.user_strings is not None%0A%0A    # %22Hello World%22 %5E 0xFF%0A    assert b%22#US%22 in dn.net.metadata.streams%0A    assert dn.net.user_strings.get(1) == b%22%5Cxb7%5Cxff%5Cx9a%5Cxff%5Cx93%5Cxff%5Cx93%5Cxff%5Cx90%5Cxff%5Cxdf%5Cxff%5Cxa8%5Cxff%5Cx90%5Cxff%5Cx8d%5Cxff%5Cx93%5Cxff%5Cx9b%5Cxff%22%0A%0A    # somehow this is valid utf-16%0A    s = dn.net.user_strings.get_us(1)%0A    assert s is not None%0A

add tests demonstrating how to handle invalid UTF-16 strings