Skip to content
Browse files

Triple escaped quotes are unescaped

  • Loading branch information...
1 parent 7a7f365 commit af5f699a922d16327e2421308dd08f8fd3f33257 @aslakhellesoy aslakhellesoy committed Apr 11, 2010
View
5 History.txt
@@ -1,3 +1,8 @@
+== In Git
+
+=== Bugfixes
+* Triple escaped quotes (\"\"\") in PyStrings are unescaped to """. (Aslak Hellesøy)
+
== 1.0.8 (2010-04-10)
=== Bugfixes
View
250 gherkin.gemspec
@@ -1,250 +0,0 @@
-# Generated by jeweler
-# DO NOT EDIT THIS FILE DIRECTLY
-# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{gherkin}
- s.version = "1.0.8"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Mike Sassak", "Gregory Hnatiuk", "Aslak Helles\303\270y"]
- s.date = %q{2010-04-11}
- s.default_executable = %q{gherkin}
- s.description = %q{A fast Gherkin lexer/parser based on the Ragel State Machine Compiler.}
- s.email = %q{cukes@googlegroups.com}
- s.executables = ["gherkin"]
- s.extensions = ["ext/gherkin_lexer_ar/extconf.rb", "ext/gherkin_lexer_bg/extconf.rb", "ext/gherkin_lexer_ca/extconf.rb", "ext/gherkin_lexer_cs/extconf.rb", "ext/gherkin_lexer_cy_gb/extconf.rb", "ext/gherkin_lexer_da/extconf.rb", "ext/gherkin_lexer_de/extconf.rb", "ext/gherkin_lexer_en/extconf.rb", "ext/gherkin_lexer_en_au/extconf.rb", "ext/gherkin_lexer_en_lol/extconf.rb", "ext/gherkin_lexer_en_scouse/extconf.rb", "ext/gherkin_lexer_en_tx/extconf.rb", "ext/gherkin_lexer_es/extconf.rb", "ext/gherkin_lexer_et/extconf.rb", "ext/gherkin_lexer_fi/extconf.rb", "ext/gherkin_lexer_fr/extconf.rb", "ext/gherkin_lexer_he/extconf.rb", "ext/gherkin_lexer_hr/extconf.rb", "ext/gherkin_lexer_hu/extconf.rb", "ext/gherkin_lexer_id/extconf.rb", "ext/gherkin_lexer_it/extconf.rb", "ext/gherkin_lexer_ja/extconf.rb", "ext/gherkin_lexer_ko/extconf.rb", "ext/gherkin_lexer_lt/extconf.rb", "ext/gherkin_lexer_lv/extconf.rb", "ext/gherkin_lexer_nl/extconf.rb", "ext/gherkin_lexer_no/extconf.rb", "ext/gherkin_lexer_pl/extconf.rb", "ext/gherkin_lexer_pt/extconf.rb", "ext/gherkin_lexer_ro/extconf.rb", "ext/gherkin_lexer_ro_ro/extconf.rb", "ext/gherkin_lexer_ru/extconf.rb", "ext/gherkin_lexer_sk/extconf.rb", "ext/gherkin_lexer_sr_cyrl/extconf.rb", "ext/gherkin_lexer_sr_latn/extconf.rb", "ext/gherkin_lexer_sv/extconf.rb", "ext/gherkin_lexer_tr/extconf.rb", "ext/gherkin_lexer_uk/extconf.rb", "ext/gherkin_lexer_uz/extconf.rb", "ext/gherkin_lexer_vi/extconf.rb", "ext/gherkin_lexer_zh_cn/extconf.rb", "ext/gherkin_lexer_zh_tw/extconf.rb"]
- s.extra_rdoc_files = [
- "LICENSE",
- "README.rdoc"
- ]
- s.files = [
- ".gitattributes",
- ".gitignore",
- ".mailmap",
- "History.txt",
- "LICENSE",
- "README.rdoc",
- "Rakefile",
- "VERSION.yml",
- "bin/gherkin",
- "cucumber.yml",
- "ext/gherkin_lexer_ar/gherkin_lexer_ar.c",
- "ext/gherkin_lexer_bg/gherkin_lexer_bg.c",
- "ext/gherkin_lexer_ca/gherkin_lexer_ca.c",
- "ext/gherkin_lexer_cs/gherkin_lexer_cs.c",
- "ext/gherkin_lexer_cy_gb/gherkin_lexer_cy_gb.c",
- "ext/gherkin_lexer_da/gherkin_lexer_da.c",
- "ext/gherkin_lexer_de/gherkin_lexer_de.c",
- "ext/gherkin_lexer_en/gherkin_lexer_en.c",
- "ext/gherkin_lexer_en_au/gherkin_lexer_en_au.c",
- "ext/gherkin_lexer_en_lol/gherkin_lexer_en_lol.c",
- "ext/gherkin_lexer_en_scouse/gherkin_lexer_en_scouse.c",
- "ext/gherkin_lexer_en_tx/gherkin_lexer_en_tx.c",
- "ext/gherkin_lexer_es/gherkin_lexer_es.c",
- "ext/gherkin_lexer_et/gherkin_lexer_et.c",
- "ext/gherkin_lexer_fi/gherkin_lexer_fi.c",
- "ext/gherkin_lexer_fr/gherkin_lexer_fr.c",
- "ext/gherkin_lexer_he/gherkin_lexer_he.c",
- "ext/gherkin_lexer_hr/gherkin_lexer_hr.c",
- "ext/gherkin_lexer_hu/gherkin_lexer_hu.c",
- "ext/gherkin_lexer_id/gherkin_lexer_id.c",
- "ext/gherkin_lexer_it/gherkin_lexer_it.c",
- "ext/gherkin_lexer_ja/gherkin_lexer_ja.c",
- "ext/gherkin_lexer_ko/gherkin_lexer_ko.c",
- "ext/gherkin_lexer_lt/gherkin_lexer_lt.c",
- "ext/gherkin_lexer_lv/gherkin_lexer_lv.c",
- "ext/gherkin_lexer_nl/gherkin_lexer_nl.c",
- "ext/gherkin_lexer_no/gherkin_lexer_no.c",
- "ext/gherkin_lexer_pl/gherkin_lexer_pl.c",
- "ext/gherkin_lexer_pt/gherkin_lexer_pt.c",
- "ext/gherkin_lexer_ro/gherkin_lexer_ro.c",
- "ext/gherkin_lexer_ro_ro/gherkin_lexer_ro_ro.c",
- "ext/gherkin_lexer_ru/gherkin_lexer_ru.c",
- "ext/gherkin_lexer_sk/gherkin_lexer_sk.c",
- "ext/gherkin_lexer_sr_cyrl/gherkin_lexer_sr_cyrl.c",
- "ext/gherkin_lexer_sr_latn/gherkin_lexer_sr_latn.c",
- "ext/gherkin_lexer_sv/gherkin_lexer_sv.c",
- "ext/gherkin_lexer_tr/gherkin_lexer_tr.c",
- "ext/gherkin_lexer_uk/gherkin_lexer_uk.c",
- "ext/gherkin_lexer_uz/gherkin_lexer_uz.c",
- "ext/gherkin_lexer_vi/gherkin_lexer_vi.c",
- "ext/gherkin_lexer_zh_cn/gherkin_lexer_zh_cn.c",
- "ext/gherkin_lexer_zh_tw/gherkin_lexer_zh_tw.c",
- "features/feature_parser.feature",
- "features/native_lexer.feature",
- "features/parser_with_native_lexer.feature",
- "features/pretty_printer.feature",
- "features/step_definitions/gherkin_steps.rb",
- "features/step_definitions/pretty_formatter_steps.rb",
- "features/steps_parser.feature",
- "features/support/env.rb",
- "gherkin.gemspec",
- "ikvm/.gitignore",
- "java/.gitignore",
- "java/src/main/java/gherkin/lexer/.gitignore",
- "lib/.gitignore",
- "lib/gherkin.rb",
- "lib/gherkin/c_lexer.rb",
- "lib/gherkin/cli/main.rb",
- "lib/gherkin/core_ext/array.rb",
- "lib/gherkin/csharp_lexer.rb",
- "lib/gherkin/formatter/argument.rb",
- "lib/gherkin/formatter/colors.rb",
- "lib/gherkin/formatter/monochrome_format.rb",
- "lib/gherkin/formatter/pretty_formatter.rb",
- "lib/gherkin/i18n.rb",
- "lib/gherkin/i18n.yml",
- "lib/gherkin/i18n_lexer.rb",
- "lib/gherkin/java_impl.rb",
- "lib/gherkin/parser/filter_listener.rb",
- "lib/gherkin/parser/meta.txt",
- "lib/gherkin/parser/parser.rb",
- "lib/gherkin/parser/root.txt",
- "lib/gherkin/parser/sexp.rb",
- "lib/gherkin/parser/steps.txt",
- "lib/gherkin/parser/tag_expression.rb",
- "lib/gherkin/rb_lexer.rb",
- "lib/gherkin/rb_lexer/.gitignore",
- "lib/gherkin/rb_lexer/README.rdoc",
- "lib/gherkin/rb_lexer/ar.rb",
- "lib/gherkin/rb_lexer/bg.rb",
- "lib/gherkin/rb_lexer/ca.rb",
- "lib/gherkin/rb_lexer/cs.rb",
- "lib/gherkin/rb_lexer/cy_gb.rb",
- "lib/gherkin/rb_lexer/da.rb",
- "lib/gherkin/rb_lexer/de.rb",
- "lib/gherkin/rb_lexer/en.rb",
- "lib/gherkin/rb_lexer/en_au.rb",
- "lib/gherkin/rb_lexer/en_lol.rb",
- "lib/gherkin/rb_lexer/en_scouse.rb",
- "lib/gherkin/rb_lexer/en_tx.rb",
- "lib/gherkin/rb_lexer/es.rb",
- "lib/gherkin/rb_lexer/et.rb",
- "lib/gherkin/rb_lexer/fi.rb",
- "lib/gherkin/rb_lexer/fr.rb",
- "lib/gherkin/rb_lexer/he.rb",
- "lib/gherkin/rb_lexer/hr.rb",
- "lib/gherkin/rb_lexer/hu.rb",
- "lib/gherkin/rb_lexer/id.rb",
- "lib/gherkin/rb_lexer/it.rb",
- "lib/gherkin/rb_lexer/ja.rb",
- "lib/gherkin/rb_lexer/ko.rb",
- "lib/gherkin/rb_lexer/lt.rb",
- "lib/gherkin/rb_lexer/lv.rb",
- "lib/gherkin/rb_lexer/nl.rb",
- "lib/gherkin/rb_lexer/no.rb",
- "lib/gherkin/rb_lexer/pl.rb",
- "lib/gherkin/rb_lexer/pt.rb",
- "lib/gherkin/rb_lexer/ro.rb",
- "lib/gherkin/rb_lexer/ro_ro.rb",
- "lib/gherkin/rb_lexer/ru.rb",
- "lib/gherkin/rb_lexer/sk.rb",
- "lib/gherkin/rb_lexer/sr_cyrl.rb",
- "lib/gherkin/rb_lexer/sr_latn.rb",
- "lib/gherkin/rb_lexer/sv.rb",
- "lib/gherkin/rb_lexer/tr.rb",
- "lib/gherkin/rb_lexer/uk.rb",
- "lib/gherkin/rb_lexer/uz.rb",
- "lib/gherkin/rb_lexer/vi.rb",
- "lib/gherkin/rb_lexer/zh_cn.rb",
- "lib/gherkin/rb_lexer/zh_tw.rb",
- "lib/gherkin/tools.rb",
- "lib/gherkin/tools/files.rb",
- "lib/gherkin/tools/reformat.rb",
- "lib/gherkin/tools/stats.rb",
- "lib/gherkin/tools/stats_listener.rb",
- "ragel/i18n/.gitignore",
- "ragel/lexer.c.rl.erb",
- "ragel/lexer.java.rl.erb",
- "ragel/lexer.rb.rl.erb",
- "ragel/lexer_common.rl.erb",
- "spec/gherkin/c_lexer_spec.rb",
- "spec/gherkin/csharp_lexer_spec.rb",
- "spec/gherkin/fixtures/1.feature",
- "spec/gherkin/fixtures/comments_in_table.feature",
- "spec/gherkin/fixtures/complex.feature",
- "spec/gherkin/fixtures/dos_line_endings.feature",
- "spec/gherkin/fixtures/i18n_fr.feature",
- "spec/gherkin/fixtures/i18n_no.feature",
- "spec/gherkin/fixtures/i18n_zh-CN.feature",
- "spec/gherkin/fixtures/simple.feature",
- "spec/gherkin/fixtures/simple_with_comments.feature",
- "spec/gherkin/fixtures/simple_with_tags.feature",
- "spec/gherkin/formatter/argument_spec.rb",
- "spec/gherkin/formatter/colors_spec.rb",
- "spec/gherkin/formatter/pretty_formatter_spec.rb",
- "spec/gherkin/i18n_lexer_spec.rb",
- "spec/gherkin/i18n_spec.rb",
- "spec/gherkin/parser/filter_listener_spec.rb",
- "spec/gherkin/parser/parser_spec.rb",
- "spec/gherkin/parser/tag_expression_spec.rb",
- "spec/gherkin/rb_lexer_spec.rb",
- "spec/gherkin/sexp_recorder.rb",
- "spec/gherkin/shared/lexer_spec.rb",
- "spec/gherkin/shared/py_string_spec.rb",
- "spec/gherkin/shared/row_spec.rb",
- "spec/gherkin/shared/tags_spec.rb",
- "spec/spec_helper.rb",
- "tasks/bench.rake",
- "tasks/bench/feature_builder.rb",
- "tasks/bench/generated/.gitignore",
- "tasks/bench/null_listener.rb",
- "tasks/compile.rake",
- "tasks/cucumber.rake",
- "tasks/gems.rake",
- "tasks/ikvm.rake",
- "tasks/ragel_task.rb",
- "tasks/rdoc.rake",
- "tasks/release.rake",
- "tasks/rspec.rake"
- ]
- s.homepage = %q{http://github.com/aslakhellesoy/gherkin}
- s.rdoc_options = ["--charset=UTF-8"]
- s.require_paths = ["lib"]
- s.rubygems_version = %q{1.3.6}
- s.summary = %q{Fast Gherkin lexer/parser}
- s.test_files = [
- "spec/gherkin/c_lexer_spec.rb",
- "spec/gherkin/csharp_lexer_spec.rb",
- "spec/gherkin/formatter/argument_spec.rb",
- "spec/gherkin/formatter/colors_spec.rb",
- "spec/gherkin/formatter/pretty_formatter_spec.rb",
- "spec/gherkin/i18n_lexer_spec.rb",
- "spec/gherkin/i18n_spec.rb",
- "spec/gherkin/parser/filter_listener_spec.rb",
- "spec/gherkin/parser/parser_spec.rb",
- "spec/gherkin/parser/tag_expression_spec.rb",
- "spec/gherkin/rb_lexer_spec.rb",
- "spec/gherkin/sexp_recorder.rb",
- "spec/gherkin/shared/lexer_spec.rb",
- "spec/gherkin/shared/py_string_spec.rb",
- "spec/gherkin/shared/row_spec.rb",
- "spec/gherkin/shared/tags_spec.rb",
- "spec/spec_helper.rb"
- ]
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<trollop>, [">= 1.15"])
- s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
- s.add_development_dependency(%q<cucumber>, [">= 0.6.4"])
- s.add_development_dependency(%q<rake-compiler>, [">= 0.7.0"])
- else
- s.add_dependency(%q<trollop>, [">= 1.15"])
- s.add_dependency(%q<rspec>, [">= 1.3.0"])
- s.add_dependency(%q<cucumber>, [">= 0.6.4"])
- s.add_dependency(%q<rake-compiler>, [">= 0.7.0"])
- end
- else
- s.add_dependency(%q<trollop>, [">= 1.15"])
- s.add_dependency(%q<rspec>, [">= 1.3.0"])
- s.add_dependency(%q<cucumber>, [">= 0.6.4"])
- s.add_dependency(%q<rake-compiler>, [">= 0.7.0"])
- end
-end
-
View
2 ragel/lexer.c.rl.erb
@@ -293,8 +293,10 @@ store_pystring_content(VALUE listener,
snprintf(pat, 32, "^ {0,%d}", start_col);
VALUE re = rb_reg_regcomp(rb_str_new2(pat));
VALUE re2 = rb_reg_regcomp(rb_str_new2("\r\\Z"));
+ VALUE unescape_escaped_quotes = rb_reg_regcomp(rb_str_new2("\\\\\"\\\\\"\\\\\""));
rb_funcall(con, rb_intern("gsub!"), 2, re, rb_str_new2(""));
rb_funcall(con, rb_intern("sub!"), 2, re2, rb_str_new2(""));
+ rb_funcall(con, rb_intern("gsub!"), 2, unescape_escaped_quotes, rb_str_new2("\"\"\""));
rb_funcall(listener, rb_intern("py_string"), 2, con, INT2FIX(current_line));
}
View
2 ragel/lexer.java.rl.erb
@@ -28,7 +28,7 @@ public class <%= @i18n.sanitized_key.upcase %> implements Lexer {
}
action store_pystring_content {
- String con = unindent(startCol, substring(data, contentStart, nextKeywordStart-1).replaceFirst("(\\r?\\n)?( )*\\Z", ""));
+ String con = unindent(startCol, substring(data, contentStart, nextKeywordStart-1).replaceFirst("(\\r?\\n)?( )*\\Z", "").replaceAll("\\\\\"\\\\\"\\\\\"", "\"\"\""));
listener.py_string(con, currentLine);
}
View
2 ragel/lexer.rb.rl.erb
@@ -21,7 +21,7 @@ module Gherkin
}
action store_pystring_content {
- con = unindent(@start_col, data[@content_start...@next_keyword_start-1].utf8_pack("c*").sub(/(\r?\n)?( )*\Z/, ''))
+ con = unindent(@start_col, data[@content_start...@next_keyword_start-1].utf8_pack("c*").sub(/(\r?\n)?( )*\Z/, '').gsub(/\\"\\"\\"/, '"""'))
@listener.py_string(con, @current_line)
}
View
21 spec/gherkin/java_lexer_spec.rb
@@ -0,0 +1,21 @@
+#encoding: utf-8
+if defined?(JRUBY_VERSION)
+require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
+require 'gherkin.jar'
+
+module Gherkin
+ module JavaLexer
+ describe "Java Lexer" do
+ before do
+ @listener = Gherkin::SexpRecorder.new
+ @lexer = Java::Gherkin::I18nLexer.new(@listener)
+ end
+
+ it_should_behave_like "a Gherkin lexer"
+ it_should_behave_like "a Gherkin lexer lexing tags"
+ it_should_behave_like "a Gherkin lexer lexing py_strings"
+ it_should_behave_like "a Gherkin lexer lexing rows"
+ end
+ end
+end
+end
View
20 spec/gherkin/shared/py_string_spec.rb
@@ -125,6 +125,26 @@ def ps(content)
@listener.should_receive(:py_string).with("Line one\r\nLine two\r\n", 1)
@lexer.scan("\"\"\"\r\nLine one\r\nLine two\r\n\r\n\"\"\"")
end
+
+ it "should unescape escaped triple quotes" do
+str = <<EOS
+ """
+ \\"\\"\\"
+ """
+EOS
+ @listener.should_receive(:py_string).with('"""', 1)
+ @lexer.scan(str)
+ end
+
+ it "should not unescape escaped single quotes" do
+str = <<EOS
+ """
+ \\" \\"\\"
+ """
+EOS
+ @listener.should_receive(:py_string).with('\" \"\"', 1)
+ @lexer.scan(str)
+ end
end
end
end
View
6 tasks/cucumber.rake
@@ -1,3 +1,4 @@
+begin
require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:cucumber) do |t|
@@ -18,3 +19,8 @@ namespace :cucumber do
task :native_lexer => [:check_dependencies, :clean, :compile]
end
+rescue LoadError
+ task :cucumber do
+ raise "Cucumber not installed"
+ end
+end

0 comments on commit af5f699

Please sign in to comment.
Something went wrong with that request. Please try again.