Skip to content

Subprocess does not correctly escape strings #69

@TanzHasan

Description

@TanzHasan
 _, err = subprocess.Popen(iwyu, stderr=subprocess.PIPE, text=True).communicate()

This line will fail occasionally because subprocess does not appropriately escape strings. This issue can be resolved by turning iwyu into a string and setting shell=True.

These settings are why the below runs without issue:

def build(command: List[str], directory: str):
    """Runs a command as a subprocess to build a .i file in the target directory"""
    os.chdir(directory)
    try:
        subprocess.check_call(" ".join(command), shell=True)

This issue was identified during the last day of development but an appropriate solution beyond shell=True has not been identified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions