D9400: rhg: check that .hg/requires is ASCII

SimonSapin (Simon Sapin) phabricator at mercurial-scm.org
Wed Nov 25 12:42:33 UTC 2020


SimonSapin created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D9400

AFFECTED FILES
  rust/hg-core/src/requirements.rs
  tests/test-rhg.t

CHANGE DETAILS

diff --git a/tests/test-rhg.t b/tests/test-rhg.t
--- a/tests/test-rhg.t
+++ b/tests/test-rhg.t
@@ -140,3 +140,8 @@
   sparserevlog
   store
   indoor-pool
+
+  $ echo -e '\xFF' >> .hg/requires
+  $ rhg debugrequirements
+  abort: .hg/requires is corrupted
+  [255]
diff --git a/rust/hg-core/src/requirements.rs b/rust/hg-core/src/requirements.rs
--- a/rust/hg-core/src/requirements.rs
+++ b/rust/hg-core/src/requirements.rs
@@ -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(())



To: SimonSapin, #hg-reviewers
Cc: mercurial-patches, mercurial-devel


More information about the Mercurial-devel mailing list