From 8b277607cf4620ed0fd37e775c5ed7f5db4f01d3 Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Tue, 8 Oct 2024 17:37:48 -0400 Subject: [PATCH 1/2] Fix guard for unitialized variable The original guard was preventing an id with value of zero from being processed correctly. --- site-generator | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/site-generator b/site-generator index e1ff3cb..2feb8dc 100755 --- a/site-generator +++ b/site-generator @@ -290,26 +290,23 @@ sub parse_page_arg { # Split page name from page ids if available. my ($page, $ids) = split(/=/, $page_arg); my @ids; + $ids = "" unless defined $ids; - if(!$ids) { - $ids = ""; - } - else { - # Parse the page ids and push them onto @ids array - my @ids_by_comma = split(/\,/, $ids); - foreach my $id_by_comma (@ids_by_comma) { - my @ids_for_range = split(/\.\./, $id_by_comma); - if ((scalar @ids_for_range) == 2) { - push @ids, $ids_for_range[0]..$ids_for_range[1]; - } - elsif ((scalar @ids_for_range) == 1) { - push @ids, $ids_for_range[0]; - } - else { - verbose (1, "\nWarning: Page $page id range $id_by_comma could not be parsed."); - } + # Parse the page ids and push them onto @ids array + my @ids_by_comma = split(/\,/, $ids); + foreach my $id_by_comma (@ids_by_comma) { + my @ids_for_range = split(/\.\./, $id_by_comma); + if ((scalar @ids_for_range) == 2) { + push @ids, $ids_for_range[0]..$ids_for_range[1]; + } + elsif ((scalar @ids_for_range) == 1) { + push @ids, $ids_for_range[0]; + } + else { + verbose (1, "\nWarning: Page $page id range $id_by_comma could not be parsed."); } } + return ('page' => $page, 'ids' => [@ids]); } From 85d43851d1cfafb0c3d21d497ea2bd9449fd52b9 Mon Sep 17 00:00:00 2001 From: Roan Horning Date: Tue, 8 Oct 2024 21:49:58 -0400 Subject: [PATCH 2/2] Fix substring initial offset value Remove only the leading comma character. --- site-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site-generator b/site-generator index 2feb8dc..f5d67ab 100755 --- a/site-generator +++ b/site-generator @@ -323,7 +323,7 @@ sub get_ids_from_db { || die $tt->error(), "\n"; # Starts with a newline and comma - return split(/,/, substr($selected_ids, 2)); + return split(/,/, substr($selected_ids, 1)); } sub get_filename {