Skip to content

Fix #4856 - escape path with backward slash in Labs#4859

Merged
tijcolem merged 3 commits intodevelopfrom
4856_EscapePath
Apr 13, 2023
Merged

Fix #4856 - escape path with backward slash in Labs#4859
tijcolem merged 3 commits intodevelopfrom
4856_EscapePath

Conversation

@jmarrec
Copy link
Copy Markdown
Collaborator

@jmarrec jmarrec commented Apr 12, 2023

Pull request overview

Pull Request Author

  • Model API Changes / Additions
  • Any new or modified fields have been implemented in the EnergyPlus ForwardTranslator (and ReverseTranslator as appropriate)
  • Model API methods are tested (in src/model/test)
  • EnergyPlus ForwardTranslator Tests (in src/energyplus/Test)
  • If a new object or method, added a test in NREL/OpenStudio-resources: Add Link
  • If needed, added VersionTranslation rules for the objects (src/osversion/VersionTranslator.cpp)
  • Verified that C# bindings built fine on Windows, partial classes used as needed, etc.
  • All new and existing tests passes
  • If methods have been deprecated, update rest of code to use the new methods

Labels:

  • If change to an IDD file, add the label IDDChange
  • If breaking existing API, add the label APIChange
  • If deemed ready, add label Pull Request - Ready for CI so that CI builds your PR

Review Checklist

This will not be exhaustively relevant to every PR.

  • Perform a Code Review on GitHub
  • Code Style, strip trailing whitespace, etc.
  • All related changes have been implemented: model changes, model tests, FT changes, FT tests, VersionTranslation, OS App
  • Labeling is ok
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified

@jmarrec jmarrec added component - CLI Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge. labels Apr 12, 2023
@jmarrec jmarrec self-assigned this Apr 12, 2023
@tijcolem
Copy link
Copy Markdown
Collaborator

@jmarrec Thanks for working on this! @shorowit Could you test the windows installer and let us know if this fixes the pathing issue.

@jmarrec jmarrec marked this pull request as ready for review April 12, 2023 15:23
@jmarrec jmarrec requested review from shorowit and tijcolem April 12, 2023 15:23
Comment on lines +54 to +62
const bool is_labs = !args.empty() && (args[0] == "labs");
if (is_labs) {
// Replace backward slashes with forward slashes... cf #4856
std::for_each(args.begin(), args.end(), [](auto& s) {
//std::replace(s.begin(), s.end(), '\\', '/');
boost::replace_all(s, "\\", "\\\\");
});
// fmt::print("Cleaned after slash replacement arguments: {}\n", args);
}
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: my original idea was to replace all \ with /. I believe that's what ruby does here: https://github.com/ruby/ruby/blob/1f4d4558484b370999954f3ede7e3aa3a3a01ef3/ruby.c#L1698-L1702

I feared this would cause more problems so I've tried something different, trying to escape those \\.

it's not perfect, I suppose some weird stuff like openstudio -e 'puts "hello\nworld"' will more or less work (then again, it also doesn't work on windows with the official ruby.exe so...), but it should fix most issues.

Copy link
Copy Markdown
Contributor

@shorowit shorowit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested various CLI commands on both Windows and Linux, labs and standard, and everything worked.

@jmarrec
Copy link
Copy Markdown
Collaborator Author

jmarrec commented Apr 12, 2023

@shorowit thanks for testing!

@tijcolem tijcolem merged commit 8d4c883 into develop Apr 13, 2023
@tijcolem tijcolem deleted the 4856_EscapePath branch April 13, 2023 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component - CLI Pull Request - Ready for CI This pull request if finalized and is ready for continuous integration verification prior to merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

labs on Windows doesn't correctly process backward slashes

4 participants