[Bug Report]: diff tool error while processing space between general and multibytes characters #2580

Closed
opened 2026-02-05 04:33:24 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @johnroyer on GitHub (Jan 17, 2022).

Describe the Bug

Diff tool can not work correctly if add/delete space in general character and multibytes characters.

2022-01-17_160517

Steps to Reproduce

  1. Create a page
  2. copy and paste this string: test測試
  3. Save page. (revision 1)
  4. Edit page
  5. Add a space between the words. New string will be: test 測試
  6. Save page. (revision 2)
  7. Click Revision of page details.
  8. Click Changes on the latest revision.
  9. Diff tool show some un-expect digits: 2022-01-17_162254

Expected Behaviour

Diff tool should show spaces only.

Screenshots or Additional Context

Error WILL occur if and if the add / delete space between general character and multibyte character.


The error will NOT occur on this conditions:

  • New space between general characters. Example: unittest to unit test.
  • New space between multibyte characters. Example: 你好 to 你 好.

Exact BookStack Version

21.12

PHP Version

7.4.27

Hosting Environment

  • Ubuntu 20.04.3 LTS
  • Nginx 1.18.0 (reverse proxy)
  • PHP-fpm 7.4.27
Originally created by @johnroyer on GitHub (Jan 17, 2022). ### Describe the Bug Diff tool can not work correctly if add/delete space in general character and multibytes characters. ![2022-01-17_160517](https://user-images.githubusercontent.com/114491/149732817-9bfffd15-774f-4828-b7fe-2f0f50976259.png) ### Steps to Reproduce 1. Create a page 2. copy and paste this string: `test測試` 3. Save page. (revision 1) 4. Edit page 5. Add a space between the words. New string will be: `test 測試` 6. Save page. (revision 2) 7. Click `Revision` of page details. 8. Click `Changes` on the latest revision. 9. Diff tool show some un-expect digits: ![2022-01-17_162254](https://user-images.githubusercontent.com/114491/149733566-6b13a913-e76f-421e-90a0-aac41eff3d95.png) ### Expected Behaviour Diff tool should show spaces only. ### Screenshots or Additional Context Error WILL occur if and if the add / delete space between general character and multibyte character. ---- The error will NOT occur on this conditions: - New space between general characters. Example: `unittest` to `unit test`. - New space between multibyte characters. Example: `你好` to `你 好`. ### Exact BookStack Version 21.12 ### PHP Version 7.4.27 ### Hosting Environment - Ubuntu 20.04.3 LTS - Nginx 1.18.0 (reverse proxy) - PHP-fpm 7.4.27
OVERLORD added the 🐛 Bug label 2026-02-05 04:33:24 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Jan 24, 2022):

Thanks for reporting @johnroyer. Could confirm this on my setup.

I maintain the diff handling as a separate project.
I made some updates to handle the provided scenario: 4894499ba6...v1.0.2
Needed to add manual multi-byte handling since using PHP multi-byte functions would end up exponentially slower.

I've updated the version of the library BookStack uses so this should be fixed in the next patch release. Will therefore close this off.

@ssddanbrown commented on GitHub (Jan 24, 2022): Thanks for reporting @johnroyer. Could confirm this on my setup. I maintain the diff handling as a [separate project](https://github.com/ssddanbrown/HtmlDiff). I made some updates to handle the provided scenario: https://github.com/ssddanbrown/HtmlDiff/compare/4894499ba6b58985ac11c185b3ec73bafa97c7ce...v1.0.2 Needed to add manual multi-byte handling since using PHP multi-byte functions would end up exponentially slower. I've [updated the version](f88e6d15201a8cf5290a188cf9138c3537d7fc32) of the library BookStack uses so this should be fixed in the next patch release. Will therefore close this off.
Author
Owner

@johnroyer commented on GitHub (Feb 2, 2022):

Fix confirmed in v21.12.4 . Everything goes well.
Thanks for helping.

@johnroyer commented on GitHub (Feb 2, 2022): Fix confirmed in v21.12.4 . Everything goes well. Thanks for helping.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2580