Skip to content

Commit 39250bf

Browse files
committed
VALUES injection fix
Fixed CLI script name ambiguity
1 parent fbdca50 commit 39250bf

4 files changed

Lines changed: 37 additions & 7 deletions

File tree

bin/imports/import-csv.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ import_doc=$(create-item.sh \
164164
)
165165

166166
# Add the CONSTRUCT query to the item using fragment identifier
167-
add-construct.sh \
167+
# TO-DO: fix ambigous add-construct.sh script names
168+
"$(dirname "$0")/../add-construct.sh" \
168169
-b "$base" \
169170
-f "$cert_pem_file" \
170171
-p "$cert_password" \

bin/imports/import-rdf.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ if [ -n "$query_file" ] ; then
168168
query_id=$(uuidgen | tr '[:upper:]' '[:lower:]')
169169

170170
# Add the CONSTRUCT query to the item using fragment identifier
171-
add-construct.sh \
171+
# TO-DO: fix ambigous add-construct.sh script names
172+
"$(dirname "$0")/../add-construct.sh" \
172173
-b "$base" \
173174
-f "$cert_pem_file" \
174175
-p "$cert_password" \

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/navigation.xsl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,6 @@ ORDER BY DESC(?created)
934934
<!-- TODO: we need to check if instances are in named graphs - for now use SelectInstancesInGraphs -->
935935
<xsl:variable name="query-uri" select="xs:anyURI('&ldh;SelectInstancesInGraphs')" as="xs:anyURI"/>
936936
<xsl:variable name="select-string" select="key('resources', $query-uri, document(ac:document-uri('&ldh;')))/sp:text" as="xs:string"/>
937-
<!-- Add VALUES clause to bind $type to the class URI -->
938-
<xsl:variable name="select-string" select="$select-string || ' VALUES $type { &lt;' || $class-uri || '&gt; }'" as="xs:string"/>
939937

940938
<xsl:variable name="select-json" as="item()">
941939
<xsl:variable name="select-builder" select="ixsl:call(ixsl:get(ixsl:get(ixsl:window(), 'SPARQLBuilder'), 'SelectBuilder'), 'fromString', [ $select-string ])"/>
@@ -944,8 +942,8 @@ ORDER BY DESC(?created)
944942
<xsl:variable name="select-json-string" select="ixsl:call(ixsl:get(ixsl:window(), 'JSON'), 'stringify', [ $select-json ])" as="xs:string"/>
945943
<xsl:variable name="select-xml" as="document-node()">
946944
<xsl:document>
947-
<xsl:apply-templates select="json-to-xml($select-json-string)" mode="ldh:replace-variables">
948-
<xsl:with-param name="var-names" select="('s')" tunnel="yes"/>
945+
<xsl:apply-templates select="json-to-xml($select-json-string)" mode="ldh:append-values">
946+
<xsl:with-param name="values-map" select="map { '$type': $class-uri }" tunnel="yes"/>
949947
</xsl:apply-templates>
950948
</xsl:document>
951949
</xsl:variable>

src/main/webapp/static/com/atomgraph/linkeddatahub/xsl/bootstrap/2.3.2/client/query-transforms.xsl

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -812,5 +812,35 @@ extension-element-prefixes="ixsl"
812812
</json:map>
813813
</xsl:copy>
814814
</xsl:template>
815-
815+
816+
<!-- Append VALUES block to WHERE clause -->
817+
818+
<xsl:template match="@* | node()" mode="ldh:append-values">
819+
<xsl:copy>
820+
<xsl:apply-templates select="@* | node()" mode="#current"/>
821+
</xsl:copy>
822+
</xsl:template>
823+
824+
<xsl:template match="json:array[@key = 'where']" mode="ldh:append-values" priority="1">
825+
<xsl:param name="values-map" as="map(xs:string, xs:anyAtomicType)" tunnel="yes"/>
826+
827+
<xsl:copy>
828+
<xsl:apply-templates select="@* | node()" mode="#current"/>
829+
830+
<!-- Append VALUES block -->
831+
<json:map>
832+
<json:string key="type">values</json:string>
833+
<json:array key="values">
834+
<json:map>
835+
<xsl:for-each select="map:keys($values-map)">
836+
<json:string key="{.}">
837+
<xsl:value-of select="map:get($values-map, .)"/>
838+
</json:string>
839+
</xsl:for-each>
840+
</json:map>
841+
</json:array>
842+
</json:map>
843+
</xsl:copy>
844+
</xsl:template>
845+
816846
</xsl:stylesheet>

0 commit comments

Comments
 (0)