kana / vim-vspec

Vim plugin: Testing framework for Vim script
http://www.vim.org/scripts/script.php?script_id=3012
222 stars 13 forks source link

Combining characters are not properly encoded as a function name #20

Closed kana closed 10 years ago

kana commented 11 years ago

Derived from gh-13:

Every {example} is used as a function name. But they are not used as is. Characters which are invalid as a function name are encoded. Thus, I think nothing will be changed by accepting double-quoted strings. Why did you think that it is problematic?

I know. I remember that I wrote this because I had found an issue – now I see that it is a different issue. It affects all {example} strings (single- and double-quoted).

Every string that has combining characters will break generate_example_function_name(). Two examples:

describe "combining characters in {example}"
  it "make vspec fail: 'a\u0300'"
    Expect 1 + 1 == 2
  end
end
# /private/var/folders/Sa/SafiUtyBG3Wmwja17AWRyE+++TI/-Tmp-/vZd4XYt/0, line 6
# Vim(function):E475: Invalid argument: make_20vspec_20fail_3a_20_27à_27
1..0
describe "combining characters in {example}"
  it "collide with different example '\u0935\u093e'"
    Expect 1 + 1 == 12345 " ok!
  end
  it "collide with different example '\u0935\u093f'"
    Expect 1 + 1 == 2
  end
end
ok 1 - combining characters in {example} collide with different example 'वा'
ok 2 - combining characters in {example} collide with different example 'वि'
1..2

I haven't investigated further. This is probably really outside the scope of vspec. I'm not sure it is worth fixing ...

kana commented 10 years ago

Note: These failed example are reproducible if 'encoding' is utf-8.

kana commented 10 years ago

@glts: I've fixed this issue and released a new version of vspec. Please check it out when you have free time.

glts commented 10 years ago

:+1:

Tested on Vim 7.2.108 and Vim 7.4. Thanks.