cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Ernest <thomas.ern...@gmail.com>
Subject Re: <map:reader> can't find files with spaces in their names
Date Sun, 15 Aug 2010 10:33:52 GMT
 Hello Stephen,
> I'm using cocoon 2.2.
>
> Background:
> I'm trying to build a cocoon presentation layer on top of an
> subversion repository. A user makes a request and the cocoon
> application checks to see if a directory index needs to be added, adds
> menus and navigation trails, handles mobile formatting etc but does a
> ci:includexml to get the content of the page from the subversion
> repository.
>
It seems very interesting :-)
> Problem:
> Some of the files in the subversion repository have spaces in the file
> names (and it's not feasible to have a repository without any URL
> encoding required characters) which are decoded (by the matcher?) and
> then passed off to the reader which makes a request of the source
> resolver without re-encoding the spaces (I think).
>
> I assume this is what is happening because I get a FileNotFound error
> when using <ci:includexml> with the src set stuff from the request
> generator but it works when I use xslt to replace the spaces with
> %20s.  I can fix the problem when constructing pages using xslt but
> not for images and other stuff that needs to be <map:read>.
>
> Am I going to have to write my own reader that does URL encoding?
>From my point of view, you don't have to write a reader to handle you
data/link. Because the (right) way to communicate with a server it with
URL, which involves URL encoding. It seems that you want to communicate
with your server, as with a standard file system. Since it isn't a file
system, you have to adapt you to web and web server requirements, i.e.
URL encoding.

I guess you use svn list to know what contains your svn repository.
(Please give us more details about this part) It must be interpreted via
a BASH at some point. So you should also use this BASH to translate your
listing into a "URL encoded" listing. I saw that sed with a file
urlencode.sed [1] can be very useful to reach this goal : svn list | sed
-f urlencode.sed

Finally, you should find a way before using <ci:includexml>, so that you
provide your server with data respecting web requirements/rules. There
are several ways :
1/ Encode URL via your BASH and the command sed.
2/ Use a XSLT style sheet to transform every occurrence of char
forbidden in URL string.
3/ Use EncodeURLTransformer. I'm not sure it releases what you want, but
its name seems to be interesting ;-) [2]
4/ Use POST data, because they likely don't require URL encoding.
5/ ... ?

There are many ways to fix your problem and I haven't provide you with a
exact fix, sorry. Whatever I wrote, I hope you understand that you have
to provide your server with URL encoded URLs. I mean the solution isn't
in developing a reader, but more in using or developing a transformer to
encode you URL or even in providing your system with URL encoded data
since the beginning.

Good luck.

Thomas.

[1] urlencode.sed
s/%/%25/g
s/ /%20/g
s/ /%09/g
s/!/%21/g
s/"/%22/g
s/#/%23/g
s/\$/%24/g
s/\&/%26/g
s/'\''/%27/g
s/(/%28/g
s/)/%29/g
s/\*/%2a/g
s/+/%2b/g
s/,/%2c/g
s/-/%2d/g
s/\./%2e/g
s/\//%2f/g
s/:/%3a/g
s/;/%3b/g
s//%3e/g
s/?/%3f/g
s/@/%40/g
s/\[/%5b/g
s/\\/%5c/g
s/\]/%5d/g
s/\^/%5e/g
s/_/%5f/g
s/`/%60/g
s/{/%7b/g
s/|/%7c/g
s/}/%7d/g
s/~/%7e/g
s/      /%09/g

[2] http://cocoon.apache.org/2.1/userdocs/encodeurl-transformer.html

Mime
View raw message