Changeset 5146 in josm for trunk


Ignore:
Timestamp:
2012-03-31T20:44:13+02:00 (8 years ago)
Author:
bastiK
Message:

fixed #7558 - History window shows XML entities in user names

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserModel.java

    r4734 r5146  
    441441                        User user = p.getUser();
    442442                        if (user != null)
    443                             return "<html>" + XmlWriter.encode(user.getName()) + " <font color=gray>(" + user.getId() + ")</font></html>";
     443                            return "<html>" + XmlWriter.encode(user.getName(), true) + " <font color=gray>(" + user.getId() + ")</font></html>";
    444444                    }
    445445                    return null;
  • trunk/src/org/openstreetmap/josm/io/XmlWriter.java

    r4645 r5146  
    2222    }
    2323
     24    public static String encode(String unencoded) {
     25        return encode(unencoded, false);
     26    }
     27
    2428    /**
    2529     * Encode the given string in XML1.0 format.
    2630     * Optimized to fast pass strings that don't need encoding (normal case).
     31     *
     32     * @param unencoded the unencoded input string
     33     * @param keepApos true if apostrophe sign should stay as it is (in order to work around
     34     * a Java bug that renders
     35     *     new JLabel("<html>&apos;</html>")
     36     * literally as 6 character string, see #7558)
    2737     */
    28     public static String encode(String unencoded) {
     38    public static String encode(String unencoded, boolean keepApos) {
    2939        StringBuilder buffer = null;
    3040        for (int i = 0; i < unencoded.length(); ++i) {
    31             String encS = XmlWriter.encoding.get(unencoded.charAt(i));
     41            String encS = null;
     42            if (!keepApos || unencoded.charAt(i) != '\'') {
     43                encS = XmlWriter.encoding.get(unencoded.charAt(i));
     44            }
    3245            if (encS != null) {
    3346                if (buffer == null) {
Note: See TracChangeset for help on using the changeset viewer.