davideuler / pwm

Automatically exported from code.google.com/p/pwm
0 stars 0 forks source link

French characters in select box in Update Profile not working properly #605

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Add new value with French character to select box in Update Profile form 
(example: école)
2. Save form
3. Reload form for same user, previously selected option no longer selected for 
this user

What is the expected output? What do you see instead?
école should be selected when reloading the page

What version of PWM are you using?
1.7.1

What ldap directory and version are you using?
eDirectory 8.8 SP7

Additional information:
If I manually change the entry with a French character in PwmConfiguration.xml 
to the following, I still have the same problem:
\u00E9cole

\u00E9 is the ASCII code for é.

Also, when saving the form, I see the correct value being written to LDAP. So 
the problem is when the info is being read from LDAP, and matched up to the 
values in the select list. The correct value is not selected, and thus not 
displayed.

Original issue reported on code.google.com by bret...@gmail.com on 8 Sep 2014 at 5:15

GoogleCodeExporter commented 9 years ago
The steps should be more like this:
1. Open Config Editor - Add new value with French character to select box in 
Update Profile form (example: école)
2. Login to PWM with user account, update profile, select the value with French 
character
3. Save form
4. Reload form for same user, previously selected option no longer selected for 
this user

Original comment by bret...@gmail.com on 8 Sep 2014 at 5:17

GoogleCodeExporter commented 9 years ago
I was able to get this to work for me with some customizations to 
/pwm/WEB-INF/jsp/fragment/form.jsp:

Added new variable "currentValueLat" at around line 50:

currentValue = currentValue == null ? "" : currentValue;
String currentValueLat = currentValue.replace("\u00E9", "e").replace("\u00E8", 
"e");
currentValue = StringEscapeUtils.escapeHtml(currentValue);

Updated code for <select> tag as below:

<select id="<%=loopConfiguration.getName()%>" 
name="<%=loopConfiguration.getName()%>" style="width:60%;margin-left: 5px">
    <% for (final String optionName : loopConfiguration.getSelectOptions().keySet()) {%>
    <% final String optionNameLat = optionName.replace("\u00E9", "e").replace("\u00E8", "e"); %>
    <option value="<%=optionName%>" <%if(optionNameLat.equals(currentValueLat)){%>selected="selected"<%}%>>
        <%=loopConfiguration.getSelectOptions().get(optionName)%>
    </option>
    <% } %>
</select>

This only works for two French characters so far (é and è), so I just have to 
continue adding more replaces.

Would be nice to have this text comparison fixed in a future release though so 
that all characters work, not only French.

Original comment by bret...@gmail.com on 10 Sep 2014 at 2:18

GoogleCodeExporter commented 9 years ago
And what if you use "é" (without the quotes) instead of "/u00E9" in the 
PwmConfiguration.xml?

Original comment by martijns...@gmail.com on 15 Oct 2014 at 12:12

GoogleCodeExporter commented 9 years ago
There's no way we're writing character mapping code to do "soft" language 
compares like this.  If you can identify an existing, well maintained, 
open-source library that does this we will consider adding it.

Original comment by jrivard on 15 Oct 2014 at 7:20

GoogleCodeExporter commented 9 years ago
I wasn't at all suggesting adding character mappings into the code as I did, 
that would be quite ridiculous. I was able to use it to get this working in my 
case specifically, because I needed something now, and only had to translate 
the most well known French characters.

What I was suggesting is to fix the text comparison (whatever that is) so that 
characters from languages other than English are also properly matched up.

Original comment by bret...@gmail.com on 15 Oct 2014 at 7:27