Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: fec1f7a71235
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 62ac0030aaec
Choose a head ref
  • 6 commits
  • 7 files changed
  • 1 contributor

Commits on Feb 10, 2015

  1. fixes directory glob inside jarfile with + in filename

    when you have embedded gems inside a jarfile and the filename was something
    like myjar-20150210+behappy.jar then the rubygems could not find those gems.
    
    Sponsored by Lookout Inc.
    mkristian committed Feb 10, 2015
    2
    Copy the full SHA
    d220103 View commit details
  2. improve the case when the path for a jar-file needs to be URL-decoded

    it removes the case my.jar!/f%20o.rb which matches the behaviour of
    file:f%20o.rb
    
    Sponsored by Lookout Inc.
    mkristian committed Feb 10, 2015
    Copy the full SHA
    f3d806d View commit details

Commits on Feb 11, 2015

  1. Copy the full SHA
    ee68c63 View commit details

Commits on Feb 12, 2015

  1. Copy the full SHA
    b14661c View commit details
  2. Copy the full SHA
    2f08882 View commit details
  3. Merge branch 'jruby-1_7'

    Conflicts:
    	test/test_load.rb
    mkristian committed Feb 12, 2015
    Copy the full SHA
    62ac003 View commit details
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -67,7 +67,6 @@ matrix:
fast_finish: true
allow_failures:
- env: PHASE='-Pcomplete'
- env: PHASE='-Pmain'
- env: PHASE='-Prake -Dtask=spec:jrubyc'
- env: PHASE='-Prake -Dtask=spec:profiler'
- env: COMMAND=tool/truffle-findbugs.sh
29 changes: 16 additions & 13 deletions core/src/main/java/org/jruby/util/JarResource.java
Original file line number Diff line number Diff line change
@@ -19,18 +19,6 @@ public static JarResource create(String pathname) {
Matcher matcher = PREFIX_MATCH.matcher(pathname);
String sanitized = matcher.matches() ? matcher.group(1) : pathname;

try {
// since pathname is actually an uri we need to decode any url decoded characters like %20
// which happens when directory names contain spaces
sanitized = URLDecoder.decode(sanitized, "UTF-8");
} catch (IllegalArgumentException iae) {
// something in the path did not decode, so it's probably not a URI
// See jruby/jruby#2264.
return null;
} catch (UnsupportedEncodingException e) {
throw new RuntimeException( "hmm - system does not know UTF-8 string encoding :(" );
}

int bang = sanitized.indexOf('!');
String jarPath = sanitized.substring(0, bang);
String entryPath = sanitized.substring(bang + 1);
@@ -52,7 +40,22 @@ private static JarResource createJarResource(String jarPath, String entryPath, b

if (index == null) {
// Jar doesn't exist
return null;
try {
jarPath = URLDecoder.decode(jarPath, "UTF-8");
entryPath = URLDecoder.decode(entryPath, "UTF-8");
} catch (IllegalArgumentException iae) {
// something in the path did not decode, so it's probably not a URI
// See jruby/jruby#2264.
return null;
} catch (UnsupportedEncodingException e) {
throw new RuntimeException( "hmm - system does not know UTF-8 string encoding :(" );
}
index = jarCache.getIndex(jarPath);

if (index == null) {
// Jar doesn't exist
return null;
}
}

// Try it as directory first, because jars tend to have foo/ entries
4 changes: 0 additions & 4 deletions core/src/test/java/org/jruby/util/JarResourceTest.java
Original file line number Diff line number Diff line change
@@ -10,8 +10,6 @@ public void testCreateJarResource(){
assertNotNull( resource );
resource = JarResource.create( jar + "!/f o.rb" );
assertNotNull( resource );
resource = JarResource.create( jar + "!/f%20o.rb" );
assertNotNull( resource );
resource = JarResource.create( jar + "!/doesnotexist.rb" );
assertNull( resource );
resource = JarResource.create( jar.replace( ".jar", ".zip" ) + "!/foo.rb" );
@@ -24,8 +22,6 @@ public void testCreateJarResourceWithSpaceCharInPath(){
assertNotNull( resource );
resource = JarResource.create( jar + "!/f o.rb" );
assertNotNull( resource );
resource = JarResource.create( jar + "!/f%20o.rb" );
assertNotNull( resource );
resource = JarResource.create( jar + "!/doesnotexist.rb" );
assertNull( resource );
resource = JarResource.create( jar.replace( ".jar", ".zip" ) + "!/foo.rb" );
34 changes: 5 additions & 29 deletions maven/jruby/src/it/runnable/Mavenfile
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@ properties( 'tesla.dump.pom' => 'pom.xml',
'tesla.dump.readOnly' => true,
'jruby.version' => '@project.version@',
'jruby.plugins.version' => '1.0.8' )

gemfile

gem 'bundler', '1.7.7'
@@ -12,47 +13,22 @@ pom 'org.jruby:jruby', '${jruby.version}'

jar 'de.saumya.mojo:jruby-mains', '0.1.0'

files = [ 'config.ru', '*file', '*file.lock', '.jbundler/classpath.rb',
'lib/**', 'app/**', 'config/**', 'vendor/**', 'spec/**' ]

# resource :directory => '${basedir}' do
# includes( files )
# end

# execute 'create jrubydir info', :phase => 'process-resources' do |ctx|
# target = ctx.project.build.output_directory.to_pathname
# entries = files.collect { |f| Dir[ f.sub( /\/.*$/, '') ] }.flatten.uniq
# File.write( File.join( target, '.jrubydir' ),
# (['.'] + entries + [ '' ]).join( "\n" ) )
# require (ctx.basedir.to_pathname + '/../../../../../core/src/main/ruby/jruby/commands.rb')
# files.select do |f|
# f =~ /\//
# end.collect do |f|
# f.sub( /\/.*$/, '')
# end.each do |f|
# JRuby::Commands.generate_dir_info( File.join( target, f ), false )
# end
# end

# resource :directory => '${project.build.directory}/rubygems/bin' do
# includes '*'
# target_path 'META-INF/jruby.home/bin'
# end

build do
directory 'pkg'
end

files = [ 'config.ru', '*file', '*file.lock', '.jbundler/classpath.rb',
'lib/**', 'app/**', 'config/**', 'vendor/**', 'spec/**' ]
jruby_plugin!( :gem,
# need a jruby-complete from maven central here
# TODO fix plugin to use the one from compile-artifacts
:jrubyVersion => '1.7.19',
:includeRubygemsInResources => true ) do
execute_goals( 'generate-resources', 'process-resources', :includeBinStubs => true, :includeRubyResources => files )
end


if File.file?('Jarfile.lock')
phase :package do
phase 'generate-resources' do
plugin :dependency do
items = []
File.read( 'Jarfile.lock' ).each_line do |l|
2 changes: 1 addition & 1 deletion maven/jruby/src/it/runnable/pom.xml
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@
<executions>
<execution>
<id>copy jar dependencies</id>
<phase>package</phase>
<phase>generate-resources</phase>
<goals>
<goal>copy</goal>
</goals>
Binary file added test/jruby/jar_with+.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions test/jruby/test_load.rb
Original file line number Diff line number Diff line change
@@ -255,6 +255,13 @@ def test_loading_jar_with_leading_underscore
}
end

def test_jar_with_plus_in_name
assert_in_sub_runtime %{
require 'test/jruby/jar_with+.jar'
Dir["#{File.dirname( __FILE__ )}/jar_with+.jar!/*"].size == 2
}
end

# JRUBY-5045
def test_cwd_plus_dotdot_jar_loading
assert_equal "hi", run_in_sub_runtime(%{