-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Safer CPL path functions (RFC 105 implementation) #11639
Draft
rouault
wants to merge
34
commits into
OSGeo:master
Choose a base branch
from
rouault:CPLFormFilenameSafe
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rouault
force-pushed
the
CPLFormFilenameSafe
branch
from
January 11, 2025 16:08
9700ce9
to
7474f93
Compare
…etExtensionSafe()
…), CPLGetExtensionSafe()
…t semantic change in Rename() where case-sensitive find() used instead of ifind(), change which is more logical
…,' with 'poOpenInfo->IsExtensionEqualToCI('
…ExtensionSafe(...).c_str(), ...) Using ``` find frmts ogr -name "*.cpp" -exec sed -i "s/EQUAL(CPLGetExtension(\([a-zA-Z]*\)),/EQUAL(CPLGetExtensionSafe(\1).c_str(),/" {} \; ```
rouault
force-pushed
the
CPLFormFilenameSafe
branch
2 times, most recently
from
January 12, 2025 16:30
45b2948
to
48542cf
Compare
rouault
added
the
funded through GSP
Work funded through the GDAL Sponsorship Program
label
Jan 12, 2025
rouault
force-pushed
the
CPLFormFilenameSafe
branch
2 times, most recently
from
January 12, 2025 17:23
0b81ed3
to
3e1327c
Compare
…anTrailingSlashSafe(), CPLGenerateTempFilenameSafe(), CPLExpandTildeSafe(), CPLLaunderForFilenameSafe()
…r automation scripts
Done with following script: ```bash funcs=(CPLGetPath CPLGetDirname CPLGetBasename CPLGetExtension CPLFormFilename CPLFormCIFilename CPLResetExtension CPLProjectRelativeFilename CPLCleanTrailingSlash CPLGenerateTempFilename CPLExpandTilde CPLLaunderForFilename) for func in "${funcs[@]}"; do find frmts ogr -name "*.cpp" -exec sed -i -E "s/const char \*([a-zA-Z_][a-zA-Z0-9_]*)\(${func}\(([^()]*(\([^()]*\))?[^()]*)\)\);/const char *\1 = ${func}(\2);/g" {} \; done for func in "${funcs[@]}"; do find frmts ogr -name "*.cpp" -exec sed -i -E "s/CPLString\(${func}\(([^()]*(\([^()]*\))?[^()]*)\)\)/CPLString(${func}Safe(\1))/g" {} \; find frmts ogr -name "*.cpp" -exec sed -i -E "s/std::string\(${func}\(([^()]*(\([^()]*\))?[^()]*)\)\)/std::string(${func}Safe(\1))/g" {} \; done for func in "${funcs[@]}"; do find frmts ogr -name "*.cpp" -exec sed -i -E "s/(CPLString\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\()${func}\((.*)\)/\1${func}Safe(\2)/g" {} \; find frmts ogr -name "*.cpp" -exec sed -i -E "s/(std::string\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\()${func}\((.*)\)/\1${func}Safe(\2)/g" {} \; done for func in "${funcs[@]}"; do find frmts ogr -name "*.cpp" -exec sed -i -E "s/(std::string\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\()${func}\(([^)]+)\)/\1${func}Safe(\2)/g" {} \; find frmts ogr -name "*.cpp" -exec sed -i -E "s/(CPLString\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\()${func}\(([^)]+)\)/\1${func}Safe(\2)/g" {} \; done for func in "${funcs[@]}"; do find frmts ogr -name "*.cpp" -exec sed -i -E "s/\(${func}\(([^()]*(\([^()]*\))?[^()]*)\)/(${func}Safe(\1).c_str()/g" {} \; find frmts ogr -name "*.cpp" -exec sed -i -E "s/, ${func}\(([^()]*(\([^()]*\))?[^()]*)\)/, ${func}Safe(\1).c_str()/g" {} \; done ```
Done with following script: ```bash funcs=(CPLGetPath CPLGetDirname CPLGetBasename CPLGetExtension CPLFormFilename CPLFormCIFilename CPLResetExtension CPLProjectRelativeFilename CPLCleanTrailingSlash CPLGenerateTempFilename CPLExpandTilde CPLLaunderForFilename) for func in "${funcs[@]}"; do find frmts ogr -name "*.cpp" -exec sed -i -E "s/(CPLString\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\ = )${func}\((.*)\)/\1${func}Safe(\2)/g" {} \; find frmts ogr -name "*.cpp" -exec sed -i -E "s/(std::string\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\ = )${func}\((.*)\)/\1${func}Safe(\2)/g" {} \; done ```
… CPLGetBasenameSafe()
…CPLGetDirnameSafe()
rouault
force-pushed
the
CPLFormFilenameSafe
branch
from
January 13, 2025 19:28
9a9d549
to
0f47eed
Compare
rouault
force-pushed
the
CPLFormFilenameSafe
branch
from
January 13, 2025 20:00
0f47eed
to
2c17139
Compare
…h CPLGetExtensionSafe()
Done with following script: ```bash funcs=(CPLGetPath CPLGetDirname CPLGetBasename CPLGetExtension CPLFormFilename CPLFormCIFilename CPLResetExtension CPLProjectRelativeFilename CPLCleanTrailingSlash CPLGenerateTempFilename CPLExpandTilde CPLLaunderForFilename) for func in "${funcs[@]}"; do find frmts ogr -name "*.cpp" -exec sed -i -E "s/(CPLString\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\ = )${func}\(/\1${func}Safe(/g" {} \; find frmts ogr -name "*.cpp" -exec sed -i -E "s/(std::string\s+[a-zA-Z_][a-zA-Z0-9_]*\s*\ = )${func}\(/\1${func}Safe(/g" {} \; done ```
Done with following script: ```bash funcs=(CPLGetPath CPLGetDirname CPLGetBasename CPLGetExtension CPLFormFilename CPLFormCIFilename CPLResetExtension CPLProjectRelativeFilename CPLCleanTrailingSlash CPLGenerateTempFilename CPLExpandTilde CPLLaunderForFilename) for func in "${funcs[@]}"; do find frmts ogr -name "*.cpp" -exec sed -i -E "s/(^\s+os[a-zA-Z_][a-zA-Z0-9_]*\s*\ = )${func}(\((.*)\);)/\1${func}Safe\2/g" {} \; done ```
…ith CPLFormCIFilenameSafe()
…ith CPLResetExtensionSafe()
…ename() with CPLProjectRelativeFilenameSafe()
…me() with CPLGenerateTempFilenameSafe()
rouault
force-pushed
the
CPLFormFilenameSafe
branch
from
January 14, 2025 21:20
99e6b7a
to
8e52de7
Compare
rouault
force-pushed
the
CPLFormFilenameSafe
branch
from
January 14, 2025 22:01
8e52de7
to
1374969
Compare
rouault
force-pushed
the
CPLFormFilenameSafe
branch
from
January 14, 2025 22:11
1374969
to
06be59b
Compare
rouault
force-pushed
the
CPLFormFilenameSafe
branch
from
January 14, 2025 22:46
06be59b
to
df669f9
Compare
rouault
changed the title
[WIP] Safer CPL path functions
Safer CPL path functions (RFC 105 implementation)
Jan 14, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Candidate implementation of RFC 105 "Add and use safe path manipulation functions" / #11640