| 510 | f: LintFnTy::Recursive(check_utf8), |
| 511 | }; |
| 512 | fn check_utf8(e: &WalkComponent, _config: &LintExecutionConfig) -> LintRecursiveResult { |
| 513 | let path = e.path; |
| 514 | let filename = e.filename; |
| 515 | let dirname = path.parent().unwrap_or(Path::new("/")); |
| 516 | if filename.to_str().is_none() { |
| 517 | // This escapes like "abc\xFFdéf" |
| 518 | return lint_err(format!( |
| 519 | "{}: Found non-utf8 filename {filename:?}", |
| 520 | PathQuotedDisplay::new(&dirname) |
| 521 | )); |
| 522 | }; |
| 523 | |
| 524 | if e.file_type.is_symlink() { |
| 525 | let target = e.dir.read_link_contents(filename)?; |
| 526 | if target.to_str().is_none() { |
| 527 | return lint_err(format!( |
| 528 | "{}: Found non-utf8 symlink target", |
| 529 | PathQuotedDisplay::new(&path) |
| 530 | )); |
| 531 | } |
| 532 | } |
| 533 | lint_ok() |
| 534 | } |
| 535 | |
| 536 | fn check_prepareroot_composefs_norecurse(dir: &Dir) -> LintResult { |
| 537 | let path = ostree_ext::ostree_prepareroot::CONF_PATH; |