Bug with comments and GraffitiCMS

One bug with Graffiti that's been driving me nuts ever since I started using the app over a year ago is that it assumes that a commenter will naturally add the http:// to the beginning of their website name. If they don't, the code that displays the comment later will force the URL to be absolute (essentially by prepending the Graffiti application's base URL to the name). Of course that link is then nonsense and leads to a 404 if someone clicks on it later.

Since I use Scott Cate's 404 manager, I see the common 404s as they accumulate, and these comment website errors have been driving me nuts.

So, I've fixed all the comments that needed fixed on the site (I used SQL Server Management Studio rather than the Graffiti admin interface) and now I've fixed the code that saves a comment. If you have downloaded the source and upgraded your site the fix is pretty simple. Find comments.cs in the Data folder of Graffiti.Core and change the code that sets up the WebSite property to:

        else {
          if (!string.IsNullOrEmpty(WebSite)) {
            WebSite = HttpUtility.HtmlEncode(WebSite).Trim();
            if (!WebSite.StartsWith("http://", true, null)) {
              WebSite = String.Format("http://{0}", WebSite);
            }
          }

          if (!string.IsNullOrEmpty(Email))
            Email = HttpUtility.HtmlEncode(Email);

In other words instead of just HTML encoding it, encode it, trim, and make sure it starts with http://. Build, copy the new DLLs to the bin folder of your web site, and you're done.

(Note: OK, OK, the test should be a little more sophisticated since it will screw up URLs that use another scheme apart from http. Hasn't happened yet though.)

Album cover for Eccentrix RemixesNow playing:
Yello - On Track [Doug Laurent's First Journey]
(from Eccentrix Remixes)



Posts on similar topics...

No Responses

Feel free to add a comment...

Leave a Response

Some MarkDown is allowed, but HTML is not. (Click to learn more.)

  • Emphasize with italics: surround word with underscores _emphasis_
  • Emphasize strongly: surround word with double-asterisks **strong**
  • Inline code: surround text with backticks `IEnumerable`
  • Unordered list: start each line with an asterisk, space * an item
  • Ordered list: start each line with a digit, period, space 1. an item
  • Insert code block: start each line with four spaces
  • Insert blockquote: start each line with right-angle-bracket, space > Now is the time...

Search

About Me

I'm Julian M Bucknall, the M because it's my middle initial and because I and the other Julian Bucknall (the movie guy) would like to differentiate ourselves.

I'm a programmer by trade, an actor by ambition, and an algorithms guy by osmosis. I write articles for PCPlus in my spare time, not that there's much of that.

Julian M Bucknall Apart from that, an ex-pat Brit, atheist, microbrew enthusiast, Pet Shop Boys fanboy, slide rule and HP calculator collector, amateur photographer, Altoids muncher.

DevExpress

I'm Chief Technology Officer at Developer Express, a software company that writes some great controls and tools for .NET and Delphi. I'm responsible for the technology oversight and vision of the company.

Validation

Validate markup as HTML5 (beta)     Validate CSS

Bottom swirl

Archives

February 2012 (6)
SMTWTFS
« Jan  
1234
567891011
12131415161718
19202122232425
26272829

Like this Archive Calendar widget? Download it here.

Social networking

Google ads

The OUT Campaign

The OUT Campaign

My Tweets

  • LOL! RT @secretGeek: Watching the NoCss movement gain momentum
  • Blog post: More on caring less about clichés, or not http://t.co/P1Unt4y9
  • @peterritchie Oh my god, the HAIR! It's all over his head! Ewwww. /cc @MillerMark
Bottom swirl