get_relative_path: shorten data_folder everywhere it appears#349
Open
abrignoni wants to merge 1 commit into
Open
get_relative_path: shorten data_folder everywhere it appears#349abrignoni wants to merge 1 commit into
abrignoni wants to merge 1 commit into
Conversation
The relative-source-paths fix shortened the returned source_path per
newline segment, but artifacts that join multiple absolute paths with
other separators (', ', '; ', ' ') only had the first path shortened:
startswith matches the head of the concatenated string, strips one
prefix, and the rest stayed absolute. Spotted by James Habben.
Replace the startswith branch with a global replacement of the
data_folder prefix, so every embedded occurrence is shortened regardless
of separator. All previous behaviors are preserved (exact path, literal
passthrough, already-relative, no data_folder) and covered by tests.
This file contains hidden or 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
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.
Follow-up to the relative-source-paths fix, prompted by @JamesHabben's question about concatenated source paths.
The gap: the decorator shortens
source_pathper newline segment. Artifacts that join multiple absolute paths with other separators (', ','; ',' ') only had the first path shortened —startswithmatches the head of the concatenated string, strips one prefix, and the rest stayed absolute:The fix:
Context.get_relative_pathnow globally replaces the data_folder prefix wherever it appears, separator-agnostic — same spirit as the oldfile_found.replace(seeker.data_folder, '')idiom. Artifacts that already relativize before joining (Oops-style, ~24 in iLEAPP) are unaffected: relative segments pass through untouched.Verified: unit tests cover exact path, path == data_folder, literals, already-relative, None, comma/semicolon/space-joined absolute paths, newline decorator path, and no-data_folder passthrough. pylint 10.00/10, byte-compile, PluginLoader smoke test all pass.
Affected artifacts that this transparently fixes: iLEAPP box/home_depot/idstatuscache/sysdiagnose (+skg_archive if its parts are paths), ALEAPP FCM family/siminfo/wifiConfigstore2/wifiProfiles. RLEAPP/VLEAPP have no current emitters — this keeps the four frameworks identical and future-proof.