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:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user