about summary refs log tree commit diff
path: root/pkgs/profpatsch
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-02-16 00:00:41 +0100
committersternenseemann <sternenseemann@systemli.org>2021-02-25 19:52:33 +0100
commit614a996e50903fce2a94225056c07ee013a3483f (patch)
treeba62618ef8d345b055720a65ec6283bbea804daa /pkgs/profpatsch
parent1afdcc045e8118741903616aa51a1b9726a8f909 (diff)
pkgs/profpatsch/nman: fix panic if mandir.len() < 3
Sometimes share/man contains directories that are not of the form
man<section> which we are checking in build_man_page. However, this
check can't deal with directories that are shorter than 3 characters due
to the use of split_at() which panics if the index is out of range (for
somer reason…).

In nixpkgs it is relatively common to have directories like "de" in
share/man.

This has been resolved.
Diffstat (limited to 'pkgs/profpatsch')
-rw-r--r--pkgs/profpatsch/nman/nman.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/pkgs/profpatsch/nman/nman.rs b/pkgs/profpatsch/nman/nman.rs
index d3f60f7a..55293f1f 100644
--- a/pkgs/profpatsch/nman/nman.rs
+++ b/pkgs/profpatsch/nman/nman.rs
@@ -212,7 +212,7 @@ fn build_man_page<'a>(drv: DrvWithOutput, section: Option<&str>, page: &str, tem
     for dir in section_dirs {
         // separate "man" prefix from section indicator,
         // while validating the particular sub directory
-        match dir.to_str().map(|d| d.split_at(3)) {
+        match dir.to_str().filter(|d| d.len() > 3).map(|d| d.split_at(3)) {
             Some((_, "")) => continue,
             Some(("man", s)) => {
                 // we have a valid man dir, check if it contains our page