Preventing tbping spamming ?

[email protected] (sirloon) Tue, 20 Mar 2007 17:40:16 +0100
Newsgroups gmane.comp.python.zope.coreblog.english
Message-ID <[email protected]>
--===============2115496019==
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="WYTEVAkct0FjGQmd"
Content-Disposition: inline


--WYTEVAkct0FjGQmd
Content-Type: multipart/mixed; boundary="BXVAT5kNtrzKuDFl"
Content-Disposition: inline


--BXVAT5kNtrzKuDFl
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

I'm using CoreBlog2 0.9b for Plone, and I get spammed with trackback pingin=
g. I've disable trackback in my entries (cannot add/hidden), but I'm still =
receiving mail notifications. So I dig a little and found a possible bug (a=
t least annoyance), in the tbping python script:
 =20
  1. the script first sends mail notification
  2. then tries to add the trackback

I would have expected: try *then* notify. More, while adding trackback, the=
 script isn't interrested into the return value of addTrackback2Entry(). As=
 a result, event if the trackback is closed/hidden (that is, not open), the=
 script won't be aware about this error (addTrackback2Entry() will return N=
one), and will return a tbping_result with error code ok.

FWIW, attached is my customized tbping script.

Hope it helps,

Cheers,

Seb
--=20
S=E9bastien LELONG
sebastien.lelong[at]sirloon.net
http://www.sirloon.net
http://sirbot.org
"Syntactic sugar is just sugar, but it makes life tasty..."
:wq!

--BXVAT5kNtrzKuDFl
Content-Type: text/x-python; charset=us-ascii
Content-Disposition: attachment; filename="customized.py"
Content-Transfer-Encoding: quoted-printable

=66rom Products.CMFCore.utils import getToolByName
=66rom Products.CMFPlone.utils import log

cbtool =3D getToolByName(context, 'coreblog2_tool')

REQUEST =3D context.REQUEST
form =3D REQUEST.form
RESPONSE =3D context.REQUEST.RESPONSE
entry =3D context

excerpt =3D ''
if form.has_key('excerpt'):
    excerpt =3D form['excerpt']

title =3D cbtool.convert_charcode(form['title'])
blog_name =3D cbtool.convert_charcode(form['blog_name'])
excerpt =3D cbtool.convert_charcode(excerpt)

#Try to add trackback
try:
    if entry.addTrackback2Entry(title=3Dtitle,url=3Dform['url'],\
                            blog_name=3Dblog_name,excerpt=3Dexcerpt) is Non=
e:
        raise Exception("Unable to tbping. Trackback closed ?")

    #Send notify mail if need
    if context.getSend_trackback_notification():
        try:
            to_addr   =3D context.getNotify_to()
            from_addr =3D context.getNotify_to()
            msgbody =3D context.translate('trackback_notify_body')
            elements =3D {}
            for k in ('blog_name','title','excerpt','url','excerpt'):
                if form.has_key(k):
                    elements[k] =3D REQUEST.form[k]
                else:
                    elements[k] =3D ''
            elements['post_ip'] =3D REQUEST.getClientAddr()
            elements['entry_url'] =3D context.absolute_url()
            msgbody =3D msgbody % (elements)
            msgsubject =3D context.translate('trackback_notify_title')
            mgsheader =3D """To: %s
=46rom: %s
Mime-Version: 1.0
Content-Type: text/plain; Charset=3Dutf-8

""" % (to_addr,from_addr)
            cbtool.send_mail(mgsheader+msgbody, to_addr, from_addr, msgsubj=
ect)
        except Exception,e:
            log( 'COREBlog2/tbping: '
                     'Some exception occured, %s' % e )

    return context.tbping_result(client=3Dcontext,REQUEST=3DREQUEST,\
                                        error_code=3D0,message=3D'Thanks :-=
)')
except:
    return context.tbping_result(client=3Dcontext,REQUEST=3DREQUEST,\
                                    error_code=3D1,message=3D'Error occured=
=2E..')


--BXVAT5kNtrzKuDFl--

--WYTEVAkct0FjGQmd
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFGAA5wwi2+M5caSkYRAljeAJ9X2P+FNcrzN1WLRxTpHRDhSm1oNgCdGWVY
BW9mnGAvAMvZyOPLSdHZlw8=
=gCNR
-----END PGP SIGNATURE-----

--WYTEVAkct0FjGQmd--

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

_______________________________________________
COREblog-en mailing list
COREblog-en-/9qXvnWia/9Wk0Htik3J/[email protected]
http://postaria.com/mailman/listinfo/coreblog-en
Unsubscription writing to coreblog-en-leave-/9qXvnWia/9Wk0Htik3J/[email protected]
--===============2115496019==--