Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into fb_requireComments
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-susanh committed Jan 23, 2024
2 parents b805a65 + 392bf29 commit 79f5f5b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 35 deletions.
18 changes: 13 additions & 5 deletions api/src/org/labkey/api/reader/HTMLDataLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.labkey.api.util.FileType;
import org.labkey.api.util.StringUtilsLabKey;
import org.labkey.api.util.JSoupUtil;
import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
Expand Down Expand Up @@ -82,12 +83,19 @@ public boolean isHeaderMatch(@NotNull byte[] header)
String s = new String(header, StringUtilsLabKey.DEFAULT_CHARSET);

List<String> errors = new ArrayList<>();
Document doc = JSoupUtil.convertHtmlToDocument(s, true, errors);
if (!errors.isEmpty() || doc == null)
return false;
try
{
Document doc = JSoupUtil.convertHtmlToDocument(s, true, errors);
if (!errors.isEmpty() || doc == null)
return false;

// Look for a html>body>table element
return findTable(doc) != null;
// Look for a html>body>table element
return findTable(doc) != null;
}
catch (DOMException e)
{
return false;
}
}
};

Expand Down
5 changes: 4 additions & 1 deletion api/src/org/labkey/api/util/JsonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,10 @@ public void testJavascript() throws Exception
{
// just verifying current behavior: JSONObject escapes /, ObjectMapper does not escape /
assertEquals("{\"key<\\/\":\"<\\/script>\"}", new JSONObject(Map.of("key</","</script>")).toString());
assertEquals("{\"key</\":\"</script>\"}", new ObjectMapper().writeValueAsString(Map.of("key</","</script>")));
// This is the default ObjectMapper behavior
//assertEquals("{\"key</\":\"</script>\"}", new ObjectMapper().writeValueAsString(Map.of("key</","</script>")));
// This is the "hacked" ObjectMapper behavior see the fix-up code in CoreModule static
assertEquals("{\"key<\\/\":\"<\\/script>\"}", new ObjectMapper().writeValueAsString(Map.of("key</","</script>")));

// our ObjectMapper should act like JSONObject.toString()
assertEquals("{\"key<\\/\":\"<\\/script>\"}", DEFAULT_MAPPER.writeValueAsString(Map.of("key</","</script>")));
Expand Down
15 changes: 1 addition & 14 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,7 @@ dependencies {
BuildUtils.addExternalDependency(
project,
new ExternalDependency(
"org.graalvm.sdk:graal-sdk:${graalVersion}",
"GraalJS",
"GraalJS",
"https://github.com/graalvm/graaljs",
"Universal Permissive License",
"https://github.com/graalvm/graaljs/blob/master/LICENSE",
"Server-side JavaScript evaluation"
)
)

BuildUtils.addExternalDependency(
project,
new ExternalDependency(
"org.graalvm.js:js:${graalVersion}",
"org.graalvm.polyglot:js-community:${graalVersion}",
"GraalJS",
"GraalJS",
"https://github.com/graalvm/graaljs",
Expand Down
18 changes: 10 additions & 8 deletions core/src/org/labkey/core/wiki/MarkdownServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,18 @@ public class MarkdownServiceImpl implements MarkdownService

private static class PoolFactory implements KeyedPoolableObjectFactory<Map<Options, Boolean>, MarkdownInvocable>
{

public static final String POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY = "polyglot.engine.WarnInterpreterOnly";

static
{
// Issue 47679 - suppress stdout logging from GraalJS about compilation mode, due to significant difficulties
// in getting the VM configured to use compilation mode
if (System.getProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY) == null)
{
System.setProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY, "false");
}
}

@Override
public MarkdownInvocable makeObject(Map<Options, Boolean> options) throws Exception
{
Expand All @@ -61,13 +70,6 @@ public MarkdownInvocable makeObject(Map<Options, Boolean> options) throws Except
if (null == svc)
throw new ConfigurationException("LabKeyScriptEngineManager service not found.");

// Issue 47679 - suppress stdout logging from Graal about compilation mode, due to significant difficulties
// in getting the VM configured to use compilation mode
if (System.getProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY) == null)
{
System.setProperty(POLYGLOT_ENGINE_WARN_INTERPRETER_ONLY, "false");
}

ScriptEngine engine = svc.getEngineByName("graal.js");
if (null == engine)
throw new ConfigurationException("Graal.js engine not found");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8564,7 +8564,7 @@ private void removeDataTypeExclusion(Collection<Integer> rowIds, DataTypeForExcl
new SqlExecutor(getExpSchema()).execute(sql);
}

@NotNull private Map<String, Object>[] _getContainerDataTypeExclusions(@Nullable DataTypeForExclusion dataType, @Nullable String excludedContainerIdOrPath, @Nullable Integer dataTypeRowId)
@NotNull private List<Map<String, Object>> _getContainerDataTypeExclusions(@Nullable DataTypeForExclusion dataType, @Nullable String excludedContainerIdOrPath, @Nullable Integer dataTypeRowId)
{
SQLFragment sql = new SQLFragment("SELECT DataTypeRowId, DataType, ExcludedContainer FROM ")
.append(getTinfoDataTypeExclusion())
Expand All @@ -8583,8 +8583,13 @@ private void removeDataTypeExclusion(Collection<Integer> rowIds, DataTypeForExcl
if (!GUID.isGUID(excludedContainerIdOrPath))
{
Container container = ContainerManager.getForPath(excludedContainerIdOrPath);
if (container != null)
excludedContainerId = container.getId();
if (container == null)
{
// container not found, it may have been deleted, return empty array instead of making the DB query
return Collections.emptyList();
}

excludedContainerId = container.getId();
}

sql.append(and);
Expand All @@ -8600,13 +8605,13 @@ private void removeDataTypeExclusion(Collection<Integer> rowIds, DataTypeForExcl
sql.add(dataTypeRowId);
}

return new SqlSelector(getTinfoDataTypeExclusion().getSchema(), sql).getMapArray();
return Arrays.stream(new SqlSelector(getTinfoDataTypeExclusion().getSchema(), sql).getMapArray()).toList();
}

@Override
public @NotNull Map<DataTypeForExclusion, Set<Integer>> getContainerDataTypeExclusions(@NotNull String excludedContainerId)
{
Map<String, Object>[] exclusions = _getContainerDataTypeExclusions(null, excludedContainerId, null);
List<Map<String, Object>> exclusions = _getContainerDataTypeExclusions(null, excludedContainerId, null);

Map<DataTypeForExclusion, Set<Integer>> typeExclusions = new HashMap<>();
for (Map<String, Object> exclusion : exclusions)
Expand All @@ -8624,7 +8629,7 @@ private void removeDataTypeExclusion(Collection<Integer> rowIds, DataTypeForExcl
@Override
public Set<String> getDataTypeContainerExclusions(@NotNull DataTypeForExclusion dataType, @NotNull Integer dataTypeRowId)
{
Map<String, Object>[] exclusions = _getContainerDataTypeExclusions(dataType, null, dataTypeRowId);
List<Map<String, Object>> exclusions = _getContainerDataTypeExclusions(dataType, null, dataTypeRowId);
Set<String> excludedProjects = new HashSet<>();
for (Map<String, Object> exclusion : exclusions)
excludedProjects.add((String) exclusion.get("ExcludedContainer"));
Expand All @@ -8635,7 +8640,7 @@ public Set<String> getDataTypeContainerExclusions(@NotNull DataTypeForExclusion
private Set<Integer> _getContainerDataTypeExclusions(DataTypeForExclusion dataType, String excludedContainerId)
{
Set<Integer> excludedRowIds = new HashSet<>();
Map<String, Object>[] exclusions = _getContainerDataTypeExclusions(dataType, excludedContainerId, null);
List<Map<String, Object>> exclusions = _getContainerDataTypeExclusions(dataType, excludedContainerId, null);
for (Map<String, Object> exclusion : exclusions)
excludedRowIds.add((Integer) exclusion.get("DataTypeRowId"));

Expand Down

0 comments on commit 79f5f5b

Please sign in to comment.