Skip to content

Commit ba62873

Browse files
ealonsobrianchandotcom
authored andcommitted
LPS-169645 Escape string
1 parent e6978d6 commit ba62873

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

modules/apps/fragment/fragment-entry-processor/fragment-entry-processor-impl/src/main/java/com/liferay/fragment/entry/processor/internal/util/FragmentEntryProcessorHelperImpl.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
import com.liferay.fragment.entry.processor.helper.FragmentEntryProcessorHelper;
1818
import com.liferay.fragment.processor.FragmentEntryProcessorContext;
1919
import com.liferay.info.exception.NoSuchInfoItemException;
20+
import com.liferay.info.field.InfoField;
2021
import com.liferay.info.field.InfoFieldValue;
22+
import com.liferay.info.field.type.TextInfoFieldType;
2123
import com.liferay.info.formatter.InfoCollectionTextFormatter;
2224
import com.liferay.info.formatter.InfoTextFormatter;
2325
import com.liferay.info.item.ClassPKInfoItemIdentifier;
@@ -41,6 +43,7 @@
4143
import com.liferay.portal.kernel.repository.model.FileEntry;
4244
import com.liferay.portal.kernel.trash.TrashHandler;
4345
import com.liferay.portal.kernel.trash.TrashHandlerRegistryUtil;
46+
import com.liferay.portal.kernel.util.Html;
4447
import com.liferay.portal.kernel.util.LocaleUtil;
4548
import com.liferay.portal.kernel.util.Portal;
4649
import com.liferay.portal.kernel.util.Validator;
@@ -494,6 +497,17 @@ private Object _getMappedInfoItemFieldValue(
494497
}
495498

496499
if (value instanceof String) {
500+
InfoField infoField = infoFieldValue.getInfoField();
501+
502+
if (infoField.getInfoFieldType() instanceof TextInfoFieldType) {
503+
Optional<Boolean> htmlOptional = infoField.getAttributeOptional(
504+
TextInfoFieldType.HTML);
505+
506+
if (htmlOptional.orElse(false)) {
507+
return _html.escape((String)value);
508+
}
509+
}
510+
497511
return (String)value;
498512
}
499513

@@ -533,6 +547,9 @@ private Object _getMappedInfoItemFieldValue(
533547
private static final Log _log = LogFactoryUtil.getLog(
534548
FragmentEntryProcessorHelperImpl.class);
535549

550+
@Reference
551+
private Html _html;
552+
536553
@Reference
537554
private InfoItemServiceRegistry _infoItemServiceRegistry;
538555

0 commit comments

Comments
 (0)