Skip to content

Commit a1b50b1

Browse files
authored
fix(blockEditor): Ensure JSON is parse correctly on field variables (dotCMS#31398)
This pull request includes changes to the `edit_field.jsp` file in the `dotCMS` project to properly handle and escape JSON values in field variables. The most important changes are focused on ensuring that JSON values are correctly processed and escaped to avoid issues with double quotes. Key changes: * Added logic to process each field variable and escape JSON values properly in `edit_field.jsp`. * Introduced a mechanism to handle double quotes in JSON values when setting field variables in `edit_field.jsp`. https://github.com/user-attachments/assets/ab145b7f-06bc-41e2-8720-122b9eb65369
1 parent ff4f11c commit a1b50b1

File tree

1 file changed

+3
-2
lines changed
  • dotCMS/src/main/webapp/html/portlet/ext/contentlet/field

1 file changed

+3
-2
lines changed

dotCMS/src/main/webapp/html/portlet/ext/contentlet/field/edit_field.jsp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,9 @@
242242
Logger.error(this.getClass(), e.getMessage());
243243
}
244244
245-
List<FieldVariable> acceptTypes=APILocator.getFieldAPI().getFieldVariablesForField(field.getInode(), user, false);
246-
String fieldVariablesContent = mapper.writeValueAsString(acceptTypes); // Field Variables
245+
List<FieldVariable> acceptTypes = APILocator.getFieldAPI().getFieldVariablesForField(field.getInode(), user, false);
246+
String fieldVariablesContent = StringEscapeUtils.escapeJavaScript(mapper.writeValueAsString(acceptTypes));
247+
247248
%>
248249
<script src="/html/showdown.min.js"></script>
249250
<div id="block-editor-<%=field.getVelocityVarName()%>-container">

0 commit comments

Comments
 (0)