idaholab / moose

Multiphysics Object Oriented Simulation Environment
https://www.mooseframework.org
GNU Lesser General Public License v2.1
1.71k stars 1.04k forks source link

MooseUtils::pathjoin needs to be improved #21150

Open YaqiWang opened 2 years ago

YaqiWang commented 2 years ago

Reason

I am seeing something like moose/framework/data/../../share/moose/framework/data/../../../foo during accessing a file.

Design

We can simply improve MooseUtils::pathjoin a little to get rid of this and make the screen output sane. The improvement should also protect potential bad access like moose/framework/../../../../../../../../../foo.

Impact

Better code and should not impact current capabilities.

dschwen commented 2 years ago

We can mess around with this, but the correct solution is in https://github.com/idaholab/moose/pull/21137 . std::filesystem::path can perform this sort of normalization.

YaqiWang commented 2 years ago

How likely that PR can be merged? Otherwise, I can push up a quick fix. It does not cost me much.

dschwen commented 2 years ago

yeah, you should go with the fix. std::filesystem is still a bit out, as it required more modern minimal compiler targets.