ImHex icon indicating copy to clipboard operation
ImHex copied to clipboard

[Bug] JSON export of Pattern Data contains undesired characters

Open speters opened this issue 1 year ago • 3 comments

Operating System

Linux

What's the issue you encountered?

Exported string Pattern Data in JSON file contains the complete contents of the "Value" column field with quotation marks and a trailing space in URL-encoded form: image

A similar observation can be made with strings containing zero bytes, where the backlash-representation of the Pattern Data display is encoded in the JSON data.

Expected behaviour: JSON field just contains the URL-encoded data.

How can the issue be reproduced?

Test case containing file i as data provider, i.hexproj as ImHex project with pattern and i.json as exported data: test.zip

General procedure to reproduce:

  • Load data provider containing string/char data.
  • set up a pattern file to read some char name[len] @ addr
  • run pattern
  • observe Pattern Data output value field and compare with exported JSON

ImHex Version

v1.32.2

ImHex Build Type

  • [ ] Nightly or built from sources

Installation type

Arch package from GH releases

Additional context?

No response

speters avatar Jan 15 '24 07:01 speters

I have a similar experience except I am running on windows 10 ans using the plcli in format mode. when i run the pattern in Imhex the output string looks fine:

image

however the json output I get from plcli is:

{
    "test": {
        "array": [
            135,
            121,
            152,
            135
        ],
        "chars": "-------%20With%20%23define%20%3A----------"
    }
}

Also I exported to json the data in imhex and got this output:

{
    "test": {
        "array": [
            135,
            121,
            152,
            135
        ],
        "chars": "%22-------%20With%20%23define%20%3A----------%22%20"
    }
}

paxcut avatar Jan 27 '24 04:01 paxcut

Probably it's caused because we take the whole displayed string instead of the inner value

PerikiyoXD avatar Jan 28 '24 00:01 PerikiyoXD

Also present in yaml and HTML strings and magics (but not on static strings, I'd say)

dlabz avatar Jan 28 '24 00:01 dlabz