bevy_webgate 0.2.1

A web server integration for the Bevy game engine that allows you to easily append a webserver to Bevy.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::path::PathBuf;

/// Sanitize the file path to prevent directory traversal attacks
pub fn sanitize_path(path: &str) -> String {
    // Remove any ".." components and ensure we stay within our allowed directory
    let path = path.replace("..", "");

    // Ensure the path is relative and doesn't start with "/"
    let path = path.trim_start_matches('/');

    // Convert to PathBuf for safe path handling
    let path_buf = PathBuf::from(path);

    // Return the sanitized path as a string
    path_buf.to_string_lossy().to_string()
}