Tk Source Code

View Ticket
Login
Ticket UUID: 1083878
Title: Wrong handling of mac file type with embedded nulls
Type: Bug Version: obsolete: 8.5a3
Submitter: vincentdarley Created on: 2004-12-12 15:21:50
Subsystem: 33. Generic Dialog Support Assigned To: dgp
Priority: 7 High Severity:
Status: Closed Last Modified: 2005-04-05 20:56:36
Resolution: Accepted Closed By: dgp
    Closed on: 2005-04-05 13:56:36
Description:
A command like:

tk_getOpenFile -filetypes {{{Allowed files} {} {TEXT
\0\0\0\0 ????}}}

should open a dialog allowing any text file or any file
with no file type to be selected.  Instead no dialog is
opened and an immediate error is returned:

bad Macintosh file type ""

This is because the code in tkFileFilter.c (around line
236) can't cope with embedded NULLs in file types:

        for (i=0; i<ostypeCount; i++) {
            if (strlen(ostypeList[i]) != 4) {
                Tcl_AppendResult(interp, "bad Macintosh
file type \"",
                    ostypeList[i], "\"", NULL);
                code = TCL_ERROR;
                goto done;
            }
        }

the 'strlen' call above is just wrong.

Vince.
User Comments: dgp added on 2005-04-05 20:56:36:
Logged In: YES 
user_id=80530

dlg.diff patch committed.

vincentdarley added on 2005-02-15 05:47:42:
Logged In: YES 
user_id=32170

Note, it's the dlg.diff patch that needs applying.

vincentdarley added on 2005-01-19 19:12:54:
Logged In: YES 
user_id=32170

Changed resolution and priority until actually fixed.  Patch
is available -- just needs testing.

vincentdarley added on 2005-01-13 02:35:29:

File Added - 115613: dlg.diff

vincentdarley added on 2005-01-13 02:35:28:
Logged In: YES 
user_id=32170

The bug is in ::tk::FDGetFileTypes in library/comdlg.tcl. 
This procedure claims to be similar to TkGetFileFilters() on
Mac/Windows, but differs in that it does not check for valid
MacOS file type strings.

Please test the attached patch.

vincentdarley added on 2005-01-11 18:28:53:
Logged In: YES 
user_id=32170

Those tests should both throw an error and therefore never
create a dialog and therefore never block.  At least that is
the behaviour on both Windows and MacOS X.

i.e. even though Windows doesn't make use of the MacOS
file-type information, it does check that it is valid. 
Validity means that the string is exactly four macRoman
bytes long.

Hence this looks like a bug or inconsistency in the unix
tk_getSaveFile definition.

Vince.

dgp added on 2004-12-21 05:53:28:
Logged In: YES 
user_id=80530

oops, not "mac"

probably should constrain
based on the value of
[tk windowingsystem]

dgp added on 2004-12-21 05:49:25:
Logged In: YES 
user_id=80530


perhaps just a missing "mac" 
constraint on these tests?

They block on Unix.  Not clear
what they'll do on Windows.

dgp added on 2004-12-21 05:31:18:
Logged In: YES 
user_id=80530


ok, this patch added two new
tests, fileDialog-0.1,2 and they
are the tests that are blocking.

No existing tests got broken, but the
new tests need to be fixed to not
block the test suite.

dgp added on 2004-12-21 05:20:38:
Logged In: YES 
user_id=80530

the fileDialog.test tests have
started blocking.  Did these
changes cause that?

vincentdarley added on 2004-12-20 17:34:20:
Logged In: YES 
user_id=32170

Further testing and commit.

vincentdarley added on 2004-12-14 20:56:13:
Logged In: YES 
user_id=32170

Donal, can I ask you to verify this fix (as maintainer of
'generic dialog support') so I can check it in?

vincentdarley added on 2004-12-14 20:54:01:

File Added - 112419: fileFilters.diff

Logged In: YES 
user_id=32170

The attached patch adds new tests for the bug, adds the
correct fix (which requires macRoman conversions), and
objectifies the handling of '-filetypes' throughout Tk.

Attachments: