sanitize_path_component

Function sanitize_path_component 

Source
pub fn sanitize_path_component(name: &str) -> String
Expand description

パス文字列のサニタイズ

ファイル名やディレクトリ名から危険な文字を除去し、安全な文字列に変換します。

§セキュリティ

以下の文字のみを許可します:

  • 英数字(a-z, A-Z, 0-9)
  • ハイフン(-)
  • アンダースコア(_)

§引数

  • name - サニタイズ対象の文字列

§戻り値

安全な文字のみを含む文字列

§使用例

use backup_suite::security::sanitize_path_component;

let safe = sanitize_path_component("my-file_v10");
assert_eq!(safe, "my-file_v10");

let sanitized = sanitize_path_component("dangerous/../../../file.txt");
assert_eq!(sanitized, "dangerousfiletxt");