Skip to content

Conversation

@pluknet
Copy link
Contributor

@pluknet pluknet commented Sep 15, 2025

The XCLIENT command uses xtext encoding for attribute values, as specified in https://www.postfix.org/XCLIENT_README.html.

@pluknet pluknet added this to the nginx-1.29.2 milestone Sep 15, 2025
@pluknet pluknet self-assigned this Sep 15, 2025
@pluknet pluknet added the bug label Sep 15, 2025
The XCLIENT command uses xtext encoding for attribute values,
as specified in https://www.postfix.org/XCLIENT_README.html.

Reported by Igor Morgenstern of Aisle Research.
@pluknet
Copy link
Contributor Author

pluknet commented Sep 15, 2025

Added credits.

Copy link

@avahahn avahahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the escaping is detected with this table:

   static uint32_t   mail_xtext[] = {
        0xffffffff, /* 1111 1111 1111 1111  1111 1111 1111 1111 */

                    /* ?>=< ;:98 7654 3210  /.-, +*)( '&%$ #"!  */
        0x20000801, /* 0010 0000 0000 0000  0000 1000 0000 0001 */

                    /* _^]\ [ZYX WVUT SRQP  ONML KJIH GFED CBA@ */
        0x00000000, /* 0000 0000 0000 0000  0000 0000 0000 0000 */

                    /*  ~}| {zyx wvut srqp  onml kjih gfed cba` */
        0x80000000, /* 1000 0000 0000 0000  0000 0000 0000 0000 */

        0xffffffff, /* 1111 1111 1111 1111  1111 1111 1111 1111 */
        0xffffffff, /* 1111 1111 1111 1111  1111 1111 1111 1111 */
        0xffffffff, /* 1111 1111 1111 1111  1111 1111 1111 1111 */
        0xffffffff, /* 1111 1111 1111 1111  1111 1111 1111 1111 */
    };

and this conditional:

        if (escape[*src >> 5] & (1U << (*src & 0x1f))) {

I can see how this works but I find it is very much not straightforward. The RFC is very clear that this is doing the correct escaping, but I wonder why not skip all this and just write a conditional like this:

    if (*src < 33 || *src > 126 || *src == '=' || *src == '+') {

What is the benefit to making it so much less clear?

@pluknet
Copy link
Contributor Author

pluknet commented Sep 24, 2025

What is the benefit to making it so much less clear?

This goes in line with d4ff561, which added NGX_ESCAPE_MAIL_AUTH for same login/password pair.

Actually, using bitmasks is cleaner (and generally more efficient) than explicitly written out character sets with ||,
although it may take some time to figure out how it works.
This removes the added complexity to the underlying function (again, as seen in d4ff561).

@pluknet pluknet merged commit 6f81314 into nginx:master Sep 26, 2025
1 check passed
@pluknet pluknet deleted the mail-smtp-xclient branch September 26, 2025 13:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants