Blog Video Url attachment with surrounding quotes detrimental

rated by 0 users
This post has 1 Reply | 1 Follower

Not Ranked
Posts 41
Points 700
Wayne Bynum Posted: Wed, Apr 4 2007 1:12 PM

In CS 2.1 SP2 if a user decides to enclose their video url in quotes then any page that tries to aggregate the post or display the post will fail on the call in the Post.cs file on public property VideoFileFormat.get() at line System.IO.Path.GetExtension(VideoUrl).  Not sure why the user tried this, but a good find for sure!

A good fix would be to check these fields on input for invalid characters.  I am not sure what I am going to do yet ... but I need a quick fix.

Wayne Bynum Application Developer
Not Ranked
Posts 41
Points 700

I performed a fix to "Components/Components/Post.cs" which is used by both Forums and Blogs for video inclusion in posts.  I made changes to properties VideoImageUrl and VideoUrl to check for and remove InvalidPathChars.  On a new install it would be feasible to only make changes to the "set", but to be sure I added the code to the "get" as well.

public string VideoUrl
{

  //begin check for invalid chars

  //get { return this.GetExtendedAttribute("VideoUrl"); }

  get

  {
    //doing this in case video urls already exist with invalid chars
    string videoUrl = this.GetExtendedAttribute("VideoUrl");
    if (videoUrl.Split(System.IO.Path.GetInvalidPathChars()).Length > 1)
    {
      foreach (char c in System.IO.Path.GetInvalidPathChars())
      {
        videoUrl = videoUrl.Replace(c.ToString(),
String.Empty);
      }
    }
    return videoUrl.Trim();
  }
  //set { this.SetExtendedAttribute("VideoUrl", value); }
  set
  {
    if (value.Split(System.IO.Path.GetInvalidPathChars()).Length > 1)
    {
      foreach (char c in System.IO.Path.GetInvalidPathChars()) 
      {
        value = value.Replace(c.ToString(), String.Empty);
      }
    }
    this.SetExtendedAttribute("VideoUrl", value.Trim()); 
  }
  //end check for invalid chars
}
 
public string VideoImageUrl
{
  //begin check for invalid chars
  //get
  //{
  // if (HasVideo && (this.GetExtendedAttribute("VideoImageUrl").Trim().Length <= 0))
  // return Globals.GetSkinPath() + "/images/video.gif";
  // return this.GetExtendedAttribute("VideoImageUrl");
  //}
  get
  {
    string imageUrl = this.GetExtendedAttribute("VideoImageUrl");
    if (imageUrl.Split(System.IO.Path.GetInvalidPathChars()).Length > 1)
    {
      foreach (char c in System.IO.Path.GetInvalidPathChars())
      { 
        imageUrl = imageUrl.Replace(c.ToString(),
String.Empty);
      }
    }
    if (HasVideo && (imageUrl.Trim().Length <= 0))
      return Globals.GetSkinPath() + "/images/video.gif";
    return imageUrl.Trim();
  }
//set { this.SetExtendedAttribute("VideoImageUrl", value); }
  set 
  {
    if (value.Split(System.IO.Path.GetInvalidPathChars()).Length > 1)
    {
      foreach (char c in System.IO.Path.GetInvalidPathChars())
      {
        value = value.Replace(c.ToString(), String.Empty);
      }
    }
    this.SetExtendedAttribute("VideoImageUrl", value.Trim());
  }
//end check for invalid chars
}

Wayne Bynum Application Developer
  • | Post Points: 5
Page 1 of 1 (2 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com