diff --git a/URLNotesGrabberCORE/DataAccess.cs b/URLNotesGrabberCORE/DataAccess.cs index 99e9490..c54d461 100644 --- a/URLNotesGrabberCORE/DataAccess.cs +++ b/URLNotesGrabberCORE/DataAccess.cs @@ -518,8 +518,12 @@ namespace URLNotesGrabberCORE { if (ownsConnection) connection.Open(); - string updateSql = "UPDATE Posts SET hasImage = " + (hasImage ? 1 : 0) + ", DateModified = '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' WHERE blogName = '" + blogName + "' AND postID = '" + postID + "'"; - SQLiteCommand updateCommand = new SQLiteCommand(updateSql, connection); + string updateSql = "UPDATE Posts SET hasImage = @hasImage, DateModified = @DateModified WHERE blogName = @blogName AND postID = @postID"; + using SQLiteCommand updateCommand = new SQLiteCommand(updateSql, connection); + updateCommand.Parameters.AddWithValue("@hasImage", hasImage ? 1 : 0); + updateCommand.Parameters.AddWithValue("@DateModified", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); + updateCommand.Parameters.AddWithValue("@blogName", blogName); + updateCommand.Parameters.AddWithValue("@postID", postID); updateCommand.ExecuteNonQuery(); } diff --git a/URLNotesGrabberCORE/Program.cs b/URLNotesGrabberCORE/Program.cs index 1604dd8..4fe250d 100644 --- a/URLNotesGrabberCORE/Program.cs +++ b/URLNotesGrabberCORE/Program.cs @@ -175,6 +175,12 @@ namespace URLNotesGrabberCORE break; case "--parse": + if (args.Length < 2) + { + Console.WriteLine("Usage: --parse "); + 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("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("PathOutputBlogs"), false, from, to, top); break;