diff options
author | Patrick J Cherry <patrick@bytemark.co.uk> | 2016-02-10 10:57:47 +0000 |
---|---|---|
committer | Patrick J Cherry <patrick@bytemark.co.uk> | 2016-02-10 10:57:47 +0000 |
commit | 4dd406dd29b166d98485a09ef25ec52867bd5530 (patch) | |
tree | f559fd8b1445c2644cb7ce3920468afa1c720a6c /t | |
parent | 3cfb74235885faa268e4984962e36f7254478104 (diff) |
Adjusted greediness of regex in http with content
It should match the next occurrence of the opening quote type, not the
last.
Diffstat (limited to 't')
-rwxr-xr-x | t/test-custodian-parser.rb | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/t/test-custodian-parser.rb b/t/test-custodian-parser.rb index d9420a5..d3c3842 100755 --- a/t/test-custodian-parser.rb +++ b/t/test-custodian-parser.rb @@ -372,14 +372,15 @@ EOF # Test that we can use lots of different strings for content. # def test_http_with_content_parsing - content_strings = [ - "'bar in single quotes'", - '"bar in double quotes"', - "'bar in single quotes with \"embedded double quotes\"'", - '"bar in double quotes with \'embedded double quotes\'"', - ] - - content_strings.each do |cs| + content_strings = { + "'bar in single quotes'" => 'bar in single quotes', + '"bar in double quotes"' => "bar in double quotes", + "'bar in single quotes with \"embedded double quotes\"'" => 'bar in single quotes with "embedded double quotes"', + '"bar in double quotes with \'embedded double quotes\'"' => "bar in double quotes with 'embedded double quotes'", + "'bar testing greediness' with host header 'but dont be greedy'" => "bar testing greediness", + } + + content_strings.each do |cs, ex| str = "http://example must run http with content #{cs}." obj = Custodian::TestFactory.create(str) assert(!obj.nil?) @@ -387,7 +388,7 @@ EOF assert(obj.size == 1) assert_equal(obj[0].to_s, str) - assert_equal(cs[1..-2], obj[0].expected_content) + assert_equal(ex, obj[0].expected_content) end end |