Path to fix gently cockeyed DDE command parsing


Subject: Path to fix gently cockeyed DDE command parsing
From: John Anderson (panic-abi@semiosix.com)
Date: Mon Sep 10 2001 - 12:27:10 CDT


Here's a patch to fix the gently cockeyed DDE command parsing code in src/af/xap/win/xap_Win32Slurp.cpp, in the 0.9.3 release version. According to LXR, the file hasn't been updated since 6-feb-2001.

The problem occurs when you try to open a file with embedded [] in the name. MSIE 5.x uses [] in the temporary filenames it generates when you try to open a document from a web server.

The patch also inserts a dde command string of [open("%1")] into the registry instead of [open(%1)]. This may have an effect with filenames containing embedded spaces, I'm not sure. All the other "open" command entries in the registry did have the quotes, though.

AFAIK there isn't a bug number for this.

have fun

------------------------------------------------------------------------------------------------
diff -rbn abiword-0.9.3/abi/src/af/xap/win/xap_Win32Slurp.cpp ../abiword-0.9.3/abi/src/af/xap/win/xap_Win32Slurp.cpp
d184 1
d200 1
a200 24
        // [Open("<pathname>")]
        // if anything more complicated is needed, it may be a
        // good idea to use a regex library
        // TODO failures just goto Finished. Some error reporting
        // TODO would be nice

        // pointer to work through the incoming string
        char * next = pBuf;
        
        // pointer used to copy into command and pathname
        char * dest = 0;
        
        // chomp the [
        if ( *next++ != '[' ) goto Finished;
        
        // find the next sequence of non ( characters
        // this will be the dde command
        char command[1024];
        dest = command;
        for ( ; *next != '('; ++next )
        {
                *dest++ = *next;
        }
        *dest = 0;
d202 1
a202 3
        // chomp the ( and the "
        if ( *next++ != '(' ) goto Finished;
        if ( *next++ != '"' ) goto Finished;
d204 2
a205 5
        // go until the next " to get the parameter
        // " are not allowed in filenames, so we should be safe here
        char pathname[4096];
        dest = pathname;
        for ( ; *next != '"'; ++next )
d207 1
a207 11
                *dest++ = *next;
        }
        *dest = 0;
        
        // chomp the ", ), and ]
        if ( *next++ != '"' ) goto Finished;
        if ( *next++ != ')' ) goto Finished;
        if ( *next++ != ']' ) goto Finished;
        
        // now do something useful with the command and its parameter
        if (UT_stricmp(command,"open") == 0)
d209 1
d229 3
d293 1
a293 1
        // HKEY_CLASSES_ROOT\<foo>\shell\open\ddeexec = [Open("%1")]
d298 1
a298 1
#define VALUE_DDEEXEC_OPEN "[Open(\"%1\")]"
a452 3
        char commandPathWithParam[1024];
        strcpy ( commandPathWithParam, szExePathname );
        strcat ( commandPathWithParam, " \"%1\"" );
d469 1
a469 1
                        if (UT_stricmp(buf,commandPathWithParam) == 0)
d472 1
a472 1
                        if(memcmp(buf, commandPathWithParam, strlen(commandPathWithParam)) == 0)
d492 1
a492 1
                eResult = RegSetValueEx(hKeyCommand,NULL,0,REG_SZ,xx(commandPathWithParam));
------------------------------------------------------------------------------------------------

Freelance Data Munger http://www.semiosix.com
Good Things require a precise lack of control



This archive was generated by hypermail 2b25 : Mon Sep 10 2001 - 12:31:45 CDT