litble/Multi-Docker-Eval huggingface dataset:
Repository: sdsykes/fastimage (ruby)

Issue:
Can it return file size too?
I am planning to develop a PR, but want to know what you think of it.

I use Fastimage to validate remote image fetching. It is good for determining both the size and also the type of image. However I often need to validate file size as well. I am guessing this can be done during when Fastimage does the request too. So I won't need to do my own request in order to find it out. Thoughts?



Discussion:

Patch:
diff --git a/README.textile b/README.textile
--- a/README.textile
+++ b/README.textile
@@ -51,6 +51,8 @@ FastImage.size("http://upload.wikimedia.org/wikipedia/commons/b/b4/Mardin_135066
 => FastImage::ImageFetchFailure: FastImage::ImageFetchFailure
 FastImage.size("http://upload.wikimedia.org/wikipedia/commons/b/b4/Mardin_1350660_1350692_33_images.jpg", :raise_on_failure=>true, :timeout=>2.0)
 => [9545, 6623]
+FastImage.new("http://stephensykes.com/images/pngimage").content_length
+=> 432
 </code></pre>
 
 h2. Installation
diff --git a/lib/fastimage.rb b/lib/fastimage.rb
--- a/lib/fastimage.rb
+++ b/lib/fastimage.rb
@@ -48,7 +48,7 @@
 require 'zlib'
 
 class FastImage
-  attr_reader :size, :type
+  attr_reader :size, :type, :content_length
 
   attr_reader :bytes_read
 
@@ -252,6 +252,8 @@ def fetch_using_http_from_parsed_uri
         end
       end
 
+      @content_length = res.content_length
+
       parse_packets FiberStream.new(read_fiber)
 
       break  # needed to actively quit out of the fetch


Test patch:
diff --git a/test/test.rb b/test/test.rb
--- a/test/test.rb
+++ b/test/test.rb
@@ -297,4 +297,18 @@ def test_cant_access_shell
   ensure
     %x{rm -f shell_test}
   end
+
+  def test_content_length
+    url = "#{TestUrl}with_content_length.gif"
+    FakeWeb.register_uri(:get, url, :body => File.join(FixturePath, "test.jpg"), :content_length => 52)
+
+    assert_equal 52, FastImage.new(url).content_length
+  end
+
+  def test_content_length_not_provided
+    url = "#{TestUrl}without_content_length.gif"
+    FakeWeb.register_uri(:get, url, :body => File.join(FixturePath, "test.jpg"))
+
+    assert_equal nil, FastImage.new(url).content_length
+  end
 end
Repository: JEG2/highline (ruby)

Issue:
test_unicode_flow(TestMenu) test error
I observe the following error:

```
Error: test_unicode_flow(TestMenu)
  ArgumentError: invalid byte sequence in US-ASCII
/builddir/build/BUILD/rubygem-highline-1.6.21/usr/share/gems/gems/highline-1.6.21/lib/highline.rb:724:in `gsub'
/builddir/build/BUILD/rubygem-highline-1.6.21/usr/share/gems/gems/highline-1.6.21/lib/highline.rb:724:in `format_statement'
/builddir/build/BUILD/rubygem-highline-1.6.21/usr/share/gems/gems/highline-1.6.21/lib/highline.rb:617:in `say'
/builddir/build/BUILD/rubygem-highline-1.6.21/usr/share/gems/gems/highline-1.6.21/lib/highline.rb:257:in `ask'
/builddir/build/BUILD/rubygem-highline-1.6.21/usr/share/gems/gems/highline-1.6.21/lib/highline.rb:361:in `choose'
/builddir/build/BUILD/rubygem-highline-1.6.21/usr/share/gems/gems/highline-1.6.21/test/tc_menu.rb:74:in `test_unicode_flow'
```

And it can be reproduced when the test suite is executed with `LANG=C`. This issue was apparently introduced by e206fb6c5da5bdbc6daefcbd which makes some strange unjustified assumptions about terminal encoding.



Discussion:
Thanks for sharing the problem and hunting down the cause!


Patch:
diff --git a/lib/highline.rb b/lib/highline.rb
--- a/lib/highline.rb
+++ b/lib/highline.rb
@@ -617,13 +617,15 @@ def say( statement )
     statement = format_statement(statement)
     return unless statement.length > 0
 
-      # Don't add a newline if statement ends with whitespace, OR
+    out = (indentation+statement).encode(@output.external_encoding, { :undef => :replace  } )
+
+    # Don't add a newline if statement ends with whitespace, OR
     # if statement ends with whitespace before a color escape code.
     if /[ \t](\e\[\d+(;\d+)*m)?\Z/ =~ statement
-      @output.print(indentation+statement)
+      @output.print(out)
       @output.flush
     else
-      @output.puts(indentation+statement)
+      @output.puts(out)
     end
   end
 
@@ -711,10 +713,6 @@ def format_statement statement
     statement = (statement || "").dup.to_str
     return statement unless statement.length > 0
 
-  # Allow non-ascii menu prompts in ruby > 1.9.2. ERB eval the menu statement
-    # with the environment's default encoding(usually utf8)
-    statement.force_encoding(Encoding.default_external) if defined?(Encoding) && Encoding.default_external
-
     template  = ERB.new(statement, nil, "%")
     statement = template.result(binding)
 


Test patch:
diff --git a/test/tc_menu.rb b/test/tc_menu.rb
--- a/test/tc_menu.rb
+++ b/test/tc_menu.rb
@@ -75,7 +75,7 @@ def test_unicode_flow
       # Default:  menu.flow = :rows
       menu.choice "Unicode right single quotation mark: ’"
     end
-    assert_equal("1. Unicode right single quotation mark: ’\n?  ", @output.string)
+    assert_equal("1. Unicode right single quotation mark: ’\n?  ".encode(@output.external_encoding, { :undef => :replace }), @output.string)
   end
 
   def test_help
Repository: yippee-fun/phlex (ruby)

Issue:
Ensure we only compile instance methods



Discussion:

Patch:
diff --git a/lib/phlex/compiler/class_compiler.rb b/lib/phlex/compiler/class_compiler.rb
--- a/lib/phlex/compiler/class_compiler.rb
+++ b/lib/phlex/compiler/class_compiler.rb
@@ -11,11 +11,12 @@ def compile(node)
 
 	def visit_def_node(node)
 		return if node.name == :initialize
+		return if node.receiver
 
 		compiled_source = Phlex::Compiler::MethodCompiler.new(@compiler.component).compile(node)
 
 		if compiled_source
-			puts compiled_source
+			# puts compiled_source
 			@compiler.redefine_method(compiled_source, node.location.start_line)
 		end
 	end


Test patch:
diff --git a/quickdraw/compiler.test.rb b/quickdraw/compiler.test.rb
--- a/quickdraw/compiler.test.rb
+++ b/quickdraw/compiler.test.rb
@@ -28,7 +28,7 @@ def foo
 
 	compiled = Phlex::Compiler::MethodCompiler.new(Phlex::HTML).compile(snippet)
 
-	puts compiled
+	# puts compiled
 
 	assert_equal compiled.strip, out = <<~RUBY.strip
 		def foo
Repository: yippee-fun/phlex (ruby)

Issue:
Support root hash property with flattened hash attributes
```ruby
div(data: { _: "root", foo: "bar" })
```

```html
<div data="root" data-foo="bar'></div>
```

We should also update `mix` to support this.

```ruby
in [_, Hash]
  { _: old, **new }
in [Hash, _]
  { **old, _: new }
```


Discussion:

Patch:
diff --git a/lib/phlex/helpers.rb b/lib/phlex/helpers.rb
--- a/lib/phlex/helpers.rb
+++ b/lib/phlex/helpers.rb
@@ -26,6 +26,10 @@ def mix(*args)
 					[old] + new.to_a
 				in [String, String]
 					"#{old} #{new}"
+				in [_, Hash]
+					{ _: old, **new }
+				in [Hash, _]
+					{ **old, _: new }
 				in [_, nil]
 					old
 				else
diff --git a/lib/phlex/sgml.rb b/lib/phlex/sgml.rb
--- a/lib/phlex/sgml.rb
+++ b/lib/phlex/sgml.rb
@@ -566,14 +566,20 @@ def __nested_attributes__(attributes, base_name, buffer = +"")
 		attributes.each do |k, v|
 			next unless v
 
-			name = case k
-				when String then k
-				when Symbol then k.name.tr("_", "-")
-				else raise Phlex::ArgumentError.new("Attribute keys should be Strings or Symbols")
-			end
+			if (root_key = (:_ == k))
+				name = ""
+				original_base_name = base_name
+				base_name = base_name.delete_suffix("-")
+			else
+				name = case k
+					when String then k
+					when Symbol then k.name.tr("_", "-")
+					else raise Phlex::ArgumentError.new("Attribute keys should be Strings or Symbols")
+				end
 
-			if name.match?(/[<>&"']/)
-				raise Phlex::ArgumentError.new("Unsafe attribute name detected: #{k}.")
+				if name.match?(/[<>&"']/)
+					raise Phlex::ArgumentError.new("Unsafe attribute name detected: #{k}.")
+				end
 			end
 
 			case v
@@ -597,6 +603,10 @@ def __nested_attributes__(attributes, base_name, buffer = +"")
 				raise Phlex::ArgumentError.new("Invalid attribute value #{v.inspect}.")
 			end
 
+			if root_key
+				base_name = original_base_name
+			end
+
 			buffer
 		end
 	end


Test patch:
diff --git a/quickdraw/helpers/mix.test.rb b/quickdraw/helpers/mix.test.rb
--- a/quickdraw/helpers/mix.test.rb
+++ b/quickdraw/helpers/mix.test.rb
@@ -33,7 +33,7 @@
 		{ data: { controller: "bar" } },
 	)
 
-	assert_equal output, { data: { controller: "bar" } }
+	assert_equal output, { data: { _: ["foo"], controller: "bar" } }
 end
 
 test "array + string" do
diff --git a/quickdraw/sgml/attributes.test.rb b/quickdraw/sgml/attributes.test.rb
--- a/quickdraw/sgml/attributes.test.rb
+++ b/quickdraw/sgml/attributes.test.rb
@@ -272,6 +272,14 @@
 	assert_raises(Phlex::ArgumentError) { phlex { div(attribute: { ">" => "a" }) } }
 end
 
+test "_, Hash(:_, _)" do
+	by_itself = phlex { div(attribute: { _: "world" }) }
+	assert_equal_html by_itself, %(<div attribute="world"></div>)
+
+	with_others = phlex { div(data: { _: "test", controller: "hello" }) }
+	assert_equal_html with_others, %(<div data="test" data-controller="hello"></div>)
+end
+
 test "_, Hash(*invalid*, _)" do
 	assert_raises(Phlex::ArgumentError) { phlex { div(attribute: { Object.new => "a" }) } }
 end
Repository: yippee-fun/phlex (ruby)

Issue:
Make `flush` and `await` public



Discussion:

Patch:
diff --git a/Gemfile b/Gemfile
--- a/Gemfile
+++ b/Gemfile
@@ -7,6 +7,10 @@ gemspec
 
 group :test do
 	gem "sus"
+	if RUBY_ENGINE == "ruby" && RUBY_VERSION[0] > "3"
+		gem "async"
+	end
+	gem "concurrent-ruby"
 end
 
 group :development do
diff --git a/lib/phlex/sgml.rb b/lib/phlex/sgml.rb
--- a/lib/phlex/sgml.rb
+++ b/lib/phlex/sgml.rb
@@ -79,15 +79,13 @@ def view_template(&block)
 			template(&block)
 		end
 
-		# @api private
 		def await(task)
-			if defined?(Concurrent::IVar) && task.is_a?(Concurrent::IVar)
+			case task
+			when defined?(Concurrent::IVar) && Concurrent::IVar
 				flush if task.pending?
-
 				task.wait.value
-			elsif defined?(Async::Task) && task.is_a?(Async::Task)
+			when defined?(Async::Task) && Async::Task
 				flush if task.running?
-
 				task.wait
 			else
 				raise ArgumentError, "Expected an asynchronous task / promise."


Test patch:
diff --git a/test/phlex/sgml/await.rb b/test/phlex/sgml/await.rb
new file mode 100644
--- /dev/null
+++ b/test/phlex/sgml/await.rb
@@ -0,0 +1,60 @@
+# frozen_string_literal: true
+
+class Example < Phlex::HTML
+	def initialize(task)
+		@task = task
+	end
+
+	def view_template
+		h1 { "Before" }
+
+		await(@task).then do |message|
+			h1 { message }
+		end
+
+		h1 { "After" }
+	end
+end
+
+describe Phlex::SGML do
+	# The Async gem only works with CRuby 3.0 and above.
+	if RUBY_ENGINE == "ruby" && RUBY_VERSION[0] > "3"
+		describe "with Async tasks" do
+			it "flushes when waiting" do
+				Sync do
+					task = Async { sleep 0.1; "Hello" }
+					buffer = []
+					Example.new(task).call(buffer)
+					expect(buffer).to be == (["<h1>Before</h1>", "<h1>Hello</h1><h1>After</h1>"])
+				end
+			end
+
+			it "doesn't flush when it doesn't need to wait" do
+				Sync do
+					task = Async { sleep 0.1; "Hello" }
+					task.wait
+					buffer = []
+					Example.new(task).call(buffer)
+					expect(buffer).to be == (["<h1>Before</h1><h1>Hello</h1><h1>After</h1>"])
+				end
+			end
+		end
+	end
+
+	describe "with Concurrent Promise" do
+		it "flushes when waiting" do
+			task = Concurrent::Promise.execute { sleep 0.1; "Hello" }
+			buffer = []
+			Example.new(task).call(buffer)
+			expect(buffer).to be == (["<h1>Before</h1>", "<h1>Hello</h1><h1>After</h1>"])
+		end
+
+		it "doesn't flush when it doesn't need to wait" do
+			task = Concurrent::Promise.execute { sleep 0.1; "Hello" }
+			task.wait
+			buffer = []
+			Example.new(task).call(buffer)
+			expect(buffer).to be == (["<h1>Before</h1><h1>Hello</h1><h1>After</h1>"])
+		end
+	end
+end
Repository: rubyzip/rubyzip (ruby)

Issue:
`Zip::FileSystem::ZipFsDir#glob` triggers non-existing `Zip::FileSystem::ZipFileNameMapper#glob` method
Code:

```ruby
require 'zip'
require 'zip/filesystem'

Zip::File.open('archive.zip') do |zip_file|
  zip_file.dir.glob('flags/**/*')
end
```

Output:

```
NoMethodError: undefined method `glob' for #<Zip::FileSystem::ZipFileNameMapper:0x00005654bd818c98>
from /home/alex/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/rubyzip-1.2.1/lib/zip/filesystem.rb:475:in `glob'
```


Discussion:

Patch:
diff --git a/lib/zip/filesystem.rb b/lib/zip/filesystem.rb
--- a/lib/zip/filesystem.rb
+++ b/lib/zip/filesystem.rb
@@ -573,6 +573,10 @@ def get_output_stream(fileName, permissionInt = nil, &aProc)
         @zipFile.get_output_stream(expand_to_entry(fileName), permissionInt, &aProc)
       end
 
+      def glob(pattern, *flags, &block)
+        @zipFile.glob(expand_to_entry(pattern), *flags, &block)
+      end
+
       def read(fileName)
         @zipFile.read(expand_to_entry(fileName))
       end


Test patch:
diff --git a/test/filesystem/directory_test.rb b/test/filesystem/directory_test.rb
--- a/test/filesystem/directory_test.rb
+++ b/test/filesystem/directory_test.rb
@@ -3,6 +3,7 @@
 
 class ZipFsDirectoryTest < MiniTest::Test
   TEST_ZIP = 'test/data/generated/zipWithDirs_copy.zip'
+  GLOB_TEST_ZIP = 'test/data/globTest.zip'
 
   def setup
     FileUtils.cp('test/data/zipWithDirs.zip', TEST_ZIP)
@@ -93,11 +94,28 @@ def test_chroot
     end
   end
 
-  # Globbing not supported yet
-  # def test_glob
-  #  # test alias []-operator too
-  #  fail "implement test"
-  # end
+  def test_glob
+    globbed_files = [
+      'globTest/foo/bar/baz/foo.txt',
+      'globTest/foo.txt',
+      'globTest/food.txt'
+    ]
+
+    ::Zip::File.open(GLOB_TEST_ZIP) do |zf|
+      zf.dir.glob('**/*.txt') do |f|
+        assert globbed_files.include?(f.name)
+      end
+
+      zf.dir.glob('globTest/foo/**/*.txt') do |f|
+        assert_equal globbed_files[0], f.name
+      end
+
+      zf.dir.chdir('globTest/foo')
+      zf.dir.glob('**/*.txt') do |f|
+        assert_equal globbed_files[0], f.name
+      end
+    end
+  end
 
   def test_open_new
     ::Zip::File.open(TEST_ZIP) do |zf|
Repository: rubyzip/rubyzip (ruby)

Issue:
read remainder of entry through input stream fails if a partial read has already been performed.
/lib/zip/ioextras/abstract_input_stream.rb line 22 does not check number_of_bytes for nil before using it.  If the output buffer is not empty due to a partial read on the stream, and a read with no parameters is performed then NoMethodError is raised instead of returning the remainder of the stream.  Can be reproduced via this pseudocode:

z = Zip::File.open('my-zip-file.zip')
e = z.entries.first # Assume first entry is a file
s = e.get_input_stream  # get an input stream to read the file entry
l = s.readline # read the first line of the entry
r = s.read # read remainder of entry
#<NoMethodError: undefined method `<=' for nil:NilClass>
read remainder of entry through input stream fails if a partial read has already been performed.
/lib/zip/ioextras/abstract_input_stream.rb line 22 does not check number_of_bytes for nil before using it.  If the output buffer is not empty due to a partial read on the stream, and a read with no parameters is performed then NoMethodError is raised instead of returning the remainder of the stream.  Can be reproduced via this pseudocode:

z = Zip::File.open('my-zip-file.zip')
e = z.entries.first # Assume first entry is a file
s = e.get_input_stream  # get an input stream to read the file entry
l = s.readline # read the first line of the entry
r = s.read # read remainder of entry
#<NoMethodError: undefined method `<=' for nil:NilClass>


Discussion:

Patch:
diff --git a/Changelog.md b/Changelog.md
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,5 +1,7 @@
 # X.X.X (Next)
 
+- Fix input stream partial read error. [#462](https://github.com/rubyzip/rubyzip/pull/462)
+
 Tooling:
 
 - Update rubocop again and run it in CI. [#444](https://github.com/rubyzip/rubyzip/pull/444)
diff --git a/lib/zip/ioextras/abstract_input_stream.rb b/lib/zip/ioextras/abstract_input_stream.rb
--- a/lib/zip/ioextras/abstract_input_stream.rb
+++ b/lib/zip/ioextras/abstract_input_stream.rb
@@ -19,7 +19,7 @@ def initialize
 
       def read(number_of_bytes = nil, buf = '')
         tbuf = if @output_buffer.bytesize > 0
-                 if number_of_bytes <= @output_buffer.bytesize
+                 if number_of_bytes && number_of_bytes <= @output_buffer.bytesize
                    @output_buffer.slice!(0, number_of_bytes)
                  else
                    number_of_bytes -= @output_buffer.bytesize if number_of_bytes


Test patch:
diff --git a/test/input_stream_test.rb b/test/input_stream_test.rb
--- a/test/input_stream_test.rb
+++ b/test/input_stream_test.rb
@@ -179,4 +179,14 @@ def test_ungetc
       assert_equal('$VERBOSE =', zis.read(10))
     end
   end
+
+  def test_readline_then_read
+    ::Zip::InputStream.open(TestZipFile::TEST_ZIP2.zip_name) do |zis|
+      zis.get_next_entry
+      assert_equal("#!/usr/bin/env ruby\n", zis.readline)
+      refute(zis.eof?)
+      refute_empty(zis.read) # Also should not raise an error.
+      assert(zis.eof?)
+    end
+  end
 end
Repository: yippee-fun/phlex (ruby)

Issue:
If you pass a Hash to `href`, you get an error about calling `downcase` on it



Discussion:

Patch:
diff --git a/lib/phlex/sgml.rb b/lib/phlex/sgml.rb
--- a/lib/phlex/sgml.rb
+++ b/lib/phlex/sgml.rb
@@ -401,9 +401,16 @@ def __attributes__(attributes, buffer = +"")
 			unless Phlex::SGML::SafeObject === v
 				normalized_name = lower_name.delete("^a-z-")
 
-				if value != true && REF_ATTRIBUTES.include?(normalized_name) && value.downcase.delete("^a-z:").start_with?("javascript:")
-					# We just ignore these because they were likely not specified by the developer.
-					next
+				if value != true && REF_ATTRIBUTES.include?(normalized_name)
+					case value
+					when String
+						if value.downcase.delete("^a-z:").start_with?("javascript:")
+							# We just ignore these because they were likely not specified by the developer.
+							next
+						end
+					else
+						raise Phlex::ArgumentError.new("Invalid attribute value for #{k}: #{v.inspect}.")
+					end
 				end
 
 				if normalized_name.bytesize > 2 && normalized_name.start_with?("on") && !normalized_name.include?("-")


Test patch:
diff --git a/quickdraw/sgml/attributes.test.rb b/quickdraw/sgml/attributes.test.rb
--- a/quickdraw/sgml/attributes.test.rb
+++ b/quickdraw/sgml/attributes.test.rb
@@ -26,6 +26,14 @@
 	end
 end
 
+test "href with hash" do
+	expect {
+		phlex { a(href: {}) }
+	}.to_raise(Phlex::ArgumentError) do |error|
+		expect(error.message) == "Invalid attribute value for href: #{{}.inspect}."
+	end
+end
+
 test "unsafe href attribute" do
 	expect(
 		phlex { div(href: "javascript:alert('hello')") },
Repository: servo/rust-url (rust)

Issue:
Consider ignoring UTS46 validity criteria V2
```
Each of the following criteria must be satisfied for a label:
2. The label must not contain a U+002D HYPHEN-MINUS character in both the third and fourth positions. 
```

However, it seems that other UAs don't enforce this, and it matches domains commonly used on youtube. ex: r6---sn-5hne6nee.googlevideo.com



Discussion:
In that case, UTS-46 should probably be changed to match reality. It says:

> Please submit corrigenda and other comments with the online reporting form [[Feedback](http://www.unicode.org/reporting.html)].

so please do that. But since Unicode doesn’t have a public bug tracker, it’d be good to also track it in https://github.com/whatwg/url/issues/53.

Just to note, I raised the issue using the reporting form, and they took note of the offending URLs such as http://r6---sn-5hne6nee.googlevideo.com

```
The rule is only included because the IETF wanted to reserve labels of the form XX--... for future use, in case they wanted another signature like "xn--"
```

They will probably address this in the June release of the next version.


Patch:
diff --git a/idna/src/uts46.rs b/idna/src/uts46.rs
--- a/idna/src/uts46.rs
+++ b/idna/src/uts46.rs
@@ -198,12 +198,10 @@ fn validate(label: &str, flags: Flags, errors: &mut Vec<Error>) {
     }
 
     // Can not contain '.' since the input is from .split('.')
-    if {
-        let mut chars = label.chars().skip(2);
-        let third = chars.next();
-        let fourth = chars.next();
-        (third, fourth) == (Some('-'), Some('-'))
-    } || label.starts_with("-")
+    // Spec says that the label must not contain a HYPHEN-MINUS character in both the
+    // third and fourth positions. But nobody follows this criteria. See the spec issue below:
+    // https://github.com/whatwg/url/issues/53
+    if label.starts_with("-")
         || label.ends_with("-")
         || label.chars().next().map_or(false, is_combining_mark)
         || label.chars().any(|c| match *find_char(c) {


Test patch:
diff --git a/tests/unit.rs b/tests/unit.rs
--- a/tests/unit.rs
+++ b/tests/unit.rs
@@ -192,6 +192,7 @@ fn host_serialization() {
 fn test_idna() {
     assert!("http://goșu.ro".parse::<Url>().is_ok());
     assert_eq!(Url::parse("http://☃.net/").unwrap().host(), Some(Host::Domain("xn--n3h.net")));
+    assert!("https://r2---sn-huoa-cvhl.googlevideo.com/crossdomain.xml".parse::<Url>().is_ok());
 }
 
 #[test]
Repository: servo/rust-url (rust)

Issue:
Integer Overflow on odd `file` URL
This code:

``` rust
"file:...".parse::<Url>();
```

will yield this error:

```
test tests::bad_file_url ... FAILED

failures:

---- tests::bad_file_url stdout ----
        thread 'tests::bad_file_url' panicked at 'arithmetic operation overflowed', src/parser.rs:287



failures:
    tests::bad_file_url

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
```



Discussion:

Patch:
diff --git a/src/parser.rs b/src/parser.rs
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -7,6 +7,7 @@
 // except according to those terms.
 
 use std::ascii::AsciiExt;
+use std::cmp::max;
 use std::error::Error;
 use std::fmt::{self, Formatter};
 
@@ -284,7 +285,7 @@ fn parse_relative_url<'a>(input: &'a str, scheme: String, scheme_type: SchemeTyp
                     path: path
                 }), remaining)
             } else {
-                let base_path = &base.path[..base.path.len() - 1];
+                let base_path = &base.path[..max(base.path.len(), 1) - 1];
                 // Relative path state
                 let (path, remaining) = try!(parse_path(
                     base_path, input, Context::UrlParser, scheme_type, parser));


Test patch:
diff --git a/src/tests.rs b/src/tests.rs
--- a/src/tests.rs
+++ b/src/tests.rs
@@ -291,3 +291,13 @@ fn new_directory_paths() {
 fn from_str() {
     assert!("http://testing.com/this".parse::<Url>().is_ok());
 }
+
+#[test]
+fn issue_124() {
+    let url: Url = "file:a".parse().unwrap();
+    assert_eq!(url.path().unwrap(), ["a"]);
+    let url: Url = "file:...".parse().unwrap();
+    assert_eq!(url.path().unwrap(), ["..."]);
+    let url: Url = "file:..".parse().unwrap();
+    assert_eq!(url.path().unwrap(), [""]);
+}