From fb5fcfe60da9f3c393a5042b346a33342e76f75f Mon Sep 17 00:00:00 2001 From: labkey-matthewb Date: Thu, 11 Jan 2024 08:09:06 -0800 Subject: [PATCH] consistency between jackson/org.json.JSONObject/PageFlowUtil (#5117) --- api/src/org/labkey/api/data/JsonTest.java | 2 + .../api/notification/notificationpanel.jsp | 2 +- .../labkey/api/reports/report/r/RReport.java | 40 ++++++++++++++++++- api/src/org/labkey/api/util/PageFlowUtil.java | 3 ++ core/src/org/labkey/core/CoreModule.java | 13 ++++++ .../org/labkey/core/user/securityAccess.jsp | 2 +- .../labkey/pipeline/startPipelineImport.jsp | 2 +- .../survey/view/customizeSurveysWebPart.jsp | 2 +- .../org/labkey/survey/view/surveyWizard.jsp | 6 +-- 9 files changed, 63 insertions(+), 9 deletions(-) diff --git a/api/src/org/labkey/api/data/JsonTest.java b/api/src/org/labkey/api/data/JsonTest.java index e5c77c55f4d..c71d7a09605 100644 --- a/api/src/org/labkey/api/data/JsonTest.java +++ b/api/src/org/labkey/api/data/JsonTest.java @@ -101,12 +101,14 @@ public void jsonOrgViaJackson() throws IOException obj.put("str", "hello"); obj.put("arr", new JSONArray(Arrays.asList("one", null, 3, new JSONObject(Collections.singletonMap("four", 4))))); obj.put("nul", (Object)null); + obj.put("key", " - +   diff --git a/api/src/org/labkey/api/reports/report/r/RReport.java b/api/src/org/labkey/api/reports/report/r/RReport.java index ddd87e0e3fa..9498d006c12 100644 --- a/api/src/org/labkey/api/reports/report/r/RReport.java +++ b/api/src/org/labkey/api/reports/report/r/RReport.java @@ -219,12 +219,48 @@ public static synchronized String getDefaultRPath() return DEFAULT_APP_PATH; } + public static String toR(String s) { - String r = PageFlowUtil.jsString(s); - return "\"" + StringUtils.strip(r, "'") + "\""; + if (s == null) + return "\"\""; + + StringBuilder r = new StringBuilder(s.length() + 10); + r.append("\""); + int len = s.length(); + for (int i = 0 ; i inputParameters) { diff --git a/api/src/org/labkey/api/util/PageFlowUtil.java b/api/src/org/labkey/api/util/PageFlowUtil.java index ea0719e355f..1622de38ee3 100644 --- a/api/src/org/labkey/api/util/PageFlowUtil.java +++ b/api/src/org/labkey/api/util/PageFlowUtil.java @@ -422,6 +422,9 @@ public static String jsString(String s) case '\\': js.append("\\\\"); break; + case '/': + js.append("\\/"); + break; case '\n': js.append("\\n"); break; diff --git a/core/src/org/labkey/core/CoreModule.java b/core/src/org/labkey/core/CoreModule.java index 2910d8ce61d..6e0e8a050f6 100644 --- a/core/src/org/labkey/core/CoreModule.java +++ b/core/src/org/labkey/core/CoreModule.java @@ -15,6 +15,7 @@ */ package org.labkey.core; +import com.fasterxml.jackson.core.io.CharTypes; import com.google.common.collect.Sets; import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; @@ -308,6 +309,18 @@ public class CoreModule extends SpringModule implements SearchService.DocumentPr // Register dialect extra early, since we need to initialize the data sources before calling DefaultModule.initialize() SqlDialectRegistry.register(new PostgreSqlDialectFactory()); + + try + { + var field = CharTypes.class.getDeclaredField("sOutputEscapes128"); + field.setAccessible(true); + ((int[])field.get(null))['/'] = '/'; + field.setAccessible(false); + } + catch (NoSuchFieldException|IllegalArgumentException|IllegalAccessException x) + { + // pass + } } private CoreWarningProvider _warningProvider; diff --git a/core/src/org/labkey/core/user/securityAccess.jsp b/core/src/org/labkey/core/user/securityAccess.jsp index b14312c6923..641f0e9dd46 100644 --- a/core/src/org/labkey/core/user/securityAccess.jsp +++ b/core/src/org/labkey/core/user/securityAccess.jsp @@ -79,7 +79,7 @@ However, if this account were re-enabled, it would have the following permissions. <% } %> - lk-region-name=<%=q(accessRegion.getName())%> class="labkey-data-region-legacy labkey-show-borders"> +
diff --git a/pipeline/src/org/labkey/pipeline/startPipelineImport.jsp b/pipeline/src/org/labkey/pipeline/startPipelineImport.jsp index e8443444bc3..01fcaeccc1b 100644 --- a/pipeline/src/org/labkey/pipeline/startPipelineImport.jsp +++ b/pipeline/src/org/labkey/pipeline/startPipelineImport.jsp @@ -62,7 +62,7 @@ > - > +
diff --git a/survey/src/org/labkey/survey/view/customizeSurveysWebPart.jsp b/survey/src/org/labkey/survey/view/customizeSurveysWebPart.jsp index 833abb6289d..cb787d61612 100644 --- a/survey/src/org/labkey/survey/view/customizeSurveysWebPart.jsp +++ b/survey/src/org/labkey/survey/view/customizeSurveysWebPart.jsp @@ -40,7 +40,7 @@ %> This webpart displays a list of survey instances created by the end user. Select which survey design this webpart should use:

-
>
+