Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API database/backup returns a broken string. #491

Closed
Bo26fhmC5M opened this issue Jul 31, 2021 · 2 comments
Closed

API database/backup returns a broken string. #491

Bo26fhmC5M opened this issue Jul 31, 2021 · 2 comments

Comments

@Bo26fhmC5M
Copy link

Bo26fhmC5M commented Jul 31, 2021

I imported metadata from the plugin that reads one json file. Metadata was added without breaking on 'Edit Metadata' page, but when I request api to back up my database, a broken string is returned.

632251.json

{"gid": 632251, "title": "(COMIC1\u26064) [Hyoco Road (Hyocorou)] O, Ore no Imouto gaa + Paper Shiori (Ore no Imouto ga Konna ni Kawaii Wake ga Nai)", "title_jpn": "(COMIC1\u26064) [\u3072\u3087\u3053\u9053 (\u3072\u3087\u3053\u308d\u30fc)] \u304a\u3001\u4ffa\u306e\u59b9\u304c\u3041 + \u30da\u30fc\u30d1\u30fc\u30fb\u3057\u304a\u308a (\u4ffa\u306e\u59b9\u304c\u3053\u3093\u306a\u306b\u53ef\u611b\u3044\u308f\u3051\u304c\u306a\u3044) [\u97d3\u56fd\u7ffb\u8a33]", "category": "Doujinshi", "tags": ["language:translated", "parody:ore no imouto ga konna ni kawaii wake ga nai", "character:kirino kousaka", "character:kyousuke kousaka", "group:hyoco road", "artist:hyocorou", "female:sister", "incest"]}

On 'Edit Metadata' page

Current File Name: /home/koyomi/lanraragi/content/[Hyocorou]/632251.zip
ID: 7b11055e2684fcd70ab7329e653ef58bdfc6f4fe
Title: (COMIC1☆4) [Hyoco Road (Hyocorou)] O, Ore no Imouto gaa + Paper Shiori (Ore no Imouto ga Konna ni Kawaii Wake ga Nai)
Tags: language:translated, parody:ore no imouto ga konna ni kawaii wake ga nai, character:kirino kousaka, character:kyousuke kousaka, group:hyoco road, artist:hyocorou, female:sister, incest, expunged:0, category:Doujinshi, title_jpn:(COMIC1☆4) [ひょこ道 (ひょころー)] お、俺の妹がぁ + ペーパー・しおり (俺の妹がこんなに可愛いわけがない) [韓国翻訳], gid:632251

Edit Metadata page

API database/backup

GET | http://localhost:3000/api/database/backup

Response Header :
HTTP/1.1 200 OK
Content-Length: 60996
Date: Sat, 31 Jul 2021 02:17:46 GMT
Server: Mojolicious (Perl)
Content-Type: application/json;charset=UTF-8
Set-Cookie: [Censored]

Request Header :
GET /api/database/backup HTTP/1.1
Host: localhost:3000
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:90.0) Gecko/20100101 Firefox/90.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,/;q=0.8
Accept-Language: ko-KR,ko;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cookie: [Censored]
Upgrade-Insecure-Requests: 1
Sec-Fetch-Dest: document
Sec-Fetch-Mode: navigate
Sec-Fetch-Site: none
Sec-Fetch-User: ?1
Cache-Control: max-age=0

backup.json (Partial)

...................
{"arcid":"7b11055e2684fcd70ab7329e653ef58bdfc6f4fe","filename":"632251","tags":" language:translated, parody:ore no imouto ga konna ni kawaii wake ga nai, character:kirino kousaka, character:kyousuke kousaka, group:hyoco road, artist:hyocorou, female:sister, incest, expunged:0, category:Doujinshi, title_jpn:(COMIC1�4) [���� (�����)] ��俺�妹�� + �������� (俺�妹�������������) [��翻訳], gid:632251","thumbhash":null,"title":"(COMIC1�4) [Hyoco Road (Hyocorou)] O, Ore no Imouto gaa + Paper Shiori (Ore no Imouto ga Konna ni Kawaii Wake ga Nai)"}
...................

backup json partial

Initially, the JSON file is represented by Unicode hexadecimal, but the backup JSON seems to have no backslash.

@Bo26fhmC5M
Copy link
Author

Bo26fhmC5M commented Jul 31, 2021

The problem seems to be resolved. I modified some codes and build a docker image and performed a test. String is no longer broken.

fixed

LANraragi/lib/LANraragi/Controller/Api/Database.pm

sub serve_backup {
my $self = shift;

# $self->render( json => from_json(LANraragi::Model::Backup::build_backup_JSON) );
$self->render( json => decode_json(LANraragi::Model::Backup::build_backup_JSON) );

}

@Difegue
Copy link
Owner

Difegue commented Aug 1, 2021

Thanks for the detailed report - I've noticed this was affecting /api/database/stats as well so I fixed both endpoints. 🎉

@Difegue Difegue closed this as completed Aug 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants