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

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

Closed
johnroyer opened this issue Jan 17, 2022 · 2 comments
Labels
Milestone

Comments

@johnroyer
Copy link
Contributor

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
ssddanbrown added a commit to ssddanbrown/HtmlDiff that referenced this issue Jan 24, 2022
Was causing issues when multibyte characters would be split into
many words and potentially be cut within character boundaries.

Originally reported at BookStackApp/BookStack#3170
ssddanbrown added a commit that referenced this issue Jan 24, 2022
Addresses potential issue when using multibyte characters.
Couple of other packages seemed to have updates also since earlier.

For #3170
@ssddanbrown ssddanbrown added this to the v21.12.3 milestone Jan 24, 2022
@ssddanbrown
Copy link
Member

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: ssddanbrown/HtmlDiff@4894499...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.

@johnroyer
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants