Skip to content

Support spaces in --datadir paths - #359

Merged
moizpgedge merged 3 commits into
mainfrom
fix/PLAT-177/-pgdata-support-with-space
Aug 6, 2025
Merged

Support spaces in --datadir paths#359
moizpgedge merged 3 commits into
mainfrom
fix/PLAT-177/-pgdata-support-with-space

Conversation

@moizpgedge

Copy link
Copy Markdown
Contributor
    • Normalize --datadir input by replacing all \ sequences with actual spaces
    • Assign cleaned path to pg_data before directory creation and downstream use
    • Ensure initdb, SSL cert generation, pg_hba.conf copy, and pg_ctl all target the real filesystem path
    • Prevent errors when users pass paths like /home/moiz/pgdir_test\ 6 on the CLI

@moizpgedge
moizpgedge requested a review from mmols July 30, 2025 14:49
@moizpgedge moizpgedge self-assigned this Jul 30, 2025
@moizpgedge
moizpgedge force-pushed the fix/PLAT-177/-pgdata-support-with-space branch from 7175fbf to 4216a9e Compare August 1, 2025 11:15
@mmols
mmols force-pushed the fix/PLAT-177/-pgdata-support-with-space branch from 4216a9e to b581a59 Compare August 5, 2025 21:15
@mmols mmols changed the title Support escaped spaces in --datadir paths Support spaces in --datadir paths Aug 6, 2025
@moizpgedge

Copy link
Copy Markdown
Contributor Author

The fix now passes the data-directory exactly once—wrapped in quotes but without backslashes—so paths like “/data/foo bar” work naturally.
All shell interactions funnel paths through shlex.quote, removing our old hand-built escapes and closing the command-injection hole Codacy flagged.

@moizpgedge
moizpgedge merged commit 1724b1f into main Aug 6, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants