From: Günter M. <mi...@us...> - 2023-06-29 13:57:23
|
- **status**: open --> open-fixed - **assigned_to**: Dave Kuhlman --> nobody - **Comment**: The provided example still fails with Docutils 0.20. Fixed in [r9422]. Thank you for reporting. --- **[bugs:#153] Image directive URI handled incorrectly in ODT output** **Status:** open-fixed **Labels:** ODT Writer **Created:** Fri Dec 03, 2010 10:09 PM UTC by GCompton **Last Updated:** Fri Dec 03, 2010 10:09 PM UTC **Owner:** nobody The ODT writer has two problems with the way it handles the URIs provided in image \(and figure\) directives. First, it does not unescape them before passing them to the local file system. Second, it dereferences relative to the current working directory, not relative to the directory reST file. The first case causes problems with images whose file names contain characters that can't be used in URIs without escaping. I ran into it because my files have spaces in their names. In order to get the HTML writer to work, I had to refer to the files using "%20" in place of each space. Not ideal, but acceptable. However, the ODT writer takes the image node's uri member and passes it directly to os.path.exists \(In writers/odt\_odt/\_\_init\_\_.py in the function check\_file\_exists\) as though it were a file system path rather than a URI. Of course, on the file system, the file name has spaces, not %20s, so it couldn't find it. This part of the problem could probably be solved by passing the uri through the standard urllib.url2pathname function before calling any file system functions. The second problem showed up when I tried to perform the generation with a current directory other than the one containing the reST file. In general, relative URIs are resolved against the directory containing the referring document \(I couldn't find anything in the reST documentation declaring an exception, so I expect the common behavior\). But, again, because the ODT writer doesn't modify the URI at all before using it as a path, Python's file system functions assume it is relative to the working directory. The solution here is probably to prepend the path from the working directory to the reST file's directory. These problems may be more general than what I've seen so far. The other writers may be affected. Also, the other directives cause external files to be read may have similar problems. I'm using docutils 0.7 with Python 2.7 32-bit running on Windows 7 Professional 64-bit. --- Sent from sourceforge.net because doc...@li... is subscribed to https://sourceforge.net/p/docutils/bugs/ To unsubscribe from further messages, a project admin can change settings at https://sourceforge.net/p/docutils/admin/bugs/options. Or, if this is a mailing list, you can unsubscribe from the mailing list. |