rhg: check that .hg/requires is ASCII
Differential Revision: https://phab.mercurial-scm.org/D9400
--- a/rust/hg-core/src/requirements.rs Tue Nov 24 18:52:38 2020 +0100
+++ b/rust/hg-core/src/requirements.rs Wed Nov 25 12:33:37 2020 +0100
@@ -24,7 +24,7 @@
.map(|line| {
// Python uses Unicode `str.isalnum` but feature names are all
// ASCII
- if line[0].is_ascii_alphanumeric() {
+ if line[0].is_ascii_alphanumeric() && line.is_ascii() {
Ok(String::from_utf8(line.into()).unwrap())
} else {
Err(())
--- a/tests/test-rhg.t Tue Nov 24 18:52:38 2020 +0100
+++ b/tests/test-rhg.t Wed Nov 25 12:33:37 2020 +0100
@@ -140,3 +140,8 @@
sparserevlog
store
indoor-pool
+
+ $ echo -e '\xFF' >> .hg/requires
+ $ rhg debugrequirements
+ abort: .hg/requires is corrupted
+ [255]