DirectoryTree / LdapRecord-Laravel

Multi-domain LDAP Authentication & Management for Laravel.
https://ldaprecord.com/docs/laravel/v3
MIT License
509 stars 54 forks source link

Special characters break log file #394

Closed alesf closed 2 years ago

alesf commented 2 years ago

I have broken lines of code in log because special characters in object names are not encoded properly. For example: Log message for fictional user John Hønry produces log message production.INFO: Object with name [John H

I don't know what would be the best way to fix this. Maybe transliteration? iconv("UTF-8", "ISO-8859-1//TRANSLIT", $event->getLogMessage()); or simply utf8_decode($event->getLogMessage()) ?

https://github.com/DirectoryTree/LdapRecord-Laravel/blob/e5a2b9bc8e17eb906dc3b1c1aeeee2b29a9fd16f/src/LdapAuthServiceProvider.php#L88

stevebauman commented 2 years ago

Thanks for the report @alesf!

Ill have a patch out shortly 👍

stevebauman commented 2 years ago

Hmmm, I'm actually not able to reproduce this -- is the editor you're using not able to view the utf8 characters?

Lines are rendered fine in my Laravel application using your example John Hønry:

Screen Shot 2022-02-16 at 9 04 45 PM
alesf commented 2 years ago

I investigated further and found the issue. It was a bit convoluted issue at my part. I have some binary data in my log file and I had to do | strings conversion of the log file to read it and I completely missed that strings command uses 7 bit encoding for formatting. When used with -e S everything works like it should.

I'm sorry for wasting your time.

stevebauman commented 2 years ago

No worries @alesf! Thanks for reporting back, I appreciate it 🙏