We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ce1a030 commit b2767d2Copy full SHA for b2767d2
src/ansiblelint/formatters/__init__.py
@@ -42,7 +42,11 @@ def _format_path(self, path: str | Path) -> str | Path:
42
if not self.base_dir or not path:
43
return path
44
# Use os.path.relpath 'cause Path.relative_to() misbehaves
45
- return os.path.relpath(path, start=self.base_dir)
+ rel_path = os.path.relpath(path, start=self.base_dir)
46
+ # Avoid returning relative paths that go outside of base_dir
47
+ if rel_path.startswith(".."):
48
+ return path
49
+ return rel_path
50
51
def apply(self, match: MatchError) -> str:
52
"""Format a match error."""
0 commit comments