Blob Blame Raw
commit ddce1f9332b6c4ff8d852379e1faab4b9ebc6a81
Author: Richard Hughes <richard@hughsie.com>
Date:   Wed Jul 30 17:00:11 2008 +0100

    bugfix: WhatProvides has a freeform search string that we don't check, also, check for wildcards before length to pick up a single star

diff --git a/src/pk-transaction.c b/src/pk-transaction.c
index 97875a7..7ae5c95 100644
--- a/src/pk-transaction.c
+++ b/src/pk-transaction.c
@@ -979,24 +979,24 @@ pk_transaction_search_check (const gchar *search, GError **error)
 				     "Search string zero length");
 		return FALSE;
 	}
-	if (size < 2) {
+	if (strstr (search, "*") != NULL) {
 		*error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_SEARCH_INVALID,
-				     "The search string length is too small");
+				     "Invalid search containing '*'");
 		return FALSE;
 	}
-	if (size == 1024) {
+	if (strstr (search, "?") != NULL) {
 		*error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_SEARCH_INVALID,
-				     "The search string length is too large");
+				     "Invalid search containing '?'");
 		return FALSE;
 	}
-	if (strstr (search, "*") != NULL) {
+	if (size < 2) {
 		*error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_SEARCH_INVALID,
-				     "Invalid search containing '*'");
+				     "The search string length is too small");
 		return FALSE;
 	}
-	if (strstr (search, "?") != NULL) {
+	if (size == 1024) {
 		*error = g_error_new (PK_TRANSACTION_ERROR, PK_TRANSACTION_ERROR_SEARCH_INVALID,
-				     "Invalid search containing '?'");
+				     "The search string length is too large");
 		return FALSE;
 	}
 	ret = pk_strvalidate (search);
@@ -2872,6 +2872,13 @@ pk_transaction_what_provides (PkTransaction *transaction, const gchar *filter, c
 		return;
 	}
 
+	/* check the search term */
+	ret = pk_transaction_search_check (search, &error);
+	if (!ret) {
+		dbus_g_method_return_error (context, error);
+		return;
+	}
+
 	/* check the filter */
 	ret = pk_transaction_filter_check (filter, &error);
 	if (!ret) {