rhg: check that .hg/requires is ASCII
authorSimon Sapin <simon-commits@exyr.org>
Wed, 25 Nov 2020 12:33:37 +0100
changeset 45938 f5d62f4d5327
parent 45937 2ad2745e0be9
child 45939 66f6ca2b7aee
rhg: check that .hg/requires is ASCII Differential Revision: https://phab.mercurial-scm.org/D9400
rust/hg-core/src/requirements.rs
tests/test-rhg.t
--- 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]