binaryninja-api: get_save_filename_input extension filtering fails on Mac

Version and Platform (required):

  • Binary Ninja Version: 4.2.6455-stable
  • OS: macOS Sequoia
  • OS Version: 15.1.1
  • CPU Architecture: arm64

Bug Description: Calling get_save_filename_input on Mac with the ext field filled out opens up the file window and lets you select a file, but you then get an error message saying that the filename does not match the extension, even if it does. Example call: bn.get_save_filename_input("test", ext="h", default_name="test.h") Output: You cannot save this document with extension “.h” at the end of the name. The required extension is “.”.

Steps To Reproduce: Please provide all steps required to reproduce the behavior:

  1. Call get_save_filename_input with a ext argument of “h”.
  2. Select a file in the popup ending in “.h”.
  3. Error message appears saying that the document cannot be saved with that extension, and the required extension is “.”

Expected Behavior: The returned filename should error if the filename does not end in “.h”, and succeed otherwise.

Additional Information: Using ext="*.h" allows you to get the filename successfully, but doesn’t match the pattern in the documentation. And if you pick a filename without “.h” at the end, it will append a “.h” to the returned filename. Using ext=".h" also fails with the error message You cannot save this document with extension “.h” at the end of the name. The required extension is “.h”. The call works with the argument “.h” on Windows 10 Enterprise.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (17 by maintainers)

Most upvoted comments

Hi all. As described in https://github.com/qt/qtbase/commit/5dabb905e7f2902345b2110d9ceda33236b5f64a, due to idiosyncrasies in NSSavePanel we had to add some manual logic to handle file name filters. That logic was based on the documented format for QFileDialog, which is *.foo, not foo.

Filing an upstream bug report about this so we can track it makes sense, but it’s not likely to get any immediate attention due to its low priority, so I would recommend fixing this in your get_save_filename_input implementation instead, adding a *. prefix before passing it on to Qt, if needed.

Survey says: It broke when we changed Qt versions. Time to diff the qt code base and see what happened there, I guess.

Thank you! I understand the change now. All good. The example above led me to believe that the third parameter was going to be nuked with this change:

Image

I see just a misunderstanding. Thanks for working on all this!

Will be out in builds >= 4.3.6733

My solution for this is to check for the unexpected syntax in the binja function and modify it before passing it to Qt. The documentation is being updated to represent the documented behavior in Qt, but as a fallback the other style should work too (but is no longer our documented way of doing it).

It doesn’t look like a macOS change-- I can successfully reproduce the old behavior using binja 4.1 on the same machine where 4.2 does not work. I’m grepping through the diff between those versions to see if it was anything we changed (or if it actually was Qt’s fault)