Backslash escaping in CFlags is parsed incorrectly #163

Closed
opened 2017-12-13 13:09:51 +00:00 by karen-arutyunov · 1 comment
karen-arutyunov commented 2017-12-13 13:09:51 +00:00 (Migrated from github.com)

The following cflags representations are equivalent according to the shell quoting rules:

Cflags: "-IC:\\D E"
Cflags: '-IC:\D E'
Cflags: -IC:\\D\ E

This assumption is confirmed by ‘pkg-config --cflags’, that prints them all the same:

-IC:\\D\ E

However, pkgconf (latest master) prints them all differently:

'-IC:\D E' 
'-IC:D E'
'-IC:\\D E'

It’s a valid choice to print the flag single-quoted (in contrast to pkg-config) in the presence of spaces, but it still should be printed the same for all 3 cases:

'-IC:\D E'

I think that the problem starts in libpkgconf at the stage of parsing flags string into the list of pkgconf_fragment_t structures. The resulted pkgconf_fragment_t objects contains the following data for the above cases:

C:\D E
C:D E
C:\\D E

This looks broken, as the library client could expect all 3 forms to result in the same (most natural “fully unescaped/unquoted”) internal representation:

C:\D E
The following cflags representations are equivalent according to the shell quoting rules: ``` Cflags: "-IC:\\D E" Cflags: '-IC:\D E' Cflags: -IC:\\D\ E ``` This assumption is confirmed by ‘pkg-config --cflags’, that prints them all the same: ``` -IC:\\D\ E ``` However, pkgconf (latest master) prints them all differently: ``` '-IC:\D E' '-IC:D E' '-IC:\\D E' ``` It’s a valid choice to print the flag single-quoted (in contrast to pkg-config) in the presence of spaces, but it still should be printed the same for all 3 cases: ``` '-IC:\D E' ``` I think that the problem starts in libpkgconf at the stage of parsing flags string into the list of pkgconf_fragment_t structures. The resulted pkgconf_fragment_t objects contains the following data for the above cases: ``` C:\D E C:D E C:\\D E ``` This looks broken, as the library client could expect all 3 forms to result in the same (most natural “fully unescaped/unquoted”) internal representation: ``` C:\D E ```

Yes, there seems to be more escape-related deficiencies.

Sigh, I will deal with that tonight.

Yes, there seems to be more escape-related deficiencies. Sigh, I will deal with that tonight.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: ariadne/pkgconf#163
There is no content yet.