You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by "Jörg Heinicke (JIRA)" <ji...@apache.org> on 2007/03/12 22:09:09 UTC

[jira] Created: (COCOON-2022) broken URI handling in ZipSource

broken URI handling in ZipSource
--------------------------------

                 Key: COCOON-2022
                 URL: https://issues.apache.org/jira/browse/COCOON-2022
             Project: Cocoon
          Issue Type: Bug
          Components: * Cocoon Core
    Affects Versions: 2.1.10
            Reporter: Jörg Heinicke
         Assigned To: Jörg Heinicke
            Priority: Minor


On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:

1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
        // Get protocol. Protocol is configurable via cocoon.xconf
        final String protocol = location.substring(0, protocolEnd - 1);

Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".

2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.

Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:

	return this.protocol + this.archive.getURI() + "!/" + this.filePath;

is not going to work. Something like this will:

    	int iZipIdx = this.archive.getURI().lastIndexOf("/");
	if (iZipIdx < 0) iZipIdx = 0;
    	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jorg Heymans (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12481964 ] 

Jorg Heymans commented on COCOON-2022:
--------------------------------------

I suggest you bring this up on excalibur-dev. 

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jörg Heinicke (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jörg Heinicke closed COCOON-2022.
---------------------------------

       Resolution: Fixed
    Fix Version/s: 2.2-dev (Current SVN)
                   2.1.11-dev (Current SVN)

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>             Fix For: 2.1.11-dev (Current SVN), 2.2-dev (Current SVN)
>
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Reinhard Poetz (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12481353 ] 

Reinhard Poetz commented on COCOON-2022:
----------------------------------------

The tests work for me. I was running it on WinXp/Java5. Seems to be some OS specific problem.

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jörg Heinicke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12480946 ] 

Jörg Heinicke commented on COCOON-2022:
---------------------------------------

Ok, it behaves differently in Eclipse and on the command line:

CLI:
Running org.apache.cocoon.components.source.impl.ZipSourceTestCase
[DEBUG] SourceResolver: Using base URL: file:/D:/Cocoon/cocoon-2.2/core/cocoon-core/
[DEBUG] Resolving 'zip:file://test.zip!/test.xml' with base 'null' in context 'file:/D:/Cocoon/cocoon-2.2/core/cocoon-core/'
[DEBUG] Resolved to systemID : zip:file://test.zip!/test.xml
[DEBUG] Resolving 'file://test.zip' with base 'null' in context 'file:/D:/Cocoon/cocoon-2.2/core/cocoon-core/'
[DEBUG] Resolved to systemID : file://test.zip
[DEBUG] Creating source object for file://test.zip
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.094 sec <<< FAILURE!

Eclipse:
[DEBUG] SourceResolver: Using base URL: file:/D:/Cocoon/cocoon-2.2/core/cocoon-core/
[DEBUG] Resolving 'zip:file://test.zip!/test.xml' with base 'null' in context 'file:/D:/Cocoon/cocoon-2.2/core/cocoon-core/'
[DEBUG] Resolved to systemID : zip:file://test.zip!/test.xml
[DEBUG] Resolving 'file://test.zip' with base 'null' in context 'file:/D:/Cocoon/cocoon-2.2/core/cocoon-core/'
[DEBUG] Resolved to systemID : file://test.zip
[DEBUG] Creating source object for file://test.zip

Now I wonder how this can happen as the above debug output of source resolver is totally equal (used diff). I will investigate.

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jörg Heinicke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12481337 ] 

Jörg Heinicke commented on COCOON-2022:
---------------------------------------

Is it still an issue or can I close it?

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jörg Heinicke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12480949 ] 

Jörg Heinicke commented on COCOON-2022:
---------------------------------------

Another strange thing: the surefire report for the CLI has the following output (different to Grek's):

junit.framework.ComparisonFailure: Scheme/protocol is wrong. expected:<zi[p]> but was:<zi[]>

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jorg Heymans (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12480952 ] 

Jorg Heymans commented on COCOON-2022:
--------------------------------------

You can look at the maven test report in cocoon-core/target/surefire-reports/TEST-org.apache.cocoon.components.source.impl.ZipSourceTestCase.xml

  <testcase time="0.12" name="testURIHandling">    <failure type="junit.framework.ComparisonFailure" message="Uri is wrong. expected:&amp;lt;zip:file:/[/]test.zip!/test.xml&amp;gt; but was:&amp;lt;zip:file:/[]test.zip!/test.xml&amp;gt;">junit.framework.ComparisonFailure: Uri is wrong. expected:&amp;zip:file:/[/]test.zip!/test.xml&amp; but was:&amp;zip:file:/[]test.zip!/test.xml&amp;        at junit.framework.Assert.assertEquals(Assert.java:81)        at org.apache.cocoon.components.source.impl.ZipSourceTestCase.testURIHandling(ZipSourceTestCase.java:28)</failure>    <system-out>[DEBUG] SourceResolver: Using base URL: file:/Users/jheymans/src/cocoon-trunk/core/cocoon-core/[DEBUG] Resolving &apos;zip:file://test.zip!/test.xml&apos; with base &apos;null&apos; in context &apos;file:/Users/jheymans/src/cocoon-trunk/core/cocoon-core/&apos;[DEBUG] Resolved to systemID : zip:file://test.zip!/test.xml
[DEBUG] Resolving &apos;file://test.zip&apos; with base &apos;null&apos; in context &apos;file:/Users/jheymans/src/cocoon-trunk/core/cocoon-core/&apos;
[DEBUG] Resolved to systemID : file://test.zip
[DEBUG] Creating source object for file://test.zip
</system-out>
  </testcase>


> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jörg Heinicke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12481864 ] 

Jörg Heinicke commented on COCOON-2022:
---------------------------------------

Thanks for investigating, Jorg.

Why not changing o.a.excalibur.source.impl.FileSource to add the additional slash? It that's not an option for any reason I also don't care that much about changing the test case. (Though I prefer fixing an error where it occurs or as early as possible and not forcing everyone using the code to cope with it.)

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Grzegorz Kossakowski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12481843 ] 

Grzegorz Kossakowski commented on COCOON-2022:
----------------------------------------------

Yes, I can confirm that's OS (Unix) specific problem. I've just built Cocoon successfully on WinXP with Java 1.6 installed.
I will provide more details of Unix error on Monday as I do not have access to my computer now.

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Grzegorz Kossakowski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12484455 ] 

Grzegorz Kossakowski commented on COCOON-2022:
----------------------------------------------

I would like to ask if there is any solution for this problem? The test should be fixed ASAP because now we are forced to use maven.test.skip=true which is harmful. Or should we disable this test temporarily?

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jorg Heymans (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12480939 ] 

Jorg Heymans commented on COCOON-2022:
--------------------------------------

Could it be that this fix breaks a testcase ?

On my local CI build i get :

Running org.apache.cocoon.components.source.impl.ZipSourceTestCase
[DEBUG] SourceResolver: Using base URL: file:/home/maven/.hudson/jobs/Cocoon/workspace/trunk/core/cocoon-core/
[DEBUG] Resolving 'zip:file://test.zip!/test.xml' with base 'null' in context 'file:/home/maven/.hudson/jobs/Cocoon/workspace/trunk/core/cocoon-core/'
[DEBUG] Resolved to systemID : zip:file://test.zip!/test.xml
[DEBUG] Resolving 'file://test.zip' with base 'null' in context 'file:/home/maven/.hudson/jobs/Cocoon/workspace/trunk/core/cocoon-core/'
[DEBUG] Resolved to systemID : file://test.zip
[DEBUG] Creating source object for file://test.zip
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.053 sec <<< FAILURE!



> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jörg Heinicke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12480942 ] 

Jörg Heinicke commented on COCOON-2022:
---------------------------------------

Actually I added this test case and used it for proving my fix. So I don't know why it fails for you. Can you say which assertion actually fails?

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jorg Heymans (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12481339 ] 

Jorg Heymans commented on COCOON-2022:
--------------------------------------

We need other people to test it, i'm still getting 

-------------------------------------------------------------------------------
Test set: org.apache.cocoon.components.source.impl.ZipSourceTestCase
-------------------------------------------------------------------------------
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.078 sec <<< FAILURE!
testURIHandling(org.apache.cocoon.components.source.impl.ZipSourceTestCase)  Time elapsed: 0.063 sec  <<< FAILURE!
junit.framework.ComparisonFailure: Uri is wrong. expected:<zip:file:/[/]test.zip!/test.xml> but was:<zip:file:/[]test.zip!/test.xml>
        at junit.framework.Assert.assertEquals(Assert.java:81)
        at org.apache.cocoon.components.source.impl.ZipSourceTestCase.testURIHandling(ZipSourceTestCase.java:28)


jorg:~/src/cocoon-trunk/core/cocoon-core jheymans$ svn st -u
Status against revision: 518773


i ran 'mvn clean install' from trunk root. Note that this is on mac os x

java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-164)
Java HotSpot(TM) Client VM (build 1.5.0_07-87, mixed mode, sharing)



> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jörg Heinicke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12481345 ] 

Jörg Heinicke commented on COCOON-2022:
---------------------------------------

Ok, can you debug it? I especially wonder why it ends in "file:/test.zip" as the debug output added by Jorg clearly says:

[DEBUG] Resolving 'file://test.zip' with base 'null' in context ...
[DEBUG] Resolved to systemID : file://test.zip
[DEBUG] Creating source object for file://test.zip

As the "inner" uri "file://test.zip" is resolved on its own and into a different Source object the actual error is probably not even in ZipSource but somewhere else. The failing check on ZipSource.getURI() only calls getURI() on the inner Source object. This inner Source object is not manipulated in any way. So maybe also the test

    public void testURIHandling() throws Exception {
        String uri = "file://test.zip";
        Source source;
        SourceResolver resolver = null;
        try {
            resolver = (SourceResolver) getManager().lookup(SourceResolver.ROLE);
            source = resolver.resolveURI(uri);
        } catch (ServiceException se) {
            throw new SourceException("SourceResolver is not available.", se);
        } finally {
            getManager().release(resolver);
        }
        assertEquals("Uri is wrong.", uri, source.getURI());
    }

would fail for you?

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Reopened: (COCOON-2022) broken URI handling in ZipSource

Posted by "Grzegorz Kossakowski (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Grzegorz Kossakowski reopened COCOON-2022:
------------------------------------------


Unfortunately the issues is still not resolved, but this time I guess that is only string offset calculation mistake. I'm not 100% sure so I bring it here. My report:

-------------------------------------------------------------------------------
Test set: org.apache.cocoon.components.source.impl.ZipSourceTestCase
-------------------------------------------------------------------------------
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec <<< FAILURE!
testURIHandling(org.apache.cocoon.components.source.impl.ZipSourceTestCase)  Time elapsed: 0.014 sec  <<< FAILURE!
junit.framework.ComparisonFailure: Uri is wrong. expected:<zip:f[le:/]/test.zip!/test.xml> but was:<zip:f[ile:]/test.zip!/test.xml>
	at junit.framework.Assert.assertEquals(Assert.java:81)
	at org.apache.cocoon.components.source.impl.ZipSourceTestCase.testURIHandling(ZipSourceTestCase.java:37)

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>             Fix For: 2.1.11-dev (Current SVN), 2.2-dev (Current SVN)
>
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jörg Heinicke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12484581 ] 

Jörg Heinicke commented on COCOON-2022:
---------------------------------------

Of course, just change the test as suggested by Jorg. I'd add a FIXME or TODO to it.

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Grzegorz Kossakowski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12481342 ] 

Grzegorz Kossakowski commented on COCOON-2022:
----------------------------------------------

It also still fails for me (after svn up and mvn clean install).
I have the same error message as Jorg.
My configuration:
openSUSE 10.2
java version "1.6.0"
Java(TM) SE Runtime Environment (build 1.6.0-b105)
Java HotSpot(TM) Client VM (build 1.6.0-b105, mixed mode)

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Grzegorz Kossakowski (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12480941 ] 

Grzegorz Kossakowski commented on COCOON-2022:
----------------------------------------------

Same here, more details:
junit.framework.ComparisonFailure: Uri is wrong. expected:<zip:file:/[/]test.zip!/test.xml> but was:<zip:file:/[]test.zip!/test.xml>

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Closed: (COCOON-2022) broken URI handling in ZipSource

Posted by Grzegorz Kossakowski <gk...@apache.org>.
Jörg Heinicke (JIRA) napisał(a):
>      [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
>
> Jörg Heinicke closed COCOON-2022.
> ---------------------------------
>
>     Resolution: Fixed
>
> next try ...
>   

It works for me. Thanks Jörg for your effort!

-- 
Grzegorz Kossakowski
http://reflectingonthevicissitudes.wordpress.com/


[jira] Closed: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jörg Heinicke (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jörg Heinicke closed COCOON-2022.
---------------------------------

    Resolution: Fixed

next try ...

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>             Fix For: 2.1.11-dev (Current SVN), 2.2-dev (Current SVN)
>
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jörg Heinicke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12480965 ] 

Jörg Heinicke commented on COCOON-2022:
---------------------------------------

So, I did a complete update on trunk, made "mvn clean install" as at least my failure looked like the old code being executed.
And the surefire report now looks like:

-------------------------------------------------------------------------------
Test set: org.apache.cocoon.components.source.impl.ZipSourceTestCase
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.11 sec

> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (COCOON-2022) broken URI handling in ZipSource

Posted by "Jorg Heymans (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/COCOON-2022?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12481847 ] 

Jorg Heymans commented on COCOON-2022:
--------------------------------------

digging a bit deeper into this...

The file:/test.zip url is constructed in o.a.excalibur.source.impl.FileSource, line 100 : file.toURL().toExternalForm();

I suspect that if you put a breakpoint there you will get the correct URL file://test.zip.

According to google this is sort of accepted 'broken' behaviour on jdk 1.3, on 1.4 and upwards one should use something like file.toURI().toASCIIString()

See e.g. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4924415
--------------
 xxxxx@xxxxx , 2003-10-01 07:01:33 : 
OK, I'll try to go through the listed conversions as best I know:

new URI(String) - fine
URI.toASCIIString() - OK, but toExternalForm = toString is fine
File.toURI() - fine
new File(URI) - fine
URLMapper.findFileObjects(URL) - fine
FileObject.getURL() - works, but URLMapper.findURL(FileObject,int) is
probably more useful
URI.toURL() - fine
new URI(URL.toExternalForm()) - fine

You forgot:

File.toURI().toURL()
new File(new URI(URL.toExternalForm())

What is *not* safe:

File.toURL() - does not work correctly
new File(URL.getPath().replace('/', File.separatorChar)) - does not work
---------------------------


See also:  http://weblogs.java.net/blog/kohsuke/archive/2005/10/xml_processing.html 
---------------------------
it's worse than you thought. file.toURL().toExternalForm() doesn't always work. The URL object that toURL() returns does not correctly implement the URL specification for many characters likely to occur in file names, including the simple space (0x20). This can trip up relative URL resolution too.
In Java 1.4 and later you should use file.toURI().toASCIIString() instead. In Java 1.3 and earlier, you'll need to build the URL from the file name yourself because Java's implementation is just too broken.
---------------------------

To summarize : i think the behaviour is buggy but seemingly accepted to be broken and thus in a wierd kind of way you could say it is 'correct' within the scope of this test. 

How about we do:

String brokenURI = "file:/test.zip";
.... 
if (! (uri.equals(source.getURI() || brokenUri.equals(source.getURI()) ){
  fail("expected either " + uri + " or " + brokenURI + " but resolved URI was " + source.getURI());
}


> broken URI handling in ZipSource
> --------------------------------
>
>                 Key: COCOON-2022
>                 URL: https://issues.apache.org/jira/browse/COCOON-2022
>             Project: Cocoon
>          Issue Type: Bug
>          Components: * Cocoon Core
>    Affects Versions: 2.1.10
>            Reporter: Jörg Heinicke
>         Assigned To: Jörg Heinicke
>            Priority: Minor
>
> On behalf of Leonid Geller: http://marc.theaimsgroup.com/?t=117337275500004&r=1&w=4:
> 1. Bug in org.apache.cocoon.components.source.impl.ZipSourceFactory, on this line:
>         // Get protocol. Protocol is configurable via cocoon.xconf
>         final String protocol = location.substring(0, protocolEnd - 1);
> Obviously it should be location.substring(0, protocolEnd). This is what causes zip to be truncated to "zi".
> 2. When using a SYSTEM identifier with relative DTD path, the XML parser will look for the file relative to the URI of the zipped source, zip:archive.zip!/source.xml which is obviously going to fail.
> Here, the solution is to have the source implementation class (in this case org.apache.cocoon.components.source.impl.ZipSource) to change getURI method to return source.xml based on archive.zip location, w/o the zip protocol. Current implementation:
> 	return this.protocol + this.archive.getURI() + "!/" + this.filePath;
> is not going to work. Something like this will:
>     	int iZipIdx = this.archive.getURI().lastIndexOf("/");
> 	if (iZipIdx < 0) iZipIdx = 0;
>     	return this.archive.getURI().substring(0,iZipIdx)+"/"+ this.filePath;

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.