module

Hwaro::Utils::OutputGuard

Instance methods

safe_output_path(output_path : String, output_dir : String) : String | Nil

Verify that the given output path is within the output directory. Returns the output_path if safe, or a fallback path and logs a warning.

Example: safe_path("public/../etc/passwd", "public") # => "public/index.html" (with warning) safe_path("public/blog/index.html", "public") # => "public/blog/index.html"

Source
within_output_dir?(output_path : String, output_dir : String) : Bool

Check if a path is within the output directory.

Source