mschilli / net-google-drive-simple

Net::Google::Drive::Simple CPAN Module
Other
11 stars 22 forks source link

can't get children of folders with single quotes in title #34

Closed Pachelbel1414 closed 2 years ago

Pachelbel1414 commented 4 years ago

consider the following drive path (note the single quote): /foo/bar's/child.txt

calling: my $children = $gd->children( "/foo/bar's" ); fails with 400 error.

google drive api docs says you have to escape single quotes. https://developers.google.com/drive/api/v2/ref-search-terms so I tried calling: my $children = $gd->children( "/foo/bar\'s" ); which sort of works (no 400 error), but also returns no children.

no children are returned, because in Simple.pm, line 363: if ( $child->title() eq $part ) { The condition fails, and it doesn't recurse into the folder. $part = /foo/bar\'s but $title = /foo/bar's

In Simple.pm, line 449, updating the query opts to escape single quotes in title seems to fix this: my $title = $search_opts->{title}; $title =~ s/\'/\\\'/g; # escape single quotes $opts->{'q'} .= " AND title = '$title'"; # ' fix for poor editors and allows the original query to work without user escaping: my $children = $gd->children( "/foo/bar's" );

There are probably other query locations where title should be escaped, but this get's me past this one case.

atoomic commented 2 years ago

thanks for the report this is fixed in v0.18 by a79a1f623c0db8fc8f4676fe7aab3495bdaf03aa