]>
Commit | Line | Data |
---|---|---|
fe123bd0 ER |
1 | --- cvsspam.rb (working copy) |
2 | +++ cvsspam.rb 2009-03-05 01:48:46.419779119 +0200 | |
d0da94c0 ER |
3 | @@ -936,7 +936,10 @@ |
4 | addInfixSize = line.length - (prefixLen+suffixLen) | |
5 | oversize_change = deleteInfixSize*100/@lineJustDeleted.length>33 || addInfixSize*100/line.length>33 | |
6 | ||
7 | - if prefixLen==1 && suffixLen==0 || deleteInfixSize<=0 || oversize_change | |
8 | + # avoid doing 'within-a-line highlighting' if a multibyte encoding | |
9 | + # is suspected, as all the suffix/prefix stuff above is byte, not | |
10 | + # character based | |
11 | + if multibyte_encoding? || prefixLen==1 && suffixLen==0 || deleteInfixSize<=0 || oversize_change | |
12 | print(htmlEncode(@lineJustDeleted)) | |
13 | else | |
14 | print(htmlEncode(@lineJustDeleted[0,prefixLen])) | |
fe123bd0 ER |
15 | @@ -1118,7 +1121,7 @@ |
16 | @lineJustDeleted = nil | |
17 | end | |
18 | shift(initial) | |
19 | - if prefixLen==1 && suffixLen==0 || addInfixSize<=0 || oversize_change | |
20 | + if multibyte_encoding? || prefixLen==1 && suffixLen==0 || addInfixSize<=0 || oversize_change | |
21 | encoded = htmlEncode(line) | |
22 | else | |
23 | encoded = htmlEncode(line[0,prefixLen]) + | |
d0da94c0 ER |
24 | @@ -1297,6 +1300,11 @@ |
25 | end | |
26 | end | |
27 | ||
28 | +# guess if the users selected encoding is multibyte, since some CVSspam code | |
29 | +# isn't multibyte-safe, and needs to be disabled. | |
30 | +def multibyte_encoding? | |
31 | + $charset && ["utf-8", "utf-16"].include?($charset.downcase) | |
32 | +end | |
33 | ||
34 | cvsroot_dir = "#{ENV['CVSROOT']}/CVSROOT" | |
35 | $config = "#{cvsroot_dir}/cvsspam.conf" |