From 9ad8a7932fa2f25785aeedc054f6a9f76ff6df49 Mon Sep 17 00:00:00 2001 From: Manuel Leduc Date: Wed, 9 Sep 2020 11:53:14 +0200 Subject: [PATCH] XWIKI-17374: Fix escaping in property displayer --- .../xwiki/objects/classes/StringClass.java | 20 +++++-------------- .../xwiki/objects/classes/TextAreaClass.java | 8 +++++++- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java index b69b32e8209..5a30856d836 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/StringClass.java @@ -128,23 +128,13 @@ public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCol public void displayView(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) { - String content = getPropertyText((BaseProperty) object.safeget(name)); - buffer.append(XMLUtils.escapeElementText(content)); - } - - /** - * Get the text of the base property. Returns the empty string if the base property is null. - * @param property the base property - * @return the text of the base property. The empty string is returned if the base property is null - */ - protected String getPropertyText(BaseProperty property) - { - String ret; + BaseProperty property = (BaseProperty) object.safeget(name); + String content; if (property != null) { - ret = property.toText(); + content = property.toText(); } else { - ret = ""; + content = ""; } - return ret; + buffer.append(XMLUtils.escapeElementText(content)); } } diff --git a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/TextAreaClass.java b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/TextAreaClass.java index 52ca40bb031..a8569f85e66 100644 --- a/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/TextAreaClass.java +++ b/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/objects/classes/TextAreaClass.java @@ -381,7 +381,13 @@ public void displayView(StringBuffer buffer, String name, String prefix, BaseCol buffer.append(result); } } else { - String content = getPropertyText((BaseProperty) object.safeget(name)); + BaseProperty property = (BaseProperty) object.safeget(name); + String content; + if (property != null) { + content = property.toText(); + } else { + content = ""; + } if (doc != null) { String syntax = getObjectDocumentSyntax(object, context).toIdString();