From c594d27af85234f813fd7c6a6329dccbe19ac424 Mon Sep 17 00:00:00 2001 From: Eudaldo Alonso Date: Tue, 21 May 2024 14:07:21 +0200 Subject: [PATCH] LPD-25739 Don't escape value if the text field is an URL --- .../FragmentEntryProcessorHelperImpl.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/modules/apps/fragment/fragment-entry-processor/fragment-entry-processor-impl/src/main/java/com/liferay/fragment/entry/processor/internal/util/FragmentEntryProcessorHelperImpl.java b/modules/apps/fragment/fragment-entry-processor/fragment-entry-processor-impl/src/main/java/com/liferay/fragment/entry/processor/internal/util/FragmentEntryProcessorHelperImpl.java index 79c897d6ce7083..9e04e9987684c5 100644 --- a/modules/apps/fragment/fragment-entry-processor/fragment-entry-processor-impl/src/main/java/com/liferay/fragment/entry/processor/internal/util/FragmentEntryProcessorHelperImpl.java +++ b/modules/apps/fragment/fragment-entry-processor/fragment-entry-processor-impl/src/main/java/com/liferay/fragment/entry/processor/internal/util/FragmentEntryProcessorHelperImpl.java @@ -52,12 +52,16 @@ import com.liferay.portal.kernel.trash.TrashHandlerRegistryUtil; import com.liferay.portal.kernel.util.DateFormatFactoryUtil; import com.liferay.portal.kernel.util.HtmlUtil; +import com.liferay.portal.kernel.util.HttpComponentsUtil; import com.liferay.portal.kernel.util.KeyValuePair; import com.liferay.portal.kernel.util.LocaleUtil; import com.liferay.portal.kernel.util.Portal; import com.liferay.portal.kernel.util.Validator; import com.liferay.portal.kernel.util.WebKeys; +import java.net.URI; +import java.net.URISyntaxException; + import java.text.DateFormat; import java.text.ParseException; @@ -433,6 +437,21 @@ else if (value instanceof String) { else if (infoField.getInfoFieldType() instanceof TextInfoFieldType) { + URI uri = null; + + try { + uri = HttpComponentsUtil.getURI((String)value); + } + catch (URISyntaxException uriSyntaxException) { + if (_log.isDebugEnabled()) { + _log.debug(uriSyntaxException); + } + } + + if (uri != null) { + return value; + } + return HtmlUtil.escape((String)value); }