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