Re: full-text v. regular expression userid searches (was: Re: [svn] GnuPG - r3867 - trunk/keyserver)

Jason Harris <[email protected]> Sat, 20 Aug 2005 08:13:32 -0400
Newsgroups gmane.comp.encryption.pgp.keyserver-folk,gmane.comp.gnu.gnupg.devel,gmane.comp.encryption.pgp.sks
Message-ID <[email protected]>
--===============0774497910==
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="q7oacCJraRPxsh4K"
Content-Disposition: inline


--q7oacCJraRPxsh4K
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Aug 19, 2005 at 10:55:06AM -0400, David Shaw wrote:
> On Fri, Aug 19, 2005 at 09:49:19AM -0400, Jason Harris wrote:

> > > Not that I'm suggesting regex searches.  I think they're overkill for
> > > the problem at hand.  Even LDAP doesn't do full regex.
> >=20
> > Well, allowing "anchoring" of the (full-word) searches with ^ and $
> > sounds like it would be a good start,
>=20
> Hard to do in a backwards compatible way, but at least it's not likely
> that people use ^ and $ at the beginning and end of their real user
> IDs.  Anyway, I can't say I think it's really necessary, but if SKS
> starts to support it, I'll add support for it in gpgkeys_hkp.

This applies after [email protected]/sks--mainline--1.0--patch-4=
4,
Enjoy:=20

--- orig/utils.ml
+++ mod/utils.ml
@@ -327,16 +327,13 @@
=20
 let substring_find ~sub string =3D=20
   try
-    for i =3D 0 to String.length string - String.length sub  do
-      try
-	for j =3D 0 to String.length sub - 1 do
-	  if string.[i+j] <> sub.[j] then raise Exit
-	done;
-	raise (Found i)
-      with
-	Exit -> ()
-    done;
-    -1
+    let string =3D String.lowercase string in
+    let sub =3D String.lowercase sub in
+    let re =3D Str.regexp sub in
+    try
+      let pos =3D Str.search_forward re string 0 in
+      raise (Found pos)
+    with Not_found -> raise (Found (-1))
+  -1
   with
-    Found i -> i
-     =20
+    Found pos -> pos

--=20
Jason Harris           |  NIC:  JH329, PGP:  This _is_ PGP-signed, isn't it?
[email protected] _|_ web:  http://keyserver.kjsl.com/~jharris/
          Got photons?   (TM), (C) 2004

--q7oacCJraRPxsh4K
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (FreeBSD)

iJ0EARECAF0FAkMHHmxWGGh0dHA6Ly9rZXlzZXJ2ZXIua2pzbC5jb206MTEzNzEv
cGtzL2xvb2t1cD9vcD1nZXQmc2VhcmNoPTB4RDM5REEwRTMmd2VoYXZleW91bm93
PXRydWUACgkQSypIl9OdoONDrwCffKoq4wSGj2DaeE34DTHuMC5g5ksAoI2XNfXB
LOW/tAT7fa6Q32gNDUFP
=exAT
-----END PGP SIGNATURE-----

--q7oacCJraRPxsh4K--

--===============0774497910==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
pgp-keyserver-folk mailing list
[email protected]
http://lists.kjsl.com/mailman/listinfo/pgp-keyserver-folk

--===============0774497910==--