changeset 45953:f5d62f4d5327

rhg: check that .hg/requires is ASCII Differential Revision: https://phab.mercurial-scm.org/D9400
author Simon Sapin <simon-commits@exyr.org>
date Wed, 25 Nov 2020 12:33:37 +0100
parents 2ad2745e0be9
children 66f6ca2b7aee
files rust/hg-core/src/requirements.rs tests/test-rhg.t
diffstat 2 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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]