After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 758524 - Cannot search documents by title
Cannot search documents by title
Status: RESOLVED FIXED
Product: libgdata
Classification: Platform
Component: Google Documents service
git master
Other All
: Normal major
: ---
Assigned To: libgdata-maint
libgdata-maint
Depends on:
Blocks:
 
 
Reported: 2015-11-23 08:34 UTC by Mardy
Modified: 2015-12-08 18:37 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Update to v2 API (2.43 KB, patch)
2015-11-23 15:37 UTC, Mardy
none Details | Review
Update to v2 API (fix commit message and author's e-mail) (2.43 KB, patch)
2015-11-23 15:39 UTC, Mardy
none Details | Review
Update to v2 API (2.42 KB, patch)
2015-11-25 14:47 UTC, Mardy
committed Details | Review

Description Mardy 2015-11-23 08:34:52 UTC
When searching a document by title, libgdata encodes the title as a URL parameter, instead of composing it into the "q" query string. Google does not recognize this URL parameter and ignores it, causing all searches to return the unfiltered set of documents.

For example, when searching for "family", the following URL is generated:

libgdata-DEBUG: > GET /drive/v2/files?q=trashed%3Dfalse%20and%20mimeType%21%3D%27application%2Fvnd.google-apps.folder%27&title=family HTTP/1.1

instead of the correct one:

/drive/v2/files?q=trashed%3Dfalse%20and%20mimeType%21%3D%27application%2Fvnd.google-apps.folder%27%20and%20title%3D%27family%27

The exact-title property should transform the query string to use "contains", instead of being also appended as an unrecognized URL parameter.
Comment 1 Mardy 2015-11-23 15:37:45 UTC
Created attachment 316099 [details] [review]
Update to v2 API

This patch works for me.
Comment 2 Mardy 2015-11-23 15:39:39 UTC
Created attachment 316100 [details] [review]
Update to v2 API (fix commit message and author's e-mail)
Comment 3 Philip Withnall 2015-11-24 23:48:21 UTC
Review of attachment 316100 [details] [review]:

This looks good; just a few minor fixes needed. Thanks!

::: gdata/services/documents/gdata-documents-query.c
@@ +364,1 @@
 	if (priv->title != NULL) {

Please add a comment pointing to the reference for this syntax: https://developers.google.com/drive/web/search-parameters

@@ +367,3 @@
+
+		title_query = g_string_new ("title");
+		if (priv->exact_title == TRUE) {

No need for the ‘== TRUE’ (I know other code in libgdata does this; it’s an obsolete coding style we’re moving away from).

@@ +375,3 @@
+
+		for (ptr = priv->title; ptr != NULL; ptr = ptr_end)
+		{

The ‘{’ should be on the previous line.
Comment 4 Mardy 2015-11-25 14:47:55 UTC
Created attachment 316247 [details] [review]
Update to v2 API

Thanks Philip for the review. I made a new version with the patch containing the desired changes.
However, I didn't add the comment about the Google search API URL, because that link is already there, at the beginning of that method.
Comment 5 Philip Withnall 2015-11-30 21:56:38 UTC
Review of attachment 316247 [details] [review]:

++
Comment 6 Mardy 2015-12-08 16:06:15 UTC
Hi Philip, I don't have commit access to the repos, so someone else should push this commit for me.
Comment 7 Debarshi Ray 2015-12-08 18:37:19 UTC
Pushed to master.