Issue Details (XML | Word | Printable)

Key: XALANJ-2205
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Brian Minchau
Reporter: Brian Minchau
Votes: 1
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
XalanJ2

If a URIResolver is provided, don't call SystemIDResolver.getAbsoluteURI

Created: 26/Sep/05 03:50 PM   Updated: 12/Dec/07 03:37 AM
Return to search
Component/s: None
Affects Version/s: 2.7
Fix Version/s: 2.7.1

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works ProcessorInclude.patch4.txt 2005-09-29 01:21 AM Brian Minchau 8 kB
Issue Links:
Cloners
 

Xalan info: PatchAvailable
Reviewer: Christine Li
Resolution Date: 31/Oct/06 02:44 AM


 Description  « Hide
If the user provides a URIResolver that returns the Source given the absolute URI of the stylesheet module doing the include/import and the relative URI from the href attribute, and if that Source has its system ID set, then there is no reason for the XSLT processor to get involved with the contents of the URIs. The user has provided the full management of stylesheet URIs, to resolve all included/imported Source stylesheet modules and their absolute URIs.

The URIs are supposed to be legitimate URIs, but wheter or not they actually are should be in the user's control. For example the URIs might be of the form "file:///..." with directories or filenames that have characters in them that are not allowed in legitimate URIs.

On the other hand, if the user hasn't provided a URIResolver, or that resolver doesn't return a Source, or that Source doesn't have its system ID set, then the fallback of using SystemIDResolver to get the base URI of the included document is OK. If the URIs are not legitimate, the services provided by this class may throw MalformedURIException.


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Brian Minchau added a comment - 26/Sep/05 04:17 PM
ProcessorInclude.startElement() blindly calls:
 SystemIDResolver.getAbsoluteURI()
to get the base URI of the included document.

ProcessorInclude.processSource() is much more careful. It checks if the user has provided a URIResolver,
if that resolver returns a Source, and if the Source has a system ID. So things are a bit inconsistent.

Also startElement() only wants the base URI so that it can check for circular includes of stylesheet modules, but
the side effect is that it also checks the validity of the URIs. As stated before, if the user provided URIResolver, and
the Source that it returns has a system ID set, then there is no reason to blindly use SystemIDResolver at all.

The patch provided uses the user provided URIResolver more consistently.

Brian Minchau added a comment - 27/Sep/05 05:45 AM
Attaching an updated fix. The code is cleaned up a bit, there are more comments, but most significantly StylesheetHandler has
one more stack.

For a given baseURI and href value, the user's URIResolver.reslove(hrefVal, baseURI) should only be called once.
In the call to ProcessorInclude.starteElement() the resolver would be called to the the Source, and from in the sytem ID, but
only the system ID was used to be pushed onto the stack that helps check for circular includes
(e.g. Sheet A -> includes Sheet B -> includes Sheet A ).

startElement() would call ProcessorInclude.process() which again would call URIResolver.reslove(hrefVal, baseURI) yet again,
to get the Source (and use it this time). It doesn't seem right to me to call URIResolver.resolve twice with the same strings.
We don't know what the user's URIResolver does when called, and calling twice might mess things up.

So the additional stack in StylesheetHandler is a stack of Source objects from the user's URI resolver, and process() just
uses the one on the top of the stack, i.e. the one pushed by startElement() just befor it called process().
Likewise the original stack of system IDs, previously used to check for circular includes, is also used to obtain the system ID
that was previously calculated in startElement().

All in all, with this patch the URIResolver and the Source that it returns now give the user total control on the parsing and meaning of the URIs.

Brian Minchau added a comment - 27/Sep/05 01:47 PM
Assigning to Brian Minchau, setting reviewer to Christine Li (thanks Christine!).

Brian Minchau added a comment - 29/Sep/05 01:21 AM
Attaching patch4 (same as patch3 but with an unused field introduced in patch3 removed).

I will be deleting earlier attached patches.

Christine Li added a comment - 29/Sep/05 03:22 AM
The patch looks fine and should resolve the problem. Reviewed by Christine Li

Brian Minchau added a comment - 04/Apr/06 11:30 PM
Comments from JIRA bug Triage on Febrary 7, 2006:
> Brian needs to apply the patch

Nicholas Sushkin added a comment - 23/May/06 11:44 PM
You also "blindly use SystemIDResolver" in class org.apache.xalan.xsltc.dom.LoadDocument.

Could you also make that class use user's URIResolver, if it is set.

Thanks.


See

http://svn.apache.org/viewvc/xalan/java/trunk/src/org/apache/xalan/xsltc/dom/LoadDocument.java?view=markup

Brian Minchau added a comment - 17/Oct/06 02:35 PM
Per the JIRA meeting on Oct 16, 2005, with the new remark by Nicholas Sushkin the old patch should be applied and a separate mini-patch should be added to this issue, and then reviewed/approved/applied.

Brian Minchau added a comment - 31/Oct/06 02:44 AM
The patch for this fix was applied to the code way back on
September 29, 2005.

Nicholas Sushkin added a comment - 31/Oct/06 04:09 PM
I think there is more work to do than just apply the patch of September 29, 2005. The 2005 patch does not fix org.apache.xalan.xsltc.dom.LoadDocument.java. Please see my comment of 23/May/06.

Nicholas Sushkin added a comment - 31/Oct/06 04:33 PM
In the "document()" function, the same issue is still unresolved. If a URIResolver is provided, don't call SystemIDResolver.getAbsoluteURI. Would you reopen this bug or should I file it as a separate bug?

Thanks

Brian Minchau added a comment - 01/Nov/06 01:33 AM
Nicholas,
please open a separate issue for this. If you have a patch for that fix, or can point to the code that you think needs to be changed that would be great. As you can see right now for the 2.7.1 release coming up we
are focusing on cleaning up issues that have patches attached to them.

With a patch the fix is far more likely to make 2.7.1 (and who knows how long until the next release).

Brian Minchau added a comment - 11/Dec/07 03:16 PM
This issue is no longer relevant for 2.7.1, it is fixed in 2.7.1.
Changing the affected version to 2.7.

Brian Minchau added a comment - 11/Dec/07 04:57 PM
Would the originator of this issue please verify that this issue is fixed in the 2.7.1 release, by adding a comment to this issue, so that we can close this issue.

A lack of response by February 1, 2008 will be taken as consent that we can close this resolved issue.

Regards,
Brian Minchau

Brian Minchau added a comment - 12/Dec/07 03:37 AM
closing this issue.