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

generate.copy.outer=1 not working properly, copies images outside of output dir #2550

Closed
robander opened this issue Dec 16, 2016 · 3 comments
Assignees
Labels
bug plugin/html5 Issue related to HTML5 plug-in priority/high High severity or high priority issue
Milestone

Comments

@robander
Copy link
Member

robander commented Dec 16, 2016

This sample demonstrates a few issues with generate.copy.outer=1 but the most significant is that I've found a way to generate files outside of the designated output directory. I ran into this with a user document in 2.3.1, but have reproduced in 2.4 now.

My map structure looks odd and is presented here as a simple test case - but variants of this exist in our real documentation. I have a map nested down in sub1/sub2/. It references a topic and an HTML file in the same directory; the topic references an image in the same directory. Trouble comes with the uplevels reference to wayup.dita:

test/wayup.dita
test/sub1/sub2/funtimes.ditamap
test/sub1/sub2/maindir.dita
test/sub1/sub2/notreally.html
test/sub1/sub2/end.jpg

I've run two builds to html5; the builds match except for generate.copy.outer, which I've tried as both "1" and "3".

Results in this zip along with source:
outdirs.zip

"3" seems to work. index.html is generated in the output equivalent of the main directory. Image and HTML file are properly copied to the same directory, and the image appears in maindir.html. Links between topics work.

"1" demonstrates several problems. Most significant: the image is copied outside of the output directory. The uplevels variable here (on Windows) is set to ..\..\ because there is a topic 2 levels up from the map. The image's output directory is constructed as:

    <condition property="copy-image.todir" value="${output.dir}/${uplevels}" else="${output.dir}">
      <equals arg1="${generate.copy.outer}" arg2="1"/>      
    </condition>

The image itself is stored in the .job.xml file as sub1/sub2/end.jpg. As a result, the generated image path for this file becomes out + uplevels + path-and-file:
out/../../sub1/sub2/end.jpg

I think what's actually wanted, but I'm not sure how to get it, would be output dir + path to image + uplevels + file name.

Other issues:

  • index.html and CSS are placed directly in the output directory as expected. Index file links to other files as if they are there
  • Generated topic from the main dir is placed within sub1/sub2/ in the output directory
  • HTML is copied to sub1/sub2/ inside the output directory - related to Update copy-html to work like copy-image, with parameter for destination directory #1964, but I think the fix I suggested there would end up causing the issue seen with images (copy outside)
@robander robander added the priority/high High severity or high priority issue label Dec 16, 2016
@robander
Copy link
Member Author

FWIW, I have those files inside the DITA-OT directory under test, and ran the builds from the DITA-OT directory with the following batch file:

call bin\dita -i test\sub1\sub2\funtimes.ditamap -f html5 -v -Dgenerate.copy.outer=1 -o out\out1
call bin\dita -i test\sub1\sub2\funtimes.ditamap -f html5 -v -Dgenerate.copy.outer=3 -o out\out3

@jelovirt jelovirt added bug plugin/html5 Issue related to HTML5 plug-in labels Jan 4, 2017
@robander
Copy link
Member Author

robander commented May 3, 2017

I think I have a simpler than expected fix for this. It fixes the image issue for XHTML and HTML5 with the attached samples. It does not fix the other issues mentioned at the end of my original description.

With the current develop code, I updated the copy-image task as follows; the image is now placed in the proper location relative to the main topic (nothing is placed outside the designated output directory):

<condition property="copy-image.todir" value="${_dita.map.output.dir}/${uplevels}" else="${output.dir}">
      <isset property="inner.transform"/>  
    </condition>
    <copy todir="${copy-image.todir}" failonerror="false">
      <dita-fileset format="image" />
    </copy>

Assuming #2670 is accepted, this will need another update to account for that change, so I haven't yet created a branch / pull request for this one. But, I'd like to get it into 2.5.

@robander robander self-assigned this May 3, 2017
@robander robander added this to the 2.5 milestone May 3, 2017
robander pushed a commit to robander/dita-ot that referenced this issue May 9, 2017
robander pushed a commit that referenced this issue May 10, 2017
Update html/image copy, avoid copy outside outdir #2550 #1964
@robander
Copy link
Member Author

@infotexture draft summary for release notes: "In some cases, referencing topics outside of the map directory resulted in images being copied outside of the specified output directory. Processing has been updated so that images are placed in the correct location inside the specified output directory."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug plugin/html5 Issue related to HTML5 plug-in priority/high High severity or high priority issue
Projects
None yet
Development

No branches or pull requests

2 participants