Gelbooru

Notice: Do you have an artist tag on Gelbooru? Let us know so we can properly credit you!

Now Viewing: API: >_<

Keep it civil, do not flame or bait other users. If you notice anything illegal or inappropriate being discussed, contact an administrator or moderator.

shionsan Group: Member - Total Posts: 19
user_avatar
API: >_<
Posted on: 02/02/18 04:14PM
When you request a post data - you get "&gt;_&lt;" in tags instead of ">_<".

I can somewhat guess why it came to this, but should it really be this way when:

gelbooru.com/index.php?pa...json=1&name=>_<
gelbooru.com/index.php?pa...mp;name=&gt;_&lt;
gelbooru.com/index.php?pa...ag&q=index&json=1

?

shionsan Group: Member - Total Posts: 19
user_avatar
Posted on: 02/02/18 09:45PM
There also seem to be tags that are in lower case in post table and have some upper characters in tags table. Ex: potemayo, tags API return Potemayo

Jerl Group: Administrator's Pet - Total Posts: 4383
user_avatar
Posted on: 02/02/18 10:46PM
Yes, it should be that way. &gt; and &lt; are proper HTML encoding for greater-than and less-than symbols. Leaving them unencoded in the JSON can cause problems. You'll run into that with a lot of other special characters too. You will need to decode special characters yourself. Almost all programming languages have this built in in one way or another.

It doesn't work in reverse because URL's use a different encoding method from HTML. While with < and > it isn't as necessary as with certain other special characters, those are usually encoded in URL's as well as %3C and %3E respectively. If you request "%3E_%3C, it will load as expected. Your browser will likely even automatically display it as ">_<", and when you request ">_<" instead of "%3E_%3C", your browser will usually automatically encode the < and > as well in the actual request.

shionsan Group: Member - Total Posts: 19
user_avatar
Posted on: 02/03/18 07:43AM
I always thought you only have to deal with ' and " in json strings and tag attributes, while doing htmlspecialchars only when data is outside tags in XML/HTML and urlencode for URL GET values. I suppose everyone has his own ways to deal with data.

Wish you'd have a proper API documentation (at least I failed to find it). Had to learn many things the hard way.

shionsan Group: Member - Total Posts: 19
user_avatar
Posted on: 02/05/18 01:06PM
And now I found some images with "\r\n" stuck to some of their tags... Ex: gelbooru.com/index.php?pa...&tags=%5cr%5cnhighres

Jerl Group: Administrator's Pet - Total Posts: 4383
user_avatar
Posted on: 02/05/18 03:34PM
That's a known issue. For some reason linebreaks (and tabs, and em/en-spaces, etc) don't get converted into spaces before being saved. Since we escape everything input by users, it ends up getting converted to that and stuck to the adjacent tag in the database.

add_replyAdd Reply

1