PermaLinkPurifying HTML In RSS Feeds
09:54:26 AM

In preparation for Lotusphere, I've been working on a revision of my Domino-based bloggregator RSS reader code, with the objective of putting a decent web UI onto it. The latest beta is here. (Comments welcome, but please note: it's a work in progress, and I'm doing things like changing the functionality, tweaking the CSS and blowing away all the data without warning, so if you try it and it's behaving very badly, that's the likely explanation.)


Spending time on the web UI again, however, has raised an issue that I knew existed in the previous version, but had mostly ignored. The web UI was so bad that I hardly ever used it, but now it's starting to look decent and I want to make it work well. The problem is that a lot of RSS feeds send garbled HTML in their artilce abstracts: e.g., unbalanced "div" or "span" tags (one too many closed tag, and suddenly one of my block level elements is prematurely closed!). And the flip side of this is some other RSS feeds that may send things like javascript and style sheets that can seriously mess up my presentation if they're not garbled! A related problem is that if I try to save some bandwidth by truncating the stream that comes from feeds that send full articles, perfectly good HTML can become garbled HTML, with unclosed tags, unclosed comments, unclosed quotes within tags, etc., and if that happens with an "img", an "a href", a "div", a "span" and in various other places it can have really nasty affects on the rendering of a page.

The solution is to "purify" the HTML, but how to do it? Right now I'm just doing an @ReplaceSubstring that finds certain opening and closing tags and inserts an underscore after the opening bracket. It deliberately mangles the HTML so that it is no longer HTML... but that approach is the sledghammer: it destroys some potentially useful markup as well as elminating harmful markup. It keeps my page's presentation intact, but it is distinctly unsatisfying to see the deliberately mangled HTML tags where the abstracts should be. Stripping all tags would probably be better, but that's also unsatisfying. An aggregator could do better than that. A more intelligent approach, however, is going to be a lot of work. Here's a list of things that I think a complete approach would need to do:


  • Detect and remove any tags that are closed without having been opened.
  • Detect and remove any script or style blocks.
  • Detect and fix any unclosed quotes for tag attributes
  • Detect and fix any truncated tags (missing the closing angle bracket)
  • Detect and fix any unclosed block-level tags, "img" tags, or "a href" tags


I actually think this could be done in column formulas now that we have the power of the ND6 formula language, but I doubt that it's a good idea to do it. I'm just guessing, but looping character-by-character through fields in a view that might have thousands of documents is probably a Bad Thing. The script that retrieves the RSS feed in the first place is probably the much better place to do it.

This page has been accessed 422 times. .
Comments :v

1. Stephan H. Wissel01/20/2005 12:39:05 PM
Homepage: http://www.wissel.net/


Hi Richard,
you might want to consider a staggered approach. The first scrub to appy to "dirty" HTML is jTidy: http://sourceforge.net/projects/jtidy
You either use a JavaAgent or LS2J. The parameters allow you to receive clean xHTML with all problems fixed. After that you could apply a XLST transformation (since xHTML is XML) that filters out the elements that you don't want (this way it is configurable). Question here: use a positive or negative list.
Like the idea? let me know!
stw




2. Richard Schwartz01/20/2005 01:17:26 PM
Homepage: http://smokey.rhs.com/web/blog/PowerOfTheSchwartz.nsf


Great idea, Stephen! I'll probably try this after 'sphere. I figured there had to be something like that out there, but I didn't find it when I searched. LS2J in my feed retrieval agent, or a Java webqueryopen agent should be possible. I don't think I'll do the XSLT though. It makes my brain hurt almost as much as Perl does.

-ich




3. Stephan H. Wissel01/21/2005 07:48:23 AM
Homepage: http://www.wissel.net


Hi Richerd,
(I'm ready to swap the the "e" for an "a" if you do the same *vbg*).
Glad you like the idea. And for the brain hurting: I could provide the sample XSLT sheets. I find XSLT cheaper that illegal drugs but the mind blowing effect is the same. Drop me an eMail when you are ready to go. And have fun on the Sphere.
stw




4. Stephan H. Wissel01/21/2005 10:27:38 AM
Homepage: http://www.wissel.net


Your quest might be shorter than you think. Once you figured out how to clean the html into valid xHTML using jTidy, head over to fromDomino.com and retrieve the XSLT template that does the filtering for you:
http://fromdomino.com/__48256E5A001AB060.nsf/d6plinks/PDWD-68UJ8Y
Specially designed for you.
stw




5. chenjinyan11/22/2016 02:52:13 AM
Homepage: http://


http://timberland.officialfree.net
http://timberlandboots.hugeoff.net
http://www.adidasoriginals.in.net
http://www.adidas.in.net
http://www.adidassuperstar.name
http://www.airjordan-pascher.fr
http://www.beatsbydrdresolo.us
http://www.celine-outlet.us
http://www.cheap-jordans.us.com
http://www.cheapjordansshoes.in.net
http://www.cheap--nfljerseys.us.com
http://www.cheapoakleysunglasses.net.co
http://www.cheaprolexwatches.name
http://www.christianlouboutin.name
http://www.christianlouboutinoff.us
http://www.christianlouboutinoutlet.com
http://www.louboutin.us.com
http://www.coachoutletstoreonlineclearances.us.com
http://www.edhardyclothing.in.net
http://www.ghdhairstraighteners.com.co
http://www.gucci-outlet.net.co
http://www.gucci-outlet.org
http://www.insanityworkout.cc
http://www.instylercurlingiron.com
http://www.jordan13.org
http://www.jordan3.net
http://www.jordan4.net
http://www.jordan6.net
http://www.jordan8.net
http://www.jordanconcords.net
http://www.jordanretro.name
http://www.cheapjordansshoes.us.com
http://www.kevindurantshoes.name
http://www.kobebryantshoes.name
http://www.kobeshoes.org
http://www.lebronjames-shoes.name
http://www.lebronjames-shoes.net
http://www.louboutinfemme-pascher.fr
http://www.louboutinshoes.cc
http://www.louisvuitton-handbags.com.co
http://www.louisvuittonlvoutlet.us.com
http://www.louis-vuittonoutlet.us.com
http://www.louis-vuittonoutlets.us.org
http://www.montblanc.com.co
http://www.montblanc-pens.name
http://www.nike-airmax.me.uk
http://www.nike-rosherun.in.net
http://www.outlet-celine.com
http://www.pandorajewelry.name
http://www.pandorajewelry.net.co
http://www.ralphlaurenpolo.in.net
http://www.raybansunglasses.uk
http://www.retrojordans.name
http://www.rolexwatchesoutlet.us
http://www.todsoutlet.in.net
http://www.toms-shoes.cc
http://www.true-religionjeans.us.org
http://www.truereligion-jeans.us
http://www.vansshoes.name
http://www.ralphlauren-outlet.net.co
http://www.michaelkorsoutletclearance.us.org
http://www.cheaprolexforsale.com
http://www.jordanshoes.us.org
http://www.michaelkorsoutlet-store.us.org
http://www.tomsshoes-outlet.com
http://www.basketballshoes.name
http://www.replicawatches.name
http://www.coachfactoryoutletmall.us.com
http://www.asicsshoes.name
http://www.outletsmichaelkors.us.com
http://www.tomswedges.us
http://www.rolexwatchesforsale.name
http://www.katespade.eu.com
http://www.designerhandbags.us.org
http://www.michael-korsbags.us.com
http://www.sunglassesoakley.com.co
http://www.cheapraybansunglasses.net.co
http://www.fitflopssaleclearance.us.org
http://www.coachclearance.us.com
http://www.tomssale.in.net
http://www.fitflops.org
http://www.cheaptoryburchoutlet.com
http://www.nfljerseyswholesales.us
http://www.raybansunglasses.me.uk
http://www.hollisterclothing.net
http://www.cheapjordansforsale.us
http://www.supra-shoes.net
http://www.truereligionjeans-outlet.us.com
http://www.rayban-sunglasses.com.co
http://www.oakley-sunglasses.net.co
http://www.oakleys-sunglasses.us.org
http://www.juicy-couture.us
http://www.louisvuittonofficial.us.com
http://www.truereligion.net.co
http://www.louisvuittonoutletstores.us
http://www.truereligion-jeans.com.co
http://www.north-faceoutlet.net.co
http://www.adidasoutletstore.net
http://www.adidasshoes.net
http://www.nikeoutletstore.us.com
http://www.coachfactoryoutlet-onlinestore.us.com
http://www.michaelkorsoutletcanada.com.co
http://www.oakleysunglassess.com.co
http://www.raybansunglassess.com.co
http://www.ray-ban-sunglasses.com.co
http://www.coachcanadaoutlet.com.co
http://www.coachfactoryoutletclearances.us.com
http://www.cheapoakleysunglassess.com.co
http://www.ralphlaurenoutletonline.in.net
http://www.hermesbagusa.com
http://www.burberryoutlet.in.net
http://www.raybansunglassesoutlet.net.co
http://www.michaelkorsuk.com.co
http://www.louboutinshoessale.com
http://www.abercrombieandfitchoutlet.in.net
http://www.abercrombieoutletonline.cc
http://www.hollistercoclothing.com
http://www.raybansonsale.com.co
http://www.tomsshoesuk.org.uk
http://www.authenticlouisvuittonhandbags.us.com
http://www.toms.us.org
http://www.ralphlaurenoutletuk.in.net
http://www.outletmichaelkorshandbags.us.com
http://www.longchamp.us.com
http://www.oakleyvaultoutlet.in.net
http://www.uggoutletsale.in.net
http://www.pandorajewelry.in.net
http://www.uggbootaustralia.us.com
http://www.ugg.eu.com
http://www.niketrainers.uk
http://www.canadagooseuk.uk
http://www.cheapuggboots.org.uk
http://www.uggslippers.com.co
http://www.uggsboots.us.org
http://www.canadagoosejacketsoutlet.us.com
http://www.cheapuggsboots.us.com
http://www.adidastrainers.uk
http://www.ugguk.me.uk
http://www.moncler.me.uk
http://www.monclerjacketsuk.me.uk
http://www.christianlouboutin-paris.fr
http://www.raybanpascher.fr
http://www.montblancpen.us.com
http://www.fitflopsuk.me.uk
http://www.nba-jerseys.us.com
http://www.longchamp-sac.fr
http://www.moncler--paris.fr
http://www.canadagoose-pascher.fr
http://www.newyorkknicksjerseys.us.com
http://www.newenglandpatriotsjerseys.us.com
http://www.cincinnatibengalsjerseys.us.com
http://www.uggboots-onsale.us.org
http://www.uggbootscheap.us.com
http://www.uggs.me.uk
http://www.curry3.name
http://www.mbt.us.com
http://www.adidasnmd-shoes.us.com
http://www.fitflops.us.com
http://www.rolexwatches.us.com
http://www.christianlouboutin-pas-cher.fr
http://www.nhljerseys.org
http://www.niketn-pascher.fr
http://www.louis-vuitton-borse.it
http://www.uggsaustralia.it
http://www.sanantoniospursjerseys.us.com
http://www.oklahomacitythunderjerseys.us.com
http://www.losangelesclippersjerseys.com
http://www.uggsbootsoutlet.us.org
http://www.thenorthface.net.co
http://www.canadagoose.com.co
http://www.adidas-yeezy.us.com
http://www.adidas-nmd.co.uk
http://www.christianlouboutinsale.me.uk
http://www.redbottoms.org.uk
http://www.timberlandboots.net.co
http://www.mlbjerseys.org
http://www.uggs-pascher.fr
http://www.monclerpascherhomme.fr
http://www.ugg-italia.it
http://www.seattleseahawksjerseys.us.com
http://www.minnesotavikingsjerseys.us.com
http://www.goldenstatewarriorsjerseys.us.com
http://www.washingtonwizardsjerseys.com
http://www.true-religion.me.uk
http://www.aididasyeezy.org.uk
http://www.ralphlaurenclearance.in.net
http://www.rosherun.org
http://www.ugg-boots.fr
http://www.uggbootsparis.fr
http://www.nike-airmaxpascher.fr
http://www.nike--rosherun.fr
http://www.louisvuittonparis.fr
http://www.jordanfemmepascher.fr
http://www.dallasmavericksjerseys.com
http://www.denverbroncosjerseys.us.com
http://www.pittsburghsteelersjerseys.us.com
http://www.tommyhilfigeroutlet.us.org
http://www.hogan-scarpe.it
http://www.bostoncelticsjerseys.com
http://www.clevelandcavaliersjerseys.us.com
http://www.miamiheatjerseys.us.com
http://www.chicagobullsjerseys.com
http://www.seattleseahawksjersey.us.com
http://www.clarisonic.com.co
http://www.louisvuittonoutletonlineshop.com
http://www.louisvuitton.de.com
http://www.louisvuitton.nom.co
http://www.louisvuitton.me
http://www.officialmichaelkorsoutlet.us.com
http://www.oakleysunglasses-outlet.com.co
http://www.pradahandbags.net
http://www.pradaoutlet.net.co
http://www.gucci--outlet.com.co
http://www.gucci.me.uk
http://oakley.sunglassesonline.us.com
http://www.canadagooseoutletsale.us.com
http://www.adidasyeezy350.us.com
http://www.oakleystore.com.co
http://www.cheapraybans.us.org
http://www.raybanssunglasses.com.co
http://www.coachfactoryoutlet-online.eu.com
http://www.louboutinshoesoutlet.co.uk
http://www.nikeoutletstores.us.com
http://www.michaelkors--outlet.com.co
http://www.uggoutletonline.in.net
http://www.raybanoutlet.net.co
http://www.louisvuitton-discount.com
http://www.uggbootscanada.ca
http://www.uggcheap.us.com
http://www.oakleysunglassescanada.ca
http://www.jordansforsale.in.net
http://www.michaelkorshandbagsonsale.com
http://www.airmaxssale.com
http://uggs.uggaustralia.qc.com
http://www.coachoutletstoreonlinesale.us.com
http://www.tiffanyandco.nom.co
http://www.katespadehandbagsoutlet.us.com
http://www.chanelbags.in.net
http://www.michaelkorsoutletstores.us.org
http://www.tiffanyandcojewelry.com.co
http://www.katespadeoutlets.us.com
http://www.gucci-outlet.in.net
http://www.poloralphlaurenukonline.co.uk
http://www.giuseppe-zanotti.us.com
http://www.louis-vuittonoutlet.eu.com
http://www.michaelkorsoutletofficial.us.com
http://www.gucci-inc.com
http://www.mulberryuk.org.uk
http://www.chaneloutlet.in.net
http://www.discountuggboots.us.com
http://www.uggaustralia.us.org
http://www.mcmbags.com.co
http://www.nikeoutlet-online.com
http://www.michael--korsoutlet.us.com
http://www.coachfactoryoutlet-online.us.org
http://www.coachoutletofficial.us.com
http://www.michaelkors--outlet.us.com
http://www.katespade-outlet.net.co
http://www.nikefactoryoutlet.org
http://www.tomsshoes.us.org
http://www.hollister.in.net
http://www.abercrombiefitch.us.com
http://www.ray-banssunglasses.com.co
http://www.northface.us.com
http://www.poloralph-lauren.us.org
http://www.hollister-uk.org.uk
http://www.prada.us.org
http://www.hilfigeroutlet.in.net
http://www.louis--vuitton.us.org
http://www.burberry-outletonline.com.co
http://www.uggsclearance.us.org
http://www.uggclassic.us.com
http://www.ugg-canada.ca
http://www.ugg-bootsuk.co.uk
http://www.ugg-outlet.ca
http://www.uggsuk.org.uk
http://www.uggoutlet.org
http://www.uggsoutletcheap.us.com
http://www.uggoutletdiscount.us.com
http://www.outletslouisvuitton.us.com
http://www.louisvuitton-outlet.ca
http://www.louisvuittonhandbagsoutlet.us.org
http://www.coachoutletcheap.us.com
http://www.outletcanadagoose.com.co
http://www.canadagoosecanada.com.co
http://www.gooseoutlet.us.com
http://www.outletcanadagoose.name
http://www.canadagoosecanada.us.org
http://www.louis-vuitton.me.uk
http://www.coachoutletonlinesale.eu.com
http://www.coachfactoryoutlet-stores.us.org
http://www.uggsoutlet-online.us.com
http://www.uggoutlet-stores.us.com
http://www.uggsoutletsale.us.com
http://www.outlet-uggboots.us.com
http://www.coachhandbagsnew.us.com
http://www.cheapuggssale.us.com
http://www.canadagooseca.us.com
201611.22chenjinyan




6. ylq jake08/17/2017 04:47:34 AM


http://www.rolex-watches.us.com/, http://www.bottega-venetasoutlet.com/, http://www.nike-airmaxs.fr/, http://www.raybans-outlet.com.co/, http://www.nike-free5.com/, http://www.nike-huarache.co.nl/, http://www.ferragamos.co.uk/, http://colts.nflvstore.com/, http://www.laurenralphs-outlet.co.uk/, http://pelicans.nba-jersey.com/, http://www.nike-store.com.de/, http://www.fredperrypolos.co.uk/, http://www.hollister-store.com.co.co/, http://www.mcmbackpacks.com.co/, http://www.bcbg-canada.ca/, http://www.pandora-charmscanada.ca/, http://www.converses-outlet.com/, http://hornets.nba-jersey.com/, http://www.beats-by-dre.com.co/, http://www.michael-kors.com.es/, http://www.kate-spadebags.com/, http://www.true-religionsoutlet.com/, http://www.adidassuper-star.de/, http://www.cheap-jerseys.mex.com/, , http://www.chiflatironhair.us.com/, http://www.fred-perry.org.uk/, http://www.nikefreerun-shoes.co.uk/, http://www.christianlouboutin-shoes.ca/, http://www.oakley-sunglasses2017.net/, http://www.tommyhilfigerca.ca/, http://www.tommyhilfigers.nl/, http://clippers.nba-jersey.com/, http://www.raybans.org.es/, http://www.bcbg-dresses.net/, http://www.long-champhandbags.com/, http://www.burberry-bagsoutlet.co.uk/, http://www.tommyhilfigers.de/, http://www.burberrysoutletstore.com/, http://grizzlies.nba-jersey.com/, http://raptors.nba-jersey.com/, http://www.nike-roshe-run.de/, http://www.longchampbags.com.co/, http://saints.nflvstore.com/, http://www.coach-outletonline.ca/, http://www.hollisterclothingcanada.ca/, http://www.vans-shoes.co.uk/, http://www.raybans-outlet.net.co/, http://knicks.nba-jersey.com/, http://www.michael-korsbags.com.co/, http://www.nike-shoesoutlet.us.org/, http://www.oakley-outletonline.com.co/, http://www.burberrys-bags.com/, http://www.burberry-storevip.com/, http://buccaneers.nflvstore.com/, http://www.nike-airmax.com.de/, http://www.converse-shoes.net/, http://www.uhren-stores.de/, http://thunder.nba-jersey.com/, http://patriots.nflvstore.com/, http://trailblazers.nba-jersey.com/, http://www.jeans-truereligion.com/, http://oakley.blackofriday.com/, http://pacers.nba-jersey.com/, http://www.jerseys-store.com/, http://www.crystals-swarovski.com/, http://www.michaelkors-ins.com/, http://www.jordan.com.de/, http://www.mlb-jerseys.us.com/, http://warriors.nba-jersey.com/, http://kings.nba-jersey.com/, http://magic.nba-jersey.com/, http://www.retrojordan-shoes.com/, http://www.australia-michaelkors.com/, http://www.christian-louboutinshoes.co.uk/, http://www.timberlandboots-outlet.com/, http://www.nikeshoes.org.es/, http://www.lacosteoutlet.com.co/, http://www.air-huarache-shoes.co.uk/, http://vikings.nflvstore.com/, http://www.swarovski-australia.com.au/, http://www.dsquared2-outlet.com/, http://www.north-faceoutletjacket.com/, http://www.salvatore-ferragamos.com/, http://www.beatsbydre.com.co/, http://redskins.nflvstore.com/,




Enter Comments^


Email addresses provided are not made available on this site.





You can use UUB Code in your posts.

[b]bold[/b]  [i]italic[/i]  [u]underline[/u]  [s]strikethrough[/s]

URL's will be automatically converted to Links


:-x :cry: :laugh: :-( :cool: :huh: :-) :angry: :-D ;-) :-p :grin: :rolleyes: :-\ :emb: :lips: :-o
bold italic underline Strikethrough





Remember me    

Monthly Archive
Responses Elsewhere



About The Schwartz

rss.jpg


All opinions expressed here are my own, and do not represent positions of my employer.