Can a uri-encoded character in a href be escaped?

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
vicmortelmans
Posts: 1
Joined: Tue Mar 07, 2023 4:51 pm

Can a uri-encoded character in a href be escaped?

Post by vicmortelmans »

Hi,
I have a mapref with a filename containing "%2A" (which is the URI-encoded form of "*").

Code: Select all

   <mapref format="ditamap"
            href="../published/en-us/axk1438118744716.ditamap_20180406+1005+%2A/axk1438118744716_202301300844_008.ditamap"
            class="+ map/topicref mapgroup-d/mapref "/>
When opening the map containing this mapref in Oxygen, an error is given:

Code: Select all

File not found: "D:\mcmsm\published\en-us\axk1438118744716.ditamap_20180406+1005+*\axk1438118744716_202301300844_008.ditamap".
Oxygen is decoding the filename before going to the filesystem, which I don't want in this case, because on the filesystem it is in the encoded form.

Note that I also have XSLT scripts using this file, run in Saxon, and they show similar behaviour, so it seems to be default behaviour for interpreting XML to decode URI-encoded characters.

There is a workaround that seems to work in Oxygen, to double encode the character: so "%2A" becomes "%252A".

I suppose that this is the way it should be done. Just posting this (1) for anyone who has the same issue and (2) for confirmation that there's indeed no better solution, that would allow me to have the "real" filename in the href attribute in the XML file.

Best regards,
Vic
chrispitude
Posts: 907
Joined: Thu May 02, 2019 2:32 pm

Re: Can a uri-encoded character in a href be escaped?

Post by chrispitude »

Hi Vic,

I think the workaround you described is actually the correct encoding. "%" must itself be written in escaped form, due to its use in escaped reserved characters. See:

URL encoding - Wikipedia
Radu
Posts: 9059
Joined: Fri Jul 09, 2004 5:18 pm

Re: Can a uri-encoded character in a href be escaped?

Post by Radu »

Hi Vic,
I confirm that if you have a file on disk named something like this "cop%2Ayright.dita" and you add a reference to it in the Oxygen DITA Maps Manager view using Oxygen's "Append Child->Reference" action (and not manually add a reference to it as you might have done), then the reference in the DITA Map looks like this:

Code: Select all

<topicref href="cop%252Ayright.dita"/>
So DITA references are URL-like and Oxygen escapes the original "%" to it's URL equivalent "%25".
If the original map you are editing in Oxygen comes as an export from a CMS, then the export has a bug in it if it does not escape the "%" to "%25" in the topicref name.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Post Reply