PDA

View Full Version : Can't post keywords with double-quotes


darryl
Oct-15-2007, 10:29 PM
Man, this is super-frustrating.

In the web UI, if you enter a keyword in "double quotes", as advised by the help pages (http://www.smugmug.com/help/keywords-tags), it ends up in the database (as retrieved by images.getInfo) as "double quotes".

Fine, I can parse for that. But when I go to write keywords back out, I'm trying to use the API like so:


$changeinfo = $browser->post('http://api.smugmug.com/hack/rest/1.2.0/',
['method'=>'smugmug.images.changeSettings',
'SessionID'=>"$sessionid",
'ImageID'=>"$updateimage",
'Keywords'=>"$newkeywordstext"],) ;


If $newkeywordstext contains double-quotes (ex. "ty"), they appear in the web UI prepended with a \, and when I go back with an images.getInfo call, it shows up as:

\"ty\"

Blech. Ok, maybe I should try to HTML encode the double-quotes myself. So I try posting: "ty"

This time images.getInfo gives me the equally ugly:
"ty"

Nasty. I don't want to use semi-colons! Double-quotes make sense to me and to the non-coders that may be editing keywords. Also, I *need* double-quotes so that keywords < 4 characters will be recognized as keywords. Argh!

Any other suggestions on getting the API to properly accept double-quote characters? It kind of sucks when functionality on the website isn't duplicated in the API.

darryl
Oct-16-2007, 01:44 PM
Based on some info from this post, I tried some further experimentation with images.changeSettings in the API:


Posted: &quot;ty&quot;
Got: &amp;quot;ty&amp;quot;

Posted: %26quot;ty%26quot;
Got: %26quot;ty%26quot;

Posted: "ty"
Got: \&quot;ty\&quot;


On the site, only the last one actually resulted in the keyword being properly recognized.

It's annoying though that if you manually type "ty" on the site, it turns into: &quot;ty&quot; without the extraneous backslashes.

lukebaker
Dec-09-2007, 01:03 PM
Bump.

I ran into this issue as well. What is the recommened practice for submitting keywords with double quotes via the API? Thanks.

darryl
Dec-09-2007, 09:06 PM
I ended up just using double-quotes, like "this sucks"

If human users end up looking at that keyword, they'll see:

\"this sucks\"

And using the API call to get quotes, I still get \&quot;this sucks\&quot;

I couldn't find any way around it, so I just use this annoying regexp to fix it before I start to deal with keywords:

$oldkeywords =~ s|\\&quot;|&quot;|g ;

Here's my whole keyword parsing subroutine

devbobo
Dec-10-2007, 12:01 PM
Bump.

I ran into this issue as well. What is the recommened practice for submitting keywords with double quotes via the API? Thanks.

Luke,

You can use semi-colons to seperate keywords, eg.

keyword1; keyword two; more key words;

Cheers,

David

lukebaker
Dec-11-2007, 01:32 PM
You can use semi-colons to seperate keywords, eg.

keyword1; keyword two; more key words;

I have the following keywords:
5 star hotel; indianapolis;

The 5 star hotel keyword does not show up when viewing the page, but will show up when I edit my keywords. It works with double-quotes, excepting the API bug.

pe2smugmug
Jan-07-2008, 05:01 AM
bump.

Is there any new info on this? I'm having a very similar problem with at least my captions and my keywords.

Using the 1.2.0 JSON interface, posting a string that starts and ends with a ", leads to the entire string being escaped, causing some interesting problems.

Using an older XML-RPC interface did NOT have the problem, and the text appears as entered.

devbobo
Jan-07-2008, 11:25 PM
I have fixed this issue internally, hopefully I can roll the changes out soon.

pe2smugmug
Jan-08-2008, 04:35 AM
I have fixed this issue internally, hopefully I can roll the changes out soon.

Thanks David!

devbobo
Jan-12-2008, 02:13 PM
This should now be fixed in api version 1.2.0/1.2.1.

Please let me know if you have any issues.