hide.py icon indicating copy to clipboard operation
hide.py copied to clipboard

Decoding gives error when the input file uses `./`

Open Qix- opened this issue 7 years ago • 2 comments

$ python hide.py -i ./test.png -f ./payload -a encode -p foobar

$ python hide.py -i ./output.png -a decode -p foobar
Saving decoded output as output./payload
Traceback (most recent call last):
  File "hide.py", line 234, in <module>
    main()
  File "hide.py", line 227, in main
    decode(args.image, password=args.password)
  File "hide.py", line 141, in decode
    with open("output"+os.extsep+header.fformat, 'wb') as outf:
IOError: [Errno 2] No such file or directory: 'output./payload'

Qix- avatar Jan 16 '19 13:01 Qix-

I think the primitive filename parser assumes everything after . must be the extension, and saves it in the header when encoding. When it decodes the data it tries to create a file with an invalid extension.

nukeop avatar Jan 16 '19 13:01 nukeop

Why not use os.path.splitext?

Qix- avatar Jan 16 '19 14:01 Qix-