fix: parameterize AddPost fallback UPDATE, guard args indexing

Posts.hasImage/DateModified fallback update built its WHERE clause via
raw string concatenation of blogName/postID, unlike every other query
in this method — a blog name containing a single quote would break or
inject into the query. Switch it to parameters.

--parse, --blogsO, and --bop indexed args[1..3] before checking
args.Length, so a missing argument threw IndexOutOfRangeException
instead of hitting the intended usage message.
This commit is contained in:
jim
2026-06-30 20:41:51 -05:00
parent 4df73367fb
commit 0ff80a0fd3
2 changed files with 16 additions and 4 deletions
+10 -2
View File
@@ -175,6 +175,12 @@ namespace URLNotesGrabberCORE
break;
case "--parse":
if (args.Length < 2)
{
Console.WriteLine("Usage: --parse <blogname>");
exitCode = 2;
break;
}
string blogNameToParse = args[1];
int postsAdded = 0;
try
@@ -283,7 +289,7 @@ namespace URLNotesGrabberCORE
case "--blogsO": //collect notes from all posts
int from = 1, to = 999999, top = 100;
if (args[1] is not null && args[2] is not null && args[3] is not null)
if (args.Length >= 4 && args[1] is not null && args[2] is not null && args[3] is not null)
{
from = int.Parse(args[1]);
to = int.Parse(args[2]);
@@ -293,6 +299,7 @@ namespace URLNotesGrabberCORE
{
Console.WriteLine("--Expected FROM TO--");
exitCode = 2;
break;
}
WriteBlogsToFile(settings.GetValue<string>("PathOutputBlogs"), false, from, to, top);
break;
@@ -300,7 +307,7 @@ namespace URLNotesGrabberCORE
case "--bop": //collect notes from all posts
from = 1; to = 999999; top = 100;
if (args[1] is not null && args[2] is not null && args[3] is not null)
if (args.Length >= 4 && args[1] is not null && args[2] is not null && args[3] is not null)
{
from = int.Parse(args[1]);
to = int.Parse(args[2]);
@@ -310,6 +317,7 @@ namespace URLNotesGrabberCORE
{
Console.WriteLine("--Expected FROM TO--");
exitCode = 2;
break;
}
WriteBlogsToFileAll(settings.GetValue<string>("PathOutputBlogs"), false, from, to, top);
break;