> Hi,
> 
> I'm running into a problem with lockdiscovery - specifically, the
> 'owner' element returned is.. strange. The relevent code is this:
> 
> generatedXML.writeElement(null, "owner", XMLPrinter.OPENING);
>         generatedXML.writeElement(null, "href", XMLPrinter.OPENING);
>         generatedXML.writeText
>             (URLEncode(req.getServletPath() + token.getSubjectUri()));
>         generatedXML.writeElement(null, "href", XMLPrinter.CLOSING);
>         generatedXML.writeElement(null, "owner", XMLPrinter.CLOSING);
> 
> There's actually two problems here. One is that the req.getServletPath()
> is being URL-encoded, when it shouldn't be (otherwise it gets encoded
> twice, I think - the end result is wrong, anyway). That's easily fixed.
> However, it raises the following question (my second problem): _why_ is
> the servlet path being prepended to the subject URI in the first place?
> 
> The correct solution would seem (to me) to be to just have this:
> 
> generatedXML.writeElement(null, "owner", XMLPrinter.OPENING);
>         generatedXML.writeText(token.getSubjectURI());
>         generatedXML.writeElement(null, "owner", XMLPrinter.CLOSING);
> 
> I'd change this myself, but I presume there's some reason for things
> being like this to begin with. Remy - why is it doing this?
> 
> A note: the webdav RFC gives the <owner> element as having 'ANY'
> content. There are examples which have an <href> within it, but there's
> nothing to imply that that's needed. There doesn't seem to be a good
> reason to have it in this specific case. 

+1 (unless the spec states that a uri should be put here).
Note that the uri should be either encoded or put in a CDATA section.
So I would do :
 generatedXML.writeElement(null, "owner", XMLPrinter.OPENING);
 generatedXML.writeData(token.getSubjectURI());
 generatedXML.writeElement(null, "owner", XMLPrinter.CLOSING);

Go ahead and commit that fix :)

Remy

Reply via email to