Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for spaces in file/dir name #3213 #3229

Merged
merged 1 commit into from Feb 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/main/plugins/org.dita.html5/xsl/functions.xsl
Expand Up @@ -172,5 +172,10 @@ See the accompanying LICENSE file for applicable license.
$table/@keycol and xs:integer($table/@keycol) eq count($entry/preceding-sibling::*) + 1
"/>
</xsl:function>

<xsl:function name="dita-ot:normalize-href" as="xs:string?">
<xsl:param name="href" as="xs:string"/>
<xsl:value-of select="replace(translate($href, '\', '/'), ' ', '%20')"/>
</xsl:function>

</xsl:stylesheet>
2 changes: 1 addition & 1 deletion src/main/plugins/org.dita.html5/xsl/nav.xsl
Expand Up @@ -54,7 +54,7 @@ See the accompanying LICENSE file for applicable license.
</xsl:if>
</xsl:template>

<xsl:variable name="current-file" select="translate(if ($FILEDIR = '.') then $FILENAME else concat($FILEDIR, '/', $FILENAME), '\', '/')" as="xs:string?"/>
<xsl:variable name="current-file" select="dita-ot:normalize-href(if ($FILEDIR = '.') then $FILENAME else concat($FILEDIR, '/', $FILENAME))" as="xs:string?"/>
<xsl:variable name="current-topicrefs" select="$input.map//*[contains(@class, ' map/topicref ')][dita-ot:get-path($PATH2PROJ, .) = $current-file]" as="element()*"/>
<xsl:variable name="current-topicref" select="$current-topicrefs[1]" as="element()?"/>

Expand Down
15 changes: 15 additions & 0 deletions src/test/xsl/plugins/org.dita.html5/xsl/functions.xspec
Expand Up @@ -385,5 +385,20 @@
<x:expect label="return false()" select="false()"/>
</x:scenario>
</x:scenario>

<x:scenario label="Normalize path with space and backslash">
<x:call function="dita-ot:normalize-href">
<x:param name="href" select="'foo bar\this that.dita'"/>
</x:call>

<x:expect label="path normalized with / and %20" select="'foo%20bar/this%20that.dita'"/>
</x:scenario>
<x:scenario label="Normalize path that doesn't need normalization">
<x:call function="dita-ot:normalize-href">
<x:param name="href" select="'foo%20bar/this%20that.dita'"/>
</x:call>

<x:expect label="path not modified" select="'foo%20bar/this%20that.dita'"/>
</x:scenario>

</x:description>