Return-Path: X-Original-To: apmail-myfaces-dev-archive@www.apache.org Delivered-To: apmail-myfaces-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8F8B2186AF for ; Fri, 21 Aug 2015 09:28:47 +0000 (UTC) Received: (qmail 53542 invoked by uid 500); 21 Aug 2015 09:28:46 -0000 Delivered-To: apmail-myfaces-dev-archive@myfaces.apache.org Received: (qmail 53400 invoked by uid 500); 21 Aug 2015 09:28:46 -0000 Mailing-List: contact dev-help@myfaces.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "MyFaces Development" Delivered-To: mailing list dev@myfaces.apache.org Received: (qmail 52907 invoked by uid 99); 21 Aug 2015 09:28:46 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Aug 2015 09:28:46 +0000 Date: Fri, 21 Aug 2015 09:28:46 +0000 (UTC) From: "Thomas Timbul (JIRA)" To: dev@myfaces.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (MYFACES-4002) Regression? - References to external entities not working with WebXmlParser MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MYFACES-4002?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14706458#comment-14706458 ] Thomas Timbul edited comment on MYFACES-4002 at 8/21/15 9:28 AM: ----------------------------------------------------------------- This is what it boils down to (formatting may be slightly off): {code:xml} ]> [...] &contextparams; [...] &filtermappings; [...] &filters; [...] &listeners; [...] [etc] {code} This used to work fine on 2.0.7. After upgrading to "stock" 2.2.4 it failed with the above error, but fine again after I patched as above. I initially discarded the use of web fragment only because this is now somewhat of a legacy project, and it used to work perfectly fine previously. I'm sure it could be restructured using web-fragments, but unfortunately it is not something I am able to spend time on right now. Please note that I have not considered possible side effects, such as a user (for some strange reason) wanting to specify an absolute system path. I also haven't compared the 2.0.7 WebXmlParser sources to check whether changes were actually made. Perhaps the change is actually in core classes that produce the "systemId"? was (Author: ttimbul): This is what it boils down to (formatting may be slightly off): {code:xml} ]> [...] &contextparams; [...] &filtermappings; [...] &filters; [...] &listeners; [...] [etc] {code} This used to work fine on 2.0.7. After upgrading to "stock" 2.2.4 it failed with the above error, but fine again after I patched as above. I initially discarded the use of web fragment only because this is now somewhat of a legacy project, and it used to work perfectly fine previously. I'm sure it could be restructured using web-fragments, but unfortunately it is not something I am able to spend time on right now. Please note that I have not considered possible side effects, such as a user (for some strange reason) wanting to specify an absolute system path. I also haven't compared the 2.0.7 WebXmlParser sources to check whether changes were actually made. Perhaps the change is actually in core classes that produce the "systemId"? > Regression? - References to external entities not working with WebXmlParser > --------------------------------------------------------------------------- > > Key: MYFACES-4002 > URL: https://issues.apache.org/jira/browse/MYFACES-4002 > Project: MyFaces Core > Issue Type: Bug > Affects Versions: 2.2.4 > Environment: Myfaces 2.2.4, Tomcat 8.0.23, JDK 1.8_20, Windows 7 64bit > Reporter: Thomas Timbul > Attachments: patch1.txt > > > I've searched JIRA and there are a few issues related to WebXmlParser, but this seems almost like a recurrence of MYFACES-1754. > My web.xml is split into multiple files, each declared as an XML entity relative to the web.xml file itself: > {code:xml} > > {code} > (As a side note I used to use {{jndi:/localhost/WEB-INF/webxml/context-params.xml}}, but for some reason Tomcat 8 claims that jndi is an invalid protocol). > Using resource relative system identifiers Tomcat is now happy and the context starts correctly. However, during its initialization MyFaces re-parses the web.xml descriptor and resolves the entities incorrectly, leading to failure with the message: > {code} > 2015-06-17 15:48:13.853 [localhost-startStop-1] ERROR o.a.m.s.w.webxml.WebXmlParser - Unable to parse web.xml > java.lang.IllegalArgumentException: The resource path [file:///WEB-INF/webxml/context-params.xml] is not valid > {code} > The solution is to remove the file:// prefix before passing to the external context to resolve, as in this patch: > {code} > Index: org/apache/myfaces/shared_impl/webapp/webxml/WebXmlParser.java > =================================================================== > --- WebXmlParser.java (revision ???) > +++ WebXmlParser.java (working copy) > @@ -138,6 +138,9 @@ > > private InputSource createContextInputSource(String publicId, String systemId) > { > + if(systemId.startsWith("file:")) { > + systemId = systemId.substring(7); // remove file:// > + } > InputStream inStream = _context.getResourceAsStream(systemId); > if (inStream == null) > { > {code} > Those three lines of code are based on other work by the MyFaces team (org.apache.myfaces.config.impl.FacesConfigEntityResolver) and even if it weren't is made available free of charge and free from license restrictions. -- This message was sent by Atlassian JIRA (v6.3.4#6332)