From 4dcb86cc4bbbf6bf7bf2fa3145dd44b4cc5615a7 Mon Sep 17 00:00:00 2001 From: "brettw%gmail.com" Date: Thu, 9 Mar 2006 17:27:21 +0000 Subject: [PATCH] Bug 329831 r=annie.sullivan Make QueryStringToQueries return empty array if there is no input. git-svn-id: svn://10.0.0.236/trunk@192067 18797224-902f-48f8-a5cc-f745e15eee43 --- .../places/public/nsINavHistoryService.idl | 4 +++- .../components/places/src/nsNavHistoryQuery.cpp | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/mozilla/browser/components/places/public/nsINavHistoryService.idl b/mozilla/browser/components/places/public/nsINavHistoryService.idl index e6ea665b1e9..fcce2bbe182 100644 --- a/mozilla/browser/components/places/public/nsINavHistoryService.idl +++ b/mozilla/browser/components/places/public/nsINavHistoryService.idl @@ -1029,7 +1029,9 @@ interface nsINavHistoryService : nsISupports /** * Converts a query URI-like string to an array of actual query objects for - * use to executeQueries(). + * use to executeQueries(). The output query array may be empty if there is + * no information. However, there will always be an options structure returned + * (if nothing is defined, it will just have the default values). */ void queryStringToQueries(in AUTF8String aQueryString, [array, size_is(aResultCount)] out nsINavHistoryQuery aQueries, out PRUint32 aResultCount, diff --git a/mozilla/browser/components/places/src/nsNavHistoryQuery.cpp b/mozilla/browser/components/places/src/nsNavHistoryQuery.cpp index ea5e5fe5db1..270b26a54fd 100644 --- a/mozilla/browser/components/places/src/nsNavHistoryQuery.cpp +++ b/mozilla/browser/components/places/src/nsNavHistoryQuery.cpp @@ -233,12 +233,15 @@ nsNavHistory::QueryStringToQueryArray(const nsACString& aQueryString, rv = TokenizeQueryString(aQueryString, &tokens); NS_ENSURE_SUCCESS(rv, rv); - rv = TokensToQueries(tokens, aQueries, options); - if (NS_FAILED(rv)) { - NS_WARNING("Unable to parse the query string: "); - NS_WARNING(PromiseFlatCString(aQueryString).get()); + if (tokens.Length() > 0) { + rv = TokensToQueries(tokens, aQueries, options); + if (NS_FAILED(rv)) { + NS_WARNING("Unable to parse the query string: "); + NS_WARNING(PromiseFlatCString(aQueryString).get()); + } + NS_ENSURE_SUCCESS(rv, rv); } - NS_ENSURE_SUCCESS(rv, rv); + // when there are no tokens, leave the query array empty NS_ADDREF(*aOptions = options); return NS_OK;