comparison mercurial/hgweb/webcommands.py @ 15727:917f263eeb26

i18n: use "encoding.lower()" to normalize string in hgweb search query some problematic encoding (e.g.: cp932) uses ASCII alphabet characters in byte sequence of multi byte characters. "str.lower()" on such byte sequence may treat distinct characters as same one, and cause unexpected log matching. this patch uses "encoding.lower()" instead of "str.lower()" to normalize strings for compare.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sun, 25 Dec 2011 20:35:16 +0900
parents a84698badf0b
children 5e50982c633c
comparison
equal deleted inserted replaced
15726:9b822edecb4c 15727:917f263eeb26
122 morevars['revcount'] = revcount * 2 122 morevars['revcount'] = revcount * 2
123 morevars['rev'] = query 123 morevars['rev'] = query
124 124
125 def changelist(**map): 125 def changelist(**map):
126 count = 0 126 count = 0
127 qw = query.lower().split() 127 lower = encoding.lower
128 qw = lower(query).split()
128 129
129 def revgen(): 130 def revgen():
130 for i in xrange(len(web.repo) - 1, 0, -100): 131 for i in xrange(len(web.repo) - 1, 0, -100):
131 l = [] 132 l = []
132 for j in xrange(max(0, i - 100), i + 1): 133 for j in xrange(max(0, i - 100), i + 1):
137 yield e 138 yield e
138 139
139 for ctx in revgen(): 140 for ctx in revgen():
140 miss = 0 141 miss = 0
141 for q in qw: 142 for q in qw:
142 if not (q in ctx.user().lower() or 143 if not (q in lower(ctx.user()) or
143 q in ctx.description().lower() or 144 q in lower(ctx.description()) or
144 q in " ".join(ctx.files()).lower()): 145 q in lower(" ".join(ctx.files()))):
145 miss = 1 146 miss = 1
146 break 147 break
147 if miss: 148 if miss:
148 continue 149 continue
149 150