munki / mwa2

Version 2 of MunkiWebAdmin
Other
156 stars 37 forks source link

Touché #45

Closed nwai closed 3 years ago

nwai commented 3 years ago

Having issue with MWA2 not liking applications with an accent over e. As in Touché. MWA2 lets users add the app into a manifest, refresh the page and it's pink, add app again, rinse repeat

gregneagle commented 3 years ago

I'm going to need a little more than that to replicate and do anything about it.

gregneagle commented 3 years ago

After some guessing, I think I understand the issue, which is Unicode-related. There are often multiple ways to represent what visually looks like the same Unicode text:

>>> a = b'Touch\xc3\xa9'.decode('utf-8')
>>> b = b'Touche\xcc\x81'.decode('utf-8')
>>> a
'Touché'
>>> b
'Touché'
>>> a == b
False

a and b are two different Unicode strings that visually look the same. One way to address this is:

>>> import unicodedata
>>> unicodedata.normalize("NFC", a) == unicodedata.normalize("NFC", b)
True

This actually also affects Munki itself, and I'm mystified that no-one has surfaced this issue to date. Addressed in Munki here: https://github.com/munki/munki/commit/80bf6d48add04aec498eea690b9a1b21a64a0319

gregneagle commented 3 years ago

Thinking about this a bit more, this might also be affected by operating system differences. If MWA2 is running on Linux, it might store Unicode characters non-normalized, or normalized using an alternate format from that used by macOS. This might explain why I haven't gotten a lot of reports for this issue.

gregneagle commented 3 years ago

Yes, it's definitely affected by OS.
MWA2 running on Red Hat Enterprise Linux 7.6:

image

MWA2 running on macOS 10.15.6:

image
gregneagle commented 3 years ago

I think this addresses the issue: https://github.com/munki/mwa2/commit/8e8d9084046ca6a7d1e642a325ad72890db07ae6
You'll need to pull the changes, and then you might need to activate the virtualenv and do a python ./mwa2/manage.py collectstatic depending on how you've configured the webserver portion.

nwai commented 3 years ago

Thank you Greg. Guessing you're not going to need more than that. Are there no French munk/mwa2 users? Surely if there were someone may have come across this.

Astounded at how your brain must work. Of course unicode chars! Your fix is so much more elegant, I just worked around it by renaming Touché to Touche in Munki Admin. Your work, and that of all contributors to the Munki solution to managing macOS devices post monolithic imaging is very, very much appreciated.