#3232·ranger

[安全性] .metadata.json 解析过程中出现未处理的异常,导致 ranger 终止

作者: sectroyer创建于 2026年5月20日更新于 2026年8月24日
标签enhancement
  1. Create a test directory with a regular file:
bash
mkdir /tmp/testdir
echo "example file" > /tmp/testdir/file.txt
  1. Write a malformed .metadata.json in the same directory:
bash
echo 'INVALID JSON <<<' > /tmp/testdir/.metadata.json
  1. Open ranger and navigate into /tmp/testdir/. To reproduce without the ranger TUI, run directly via Python:
python
import sys; sys.path.insert(0, '/path/to/ranger')
from ranger.core.metadata import MetadataManager
MetadataManager().get_metadata('/tmp/testdir/file.txt')
  1. Observe that an unhandled ValueError is raised. In a live ranger session, this exception terminates the process.