snoopdave commented on code in PR #353:
URL: https://github.com/apache/roller/pull/353#discussion_r4636773146
##########
app/src/main/java/org/apache/roller/weblogger/pojos/wrapper/UserWrapper.java:
##########
@@ -53,19 +53,36 @@ public static UserWrapper wrap(User toWrap) {
*/
public String getUserName() {
if (WebloggerConfig.getBooleanProperty("user.hideUserNames")) {
- return this.pojo.getScreenName();
+ return getScreenName();
}
return this.pojo.getUserName();
}
+ /**
+ * Get the screen name as html escaped text, since users choose their own
+ * screen names and templates print them as they are.
+ */
public String getScreenName() {
- return HTMLSanitizer.conditionallySanitize(this.pojo.getScreenName());
+ return escapeOnce(this.pojo.getScreenName());
}
+ /**
+ * Get the full name as html escaped text.
+ */
public String getFullName() {
- return HTMLSanitizer.conditionallySanitize(this.pojo.getFullName());
+ return escapeOnce(this.pojo.getFullName());
+ }
+
+
+ /**
+ * Names are stored as typed when weblog admins are trusted, and already
+ * html encoded by the sanitizer when they aren't, so decode any entities
+ * before escaping to encode them exactly once.
+ */
+ private static String escapeOnce(String name) {
+ return
StringEscapeUtils.escapeHtml4(StringEscapeUtils.unescapeHtml4(name));
Review Comment:
**Important:** For trusted admins, names are stored as typed. A name typed
literally as `Tom & Jerry` is decoded here and displays as `Tom & Jerry`;
full names have the same problem, and `feeds.vm` also decodes raw media-file
creator names. Preserve literal entities in raw names, decode only values known
to have been stored encoded, and test a name containing literal `&`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]