Wierd issue displaying book description #656

Closed
opened 2026-02-04 21:37:16 +03:00 by OVERLORD · 11 comments
Owner

Originally created by @sprnza on GitHub (Apr 27, 2018).

  • BookStack v0.21.0
  • PHP: 7.2.5-1
  • MySQL: Mariadb 10.1.32-1

If I add this book description it doesn't show up on a book overview page (

tag is just empty), but I do see it when open up the book.

Здесь собираются рецепты, которые мне хотелось бы повторить или дополненные варианты, найденные на просторах Интернета и различных кулинарных книг.

If I add some text in front of the text the issue disappears:

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Здесь собираются рецепты, которые мне хотелось бы повторить или дополненные варианты, найденные на просторах Интернета и различных кулинарных книг.

UPD: if a cut the added text down to Lorem Ipsum is simply dummy text. so the description appears like this:

Lorem Ipsum is simply dummy text. Здесь собираются рецепты, которые мне хотелось бы повторить или дополненные варианты, найденные на просторах Интернета и различных кулинарных книг.

The issue is back.

Originally created by @sprnza on GitHub (Apr 27, 2018). * BookStack v0.21.0 * PHP: 7.2.5-1 * MySQL: Mariadb 10.1.32-1 If I add this book description it doesn't show up on a book overview page (<p> tag is just empty), but I do see it when open up the book. ``` Здесь собираются рецепты, которые мне хотелось бы повторить или дополненные варианты, найденные на просторах Интернета и различных кулинарных книг. ``` If I add some text in front of the text the issue disappears: ``` Lorem Ipsum is simply dummy text of the printing and typesetting industry. Здесь собираются рецепты, которые мне хотелось бы повторить или дополненные варианты, найденные на просторах Интернета и различных кулинарных книг. ``` UPD: if a cut the added text down to `Lorem Ipsum is simply dummy text.` so the description appears like this: ``` Lorem Ipsum is simply dummy text. Здесь собираются рецепты, которые мне хотелось бы повторить или дополненные варианты, найденные на просторах Интернета и различных кулинарных книг. ``` The issue is back.
OVERLORD added the 🐛 Bug🏭 Back-End labels 2026-02-04 21:37:16 +03:00
Author
Owner

@ezzra commented on GitHub (Dec 10, 2018):

Здесь собираются рецепты, которые мне хотелось бы повторить или дополненные варианты, найденные на просторах Интернета и различных кулинарных книг.

works for me, perhaps the issue is just gone in the current release?

@ezzra commented on GitHub (Dec 10, 2018): > Здесь собираются рецепты, которые мне хотелось бы повторить или дополненные варианты, найденные на просторах Интернета и различных кулинарных книг. works for me, perhaps the issue is just gone in the current release?
Author
Owner

@sprnza commented on GitHub (Dec 10, 2018):

Nope, the issue is still there.
BookStack v0.24.2 from docker image solidnerd/bookstack:0.24.2 with mariadb

@sprnza commented on GitHub (Dec 10, 2018): Nope, the issue is still there. BookStack v0.24.2 from docker image `solidnerd/bookstack:0.24.2` with mariadb
Author
Owner

@ezzra commented on GitHub (Dec 10, 2018):

did you look up the database table? what does it look like there? Thats the problem with utf8, it can be scrambled anywhere from input to output, but strange that it just does not show up...

I guess, you have the same problem with all russian textes in description?

@ezzra commented on GitHub (Dec 10, 2018): did you look up the database table? what does it look like there? Thats the problem with utf8, it can be scrambled anywhere from input to output, but strange that it just does not show up... I guess, you have the same problem with all russian textes in description?
Author
Owner

@sprnza commented on GitHub (Dec 10, 2018):

In the database it looks like this:

MariaDB [bookstack]> select * from books;
+----+----------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+------------+------------+------------+----------+
| id | name     | slug     | description                                                                                                                                         | created_at          | updated_at          | created_by | updated_by | restricted | image_id |
+----+----------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+------------+------------+------------+----------+
|  1 | Recipes  | recipes  | Recipes and other kitchen stuff                                                                                                                     | 2018-11-25 17:00:31 | 2018-11-25 17:00:31 |          1 |          1 |          0 |        4 |
|  2 | Medicine | medicine | Medicine related stuff like pills insctructions, prescriptions for each family member etc.                                                          | 2018-12-04 13:40:30 | 2018-12-04 13:40:30 |          1 |          1 |          0 |        5 |
|  3 | Test     | test     | ????? ?????????? ???????, ??????? ??? ???????? ?? ????????? ??? ??????????? ????????, ????????? ?? ????????? ????????? ? ????????? ?????????? ????. | 2018-12-10 11:50:34 | 2018-12-10 11:50:34 |          1 |          1 |          0 |        3 |
|  4 | test     | test-edd | ?????-?? ?????????, ??????? ???????????? ?????????.                                                                                                 | 2018-12-10 11:59:02 | 2018-12-10 11:59:02 |          1 |          1 |          0 |        3 |
+----+----------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+------------+------------+------------+----------+
4 rows in set (0.000 sec)

But I think it's because container doesn't support UTF8 in its console. test-edd is another book I added to check that cyrrillic symbols are being displayed correctly. No, the exact this string from the first post doesn't show up. If I enter another text in Russian it works like it's intended to. Moreover the string that doesn't show up on books overview page does show up when I open up the book.

@sprnza commented on GitHub (Dec 10, 2018): In the database it looks like this: ``` MariaDB [bookstack]> select * from books; +----+----------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+------------+------------+------------+----------+ | id | name | slug | description | created_at | updated_at | created_by | updated_by | restricted | image_id | +----+----------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+------------+------------+------------+----------+ | 1 | Recipes | recipes | Recipes and other kitchen stuff | 2018-11-25 17:00:31 | 2018-11-25 17:00:31 | 1 | 1 | 0 | 4 | | 2 | Medicine | medicine | Medicine related stuff like pills insctructions, prescriptions for each family member etc. | 2018-12-04 13:40:30 | 2018-12-04 13:40:30 | 1 | 1 | 0 | 5 | | 3 | Test | test | ????? ?????????? ???????, ??????? ??? ???????? ?? ????????? ??? ??????????? ????????, ????????? ?? ????????? ????????? ? ????????? ?????????? ????. | 2018-12-10 11:50:34 | 2018-12-10 11:50:34 | 1 | 1 | 0 | 3 | | 4 | test | test-edd | ?????-?? ?????????, ??????? ???????????? ?????????. | 2018-12-10 11:59:02 | 2018-12-10 11:59:02 | 1 | 1 | 0 | 3 | +----+----------+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------+---------------------+---------------------+------------+------------+------------+----------+ 4 rows in set (0.000 sec) ``` But I think it's because container doesn't support UTF8 in its console. test-edd is another book I added to check that cyrrillic symbols are being displayed correctly. No, the exact this string from the first post doesn't show up. If I enter another text in Russian it works like it's intended to. Moreover the string that doesn't show up on books overview page does show up when I open up the book.
Author
Owner

@ezzra commented on GitHub (Dec 10, 2018):

Moreover the string that doesn't show up on books overview page does show up when I open up the book.

ah ok, I didn't understand this because you wrote " it doesn't show up on a book overview page", I thought you are talking about the book page, not the books list. True, I can reproduce the problem on the list, mh

@ezzra commented on GitHub (Dec 10, 2018): > Moreover the string that doesn't show up on books overview page does show up when I open up the book. ah ok, I didn't understand this because you wrote " it doesn't show up on a book overview page", I thought you are talking about the book page, not the books list. True, I can reproduce the problem on the list, mh
Author
Owner

@sprnza commented on GitHub (Dec 10, 2018):

Yep, sorry for my English :)

@sprnza commented on GitHub (Dec 10, 2018): Yep, sorry for my English :)
Author
Owner

@ezzra commented on GitHub (Dec 10, 2018):

workaround: just add a space to the beginning of the description field in databse, this will be cut out and it works like a charme :) But

@ezzra commented on GitHub (Dec 10, 2018): workaround: just add a space to the beginning of the description field in databse, this will be cut out and it works like a charme :) But
Author
Owner

@ezzra commented on GitHub (Dec 10, 2018):

Ok got it, the problem is in line 98 in Entities/Book.php, I already had a feeling that it has something to do with not-multibyte-safe functions, and there it is. Just replace

return strlen($description) > $length ? substr($description, 0, $length-3) . '...' : $description;

with

return mb_strlen($description) > $length ? mb_substr($description, 0, $length-3) . '...' : $description;
@ezzra commented on GitHub (Dec 10, 2018): Ok got it, the problem is in line 98 in `Entities/Book.php`, I already had a feeling that it has something to do with not-multibyte-safe functions, and there it is. Just replace ``` return strlen($description) > $length ? substr($description, 0, $length-3) . '...' : $description; ``` with ``` return mb_strlen($description) > $length ? mb_substr($description, 0, $length-3) . '...' : $description; ```
Author
Owner

@sprnza commented on GitHub (Dec 10, 2018):

Yay! Works!

@sprnza commented on GitHub (Dec 10, 2018): Yay! Works!
Author
Owner

@ezzra commented on GitHub (Dec 10, 2018):

unfortunately, thats not the only position where not mb safe functions are used, I could go on and replace them everywhere. But there is actually a performance issue using them (though to be honest, this is kind of microperformance optimizing).

So the question is, should they be replaced everywhere or should the simple functions be kept where the mb_function is not needed currently? The danger, however, is that something will change and then problems will arise again. I would vote to replace them all, what does @ssddanbrown think?

@ezzra commented on GitHub (Dec 10, 2018): unfortunately, thats not the only position where not mb safe functions are used, I could go on and replace them everywhere. But there is actually a performance issue using them (though to be honest, this is kind of microperformance optimizing). So the question is, should they be replaced everywhere or should the simple functions be kept where the mb_function is not needed currently? The danger, however, is that something will change and then problems will arise again. I would vote to replace them all, what does @ssddanbrown think?
Author
Owner

@ssddanbrown commented on GitHub (May 25, 2019):

Fixed in the next release. Thank for helping and providing info @ezzra.
I've just replaced many where user-provided input might be handled, Will just try to keep in mind to use mb_ functions where needed and handle cases as they arise.

@ssddanbrown commented on GitHub (May 25, 2019): Fixed in the next release. Thank for helping and providing info @ezzra. I've just replaced many where user-provided input might be handled, Will just try to keep in mind to use `mb_` functions where needed and handle cases as they arise.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#656