Skip to content

Commit

Permalink
escape_javascript does not kill anymore opening html tags
Browse files Browse the repository at this point in the history
  • Loading branch information
nagybence authored and brianmario committed Sep 5, 2010
1 parent 051efbc commit ec710a4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.1.5
0.1.6
21 changes: 14 additions & 7 deletions escape_utils.gemspec
Expand Up @@ -5,11 +5,11 @@

Gem::Specification.new do |s|
s.name = %q{escape_utils}
s.version = "0.1.5"
s.version = "0.1.6"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Brian Lopez"]
s.date = %q{2010-08-07}
s.date = %q{2010-09-05}
s.email = %q{seniorlopez@gmail.com}
s.extensions = ["ext/extconf.rb"]
s.extra_rdoc_files = [
Expand Down Expand Up @@ -41,28 +41,35 @@ Gem::Specification.new do |s|
"lib/escape_utils/url/cgi.rb",
"lib/escape_utils/url/erb.rb",
"lib/escape_utils/url/rack.rb",
"lib/escape_utils/url/uri.rb",
"spec/html/escape_spec.rb",
"spec/html/unescape_spec.rb",
"spec/html_safety_spec.rb",
"spec/javascript/escape_spec.rb",
"spec/javascript/unescape_spec.rb",
"spec/query/escape_spec.rb",
"spec/query/unescape_spec.rb",
"spec/rcov.opts",
"spec/spec.opts",
"spec/spec_helper.rb"
"spec/spec_helper.rb",
"spec/uri/escape_spec.rb",
"spec/uri/unescape_spec.rb"
]
s.homepage = %q{http://github.com/brianmario/escape_utils}
s.rdoc_options = ["--charset=UTF-8"]
s.require_paths = ["lib", "ext"]
s.rubygems_version = %q{1.3.7}
s.summary = %q{Faster string escaping routines for your web apps}
s.test_files = [
"spec/html/escape_spec.rb",
"spec/html/unescape_spec.rb",
"spec/html_safety_spec.rb",
"spec/javascript/escape_spec.rb",
"spec/javascript/escape_spec.rb",
"spec/javascript/unescape_spec.rb",
"spec/html/escape_spec.rb",
"spec/html/unescape_spec.rb",
"spec/query/escape_spec.rb",
"spec/query/unescape_spec.rb",
"spec/html_safety_spec.rb",
"spec/uri/escape_spec.rb",
"spec/uri/unescape_spec.rb",
"spec/spec_helper.rb"
]

Expand Down
6 changes: 4 additions & 2 deletions ext/escape_utils.c
Expand Up @@ -114,8 +114,9 @@ static size_t escape_javascript(unsigned char *out, const unsigned char *in, siz
total++;
break;
case '<':
*out++ = '<';
if (*in == '/') {
*out++ = '<'; *out++ = '\\'; *out++ = '/';
*out++ = '\\'; *out++ = '/';
in++; in_len--;
total++;
}
Expand Down Expand Up @@ -592,4 +593,5 @@ void Init_escape_utils_ext() {
#ifdef HAVE_RUBY_ENCODING_H
utf8Encoding = rb_utf8_encoding();
#endif
}
}

5 changes: 3 additions & 2 deletions spec/javascript/escape_spec.rb
Expand Up @@ -20,7 +20,7 @@
end

it "should escape closed html tags" do
EscapeUtils.escape_javascript(%(dont </close> tags)).should eql(%(dont <\\/close> tags))
EscapeUtils.escape_javascript(%(keep <open>, but dont </close> tags)).should eql(%(keep <open>, but dont <\\/close> tags))
end

if RUBY_VERSION =~ /^1.9/
Expand All @@ -36,4 +36,5 @@
EscapeUtils.escape_javascript(%(dont </close> tags)).encoding.should eql(Encoding.default_internal)
end
end
end
end

0 comments on commit ec710a4

Please sign in to comment.