Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

PHP programmers? I have enough with C

Name: Anonymous 2007-09-05 11:12 ID:ZUBQe78S

You bash PHP "web designers"? Wait till you see some sauce from GNUfags. And these are worse because they write portable assembly. I'm amazed it actually kinda half sorta works (not flawlessly of course).

From the Midnight Commander source, 4.6.1, subshell.c. This function is called to quote a directory name before issuing a "cd 'xxx'" command to a subshell that's running along. Quoting is necessary because one could make a directory like "x';rm -rf /".

/*
 * Carefully quote directory name to allow entering any directory safely,
 * no matter what weird characters it may contain in its name.
 * NOTE: Treat directory name an untrusted data, don't allow it to cause
 * executing any commands in the shell.  Escape all control characters.
 * Use following technique:
 *
 * for bash - echo with `-e', 3-digit octal numbers:
 *   cd "`echo -e '\ooo...\ooo'`"
 *
 * for zsh - echo with `-e', 4-digit octal numbers:
 *   cd "`echo '\oooo...\oooo'`"
 *
 * for tcsh - echo without `-e', 4-digit octal numbers:
 *   cd "`echo '\oooo...\oooo'`"
 */
static char *
subshell_name_quote (const char *s)
{
    char *ret, *d;
    const char echo_cmd[] = "\"`echo '";
    const char echo_e_cmd[] = "\"`echo -e '";
    const char common_end[] = "'`\"";
    const char *cmd_start;
    int len;

    /*
     * Factor 5 because we need \, 0 and 3 other digits per character
     * in the worst case (tcsh and zsh).
     */
    d = ret = g_malloc (5 * strlen (s) + 16);
    if (!d)
    return NULL;

    /* Prevent interpreting leading `-' as a switch for `cd' */
    if (*s == '-') {
    *d++ = '.';
    *d++ = '/';
    }

    /* echo in tcsh doesn't understand the "-e" option */
    if (subshell_type == TCSH)
    cmd_start = echo_cmd;
    else
    cmd_start = echo_e_cmd;

    /* Copy the beginning of the command to the buffer */
    len = strlen (cmd_start);
    memcpy (d, cmd_start, len);
    d += len;

    /*
     * Print every character in octal format with the leading backslash.
     * tcsh and zsh may require 4-digit octals, bash < 2.05b doesn't like them.
     */
    if (subshell_type == BASH) {
    for (; *s; s++) {
    /* Must quote numbers, so that they are not glued to octals */
    if (isalpha ((unsigned char) *s)) {
    *d++ = (unsigned char) *s;
    } else {
    sprintf (d, "\\%03o", (unsigned char) *s);
    d += 4;
    }
    }
    } else {
    for (; *s; s++) {
    if (isalnum ((unsigned char) *s)) {
    *d++ = (unsigned char) *s;
    } else {
    sprintf (d, "\\0%03o", (unsigned char) *s);
    d += 5;
    }
    }
    }

    memcpy (d, common_end, sizeof (common_end));

    return ret;
}


Also, Google the function name for some fun and insanity. My fucking god, this is already looking like a = str(int(b) + d + 0.0)) #Thanks Robert . The guys who wrote that should move to web design.

Name: Anonymous 2007-09-05 11:19 ID:Heaven

Name: Anonymous 2007-09-05 11:20 ID:Heaven

Name: Anonymous 2007-09-05 11:20 ID:Heaven

Name: Anonymous 2007-09-05 11:21 ID:Heaven

Name: sage 2007-09-05 11:28 ID:Heaven

sage goes in all fields

Name: Anonymous 2007-09-05 11:28 ID:rEvWy/uM

C-C-COMBO BREAKER

Name: Anonymous 2007-09-05 11:32 ID:dOwoDaQV

Sorry, what is the problem?

Looks like a reasonable function to me, considering the shortcomings of Unix shells.

Name: Anonymous 2007-09-05 12:34 ID:Heaven

>>8
lack of forced indentation is the problem

Name: Anonymous 2007-09-05 14:47 ID:ZUBQe78S

>>8
"\"`echo -e '"

Also, it doesn't even work. On Bash, at least 3.x, it fails on directories which contain characters such as _ or ^ .

Also, to avoid -, just cd --

Also, the unenforced indentation of code leads to this

Also, it sucks

Name: Anonymous 2007-09-06 10:46 ID:Heaven

Also, building your program on top of a bunch of shells is retarded.

Name: Anonymous 2009-02-25 6:19

At weird characters it   may contain in.

Name: Anonymous 2010-12-26 14:35

Name: Anonymous 2011-02-04 13:21

Name: Sgt.Kabukiman哰 2012-05-23 5:05




1  Name: Anonymous : 2007-09-05 11:12  ID:ZUBQe78S


You bash PHP "web designers"? Wait till you see some sauce from GNUfags. And these are worse because they write portable assembly. I'm amazed it actually kinda half sorta works (not flawlessly of course).

From the Midnight Commander source, 4.6.1, subshell.c. This function is called to quote a directory name before issuing a "cd 'xxx'" command to a subshell that's running along. Quoting is necessary because one could make a directory like "x';rm -rf /".

/* * Carefully quote directory name to allow entering any directory safely, * no matter what weird characters it may contain in its name. * NOTE: Treat directory name an untrusted data, don't allow it to cause * executing any commands in the shell.  Escape all control characters. * Use following technique: * * for bash - echo with `-e', 3-digit octal numbers: *   cd "`echo -e '\ooo...\ooo'`" * * for zsh - echo with `-e', 4-digit octal numbers: *   cd "`echo '\oooo...\oooo'`" * * for tcsh - echo without `-e', 4-digit octal numbers: *   cd "`echo '\oooo...\oooo'`" */static char *subshell_name_quote (const char *s){    char *ret, *d;    const char echo_cmd[] = "\"`echo '";    const char echo_e_cmd[] = "\"`echo -e '";    const char common_end[] = "'`\"";    const char *cmd_start;    int len;    /*     * Factor 5 because we need \, 0 and 3 other digits per character     * in the worst case (tcsh and zsh).     */    d = ret = g_malloc (5 * strlen (s) + 16);    if (!d)    return NULL;    /* Prevent interpreting leading `-' as a switch for `cd' */    if (*s == '-') {    *d++ = '.';    *d++ = '/';    }    /* echo in tcsh doesn't understand the "-e" option */    if (subshell_type == TCSH)    cmd_start = echo_cmd;    else    cmd_start = echo_e_cmd;    /* Copy the beginning of the command to the buffer */    len = strlen (cmd_start);    memcpy (d, cmd_start, len);    d += len;    /*     * Print every character in octal format with the leading backslash.     * tcsh and zsh may require 4-digit octals, bash < 2.05b doesn't like them.     */    if (subshell_type == BASH) {    for (; *s; s++) {    /* Must quote numbers, so that they are not glued to octals */    if (isalpha ((unsigned char) *s)) {    *d++ = (unsigned char) *s;    } else {    sprintf (d, "\\%03o", (unsigned char) *s);    d += 4;    }    }    } else {    for (; *s; s++) {    if (isalnum ((unsigned char) *s)) {    *d++ = (unsigned char) *s;    } else {    sprintf (d, "\\0%03o", (unsigned char) *s);    d += 5;    }    }    }    memcpy (d, common_end, sizeof (common_end));    return ret;}

Also, Google the function name for some fun and insanity. My fucking god, this is already looking like a = str(int(b) + d + 0.0)) #Thanks Robert . The guys who wrote that should move to web design.



2  Name: Anonymous : 2007-09-05 11:19  ID:Heaven


http://mitpress.mit.edu/sicp/full-text/book/book.html



3  Name: Anonymous : 2007-09-05 11:20  ID:Heaven


http://mitpress.mit.edu/sicp/full-text/book/book.html



4  Name: Anonymous : 2007-09-05 11:20  ID:Heaven


HTTP://MITPRESS.MIT.EDU/SICP/FULL-TEXT/BOOK/BOOK.HTML



5  Name: Anonymous : 2007-09-05 11:21  ID:Heaven


HTTP://MITPRESS.MIT.EDU/SICP/FULL-TEXT/BOOK/BOOK.HTML



6  Name: sage : 2007-09-05 11:28  ID:Heaven


sage goes in all fields



7  Name: Anonymous : 2007-09-05 11:28  ID:rEvWy/uM


C-C-COMBO BREAKER



8  Name: Anonymous : 2007-09-05 11:32  ID:dOwoDaQV


Sorry, what is the problem?

Looks like a reasonable function to me, considering the shortcomings of Unix shells.



9  Name: Anonymous : 2007-09-05 12:34  ID:Heaven


>>8
lack of forced indentation is the problem



10  Name: Anonymous : 2007-09-05 14:47  ID:ZUBQe78S


>>8
"\"`echo -e '"

Also, it doesn't even work. On Bash, at least 3.x, it fails on directories which contain characters such as _ or ^ .

Also, to avoid -, just cd --

Also, the unenforced indentation of code leads to this

Also, it sucks



11  Name: Anonymous : 2007-09-06 10:46  ID:Heaven


Also, building your program on top of a bunch of shells is retarded.



12  Name: Anonymous : 2009-02-25 06:19 


At weird characters it   may contain in.



14  Name: Anonymous : 2010-12-26 14:35 






15  Name: Anonymous : 2011-02-04 13:21

Name: Anonymous 2013-09-09 3:15

>>16
learn to optimise your quotes!

Don't change these.
Name: Email:
Entire Thread Thread List