Skip to content
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

Fix issues #276 and #293 by checking for double slashes in STGroupDir #294

Closed
wants to merge 6 commits into from

Conversation

Mooninaut
Copy link

@Mooninaut Mooninaut commented Feb 24, 2022

Fixes #276 and fixes #293 by adding or trimming a trailing slash to/from the root and a leading slash to/from the parent before constructing the groupFileURL in STGroupDir.java

Adds unit tests to ensure all 4 combinations of root and parent with or without slash work correctly.

NOTE: This does not remove multiple consecutive leading or trailing slashes like root// or //parent. I feel like supplying such a path counts as user error and is unlikely to occur in practice. If it ever does cause a problem, another issue should be filed.

Clement Cherlin added 4 commits February 24, 2022 10:35
Fix bug that prevented loading template groups from a template group dir if the path returned by getResource() ended in a '/' by removing the initial '/' from the parent if the root ends with '/'.
@Mooninaut Mooninaut changed the title Issue 293 double slash Fix issues #276 and #293 by checking for double slashes in STGroupDir Feb 24, 2022
Remove now-unneeded TestGroupDirPathsGroupFile.stg and references to test-resources in build files.
@Mooninaut Mooninaut force-pushed the issue-293-double-slash branch 2 times, most recently from bc3804f to 8d576be Compare March 3, 2022 14:53
Use stripRight in trimOneTrailingNewline.
Remove redundant variable in getPrefix.
Use fixed string replace in replaceEscapes, no need for regex.
@parrt
Copy link
Member

parrt commented Mar 11, 2022

Hi! @Mooninaut Thanks!I am back to looking at this issue... I have like five open source projects to maintain at the moment. ugh. Anyway, I still think there must be a standard way to join these. I've just pushed a change that requires java 7 so hopefully there's a method in there. I'll go look now. I'll look at https://github.com/Mooninaut/stringtemplate4/tree/java1.7

@parrt
Copy link
Member

parrt commented Mar 11, 2022

Hi. I'm closing this in favor of the patched just did. Added a bunch of unit tests as well. Can you give it a shot? I just pushed a new snapshot of 4.3.2 via maven.

@parrt parrt closed this Mar 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants