Permalink
Browse files

fixing URI warnings

  • Loading branch information...
1 parent ff0d98a commit c94257db653c6bbe9706b973481a78d705d3a32f @tenderlove committed Mar 21, 2013
Showing with 14 additions and 3 deletions.
  1. +1 −2 lib/sass/engine.rb
  2. +1 −1 lib/sass/tree/rule_node.rb
  3. +12 −0 lib/sass/util.rb
View
@@ -356,7 +356,7 @@ def _render_with_sourcemap(sourcemap_uri)
rendered << "\n" if rendered[-1] != ?\n
rendered << "\n" unless compressed
rendered << "/*@ sourceMappingURL="
- rendered << URI.encode(sourcemap_uri)
+ rendered << Sass::Util.escape_uri(sourcemap_uri)
rendered << " */"
rendered = encode_and_set_charset(rendered)
return rendered, sourcemap
@@ -678,7 +678,6 @@ def parse_property_or_rule(line)
res.pop if comment
scanner_start_pos = scanner.pos
interp_parsed = parse_interp(scanner.rest)
- scanned_size = scanner.pos - scanner_start_pos
selector_range = Sass::Source::Range.new(
ident_range.start_pos,
Sass::Source::Position.new(@line, to_parser_offset(line.offset) + line.text.length),
@@ -116,7 +116,7 @@ def continued?
#
# @return [{#to_s => #to_s}]
def debug_info
- {:filename => filename && ("file://" + URI.escape(File.expand_path(filename))),
+ {:filename => filename && ("file://" + Sass::Util.escape_uri(File.expand_path(filename))),
:line => self.line}
end
View
@@ -962,6 +962,18 @@ def method_missing(name, *args, &block)
end
end
+
+ # This is a hack around the fact that you can't instantiate a URI parser
+ # on 1.8, so we have to have this hacky stuff to work around it. When
+ # 1.8 support is dropped, we can remove this method.
+ #
+ # **THIS IS NOT A PUBLIC METHOD, JUST A HACK** :-)
@nex3

nex3 Mar 22, 2013

There's no need for this, or the :nodoc: comment. Half the methods in Sass::Util are hacks around compatibility-issues.

@tenderlove

tenderlove Mar 22, 2013

Owner

Sounds good, I'll delete the comment.

+ def escape_uri(uri) # :nodoc:
+ URI.const_defined?(:DEFAULT_PARSER) ?
+ URI::DEFAULT_PARSER.escape(uri) :
@nex3

nex3 Mar 22, 2013

Can we cache the parser? Something like $parser ||= URI.const_defined?(:DEFAULT_PARSER) ? URI::DEFAULT_PARSER : URI?

@tenderlove

tenderlove Mar 22, 2013

Owner

Sure. I'll cache the value.

+ URI.escape(uri)
+ end
+
private
# Calculates the memoization table for the Least Common Subsequence algorithm.

0 comments on commit c94257d

Please sign in to comment.