Welcome to Office Zealot Sign in | Join | Help

Invalid characters and URLs in SharePoint

 

There's an existing body of knowledge regarding character and URL limitations for SharePoint Sites, Document Libraries and Lists, folders and file names.   There's a few more things I've learned that I want to add but I'll summarize the current information first.

 

Sources:

 

Site Names

 

  • In WSS Site Names may not contain the following characters: \ / : * ? " < > | # { } % & <TAB>" ~ +
  • You cannot start a site name, subsite name, or a site group name with an underscore (_) character or with the period character
  • You cannot use the period character consecutively in the middle of a site name, a subsite name, or a site group name
  • You cannot use the period character at the end of a site name, a subsite name, or a site group name

 

File Names

 

  • Invalid characters: " # % & * : < > ? \ / { | } ~ 
  • Cannot be longer than 128 characters
  • You cannot use the period character consecutively in the middle of a file name
  • You cannot use the period character at the end of a file name
  • You cannot start a file name with the period character

 

 

Folder Names

 

  • You cannot use the following characters anywhere in a folder name or a server name:  ~ # % & * { } \ : < > ? / | "
  • Cannot be longer than 128 characters
  • You cannot use the period character consecutively in the middle of a folder name
  • You cannot use the period character at the end of a folder name
  • You cannot start a folder name with the period character

 

Miscellaneous

 

  • The complete URL for the file or folder cannot be longer than 260 characters.  Note that this includes the server, site and library name.

 

What I've Learned…

 

My experiences lately have found some issues with the relationship between Document Library and List Titles and the resulting URLs that are created.  However, this is probably only relevant in the real world when you depend on display names and use the SDK.  Take this rule:

 

  • If a Document Library or List is given a title that contains a comma, any bracket, period or dash (  ,  (  )  . -  ), they will be removed from the URL.

 

That's obvious enough because you cannot have those characters in a URL, but they're usually translated to a URL friendly string (like %21 for an exclamation point).  What's surprising is that SharePoint removes them entirely from the URL.  So if you are writing a solution that takes user driven configuration settings to create a library for example, you need to know that the URL will be different than the value given to a library's title.  I found this out the hard way when I was building a complete destination file path for a file that was being uploaded from a client via a custom Web Service.  Basically the library was created first to hold the files that were being uploaded, and depending on the library title it quickly resulted in files being skipped because the actual URL that is required is different.

 

  • Issues with the conversion of a Document Library and List Title to a URL

 

The other issue with Document Library and List URLs is that the URL which derives from the library/list title will be truncated at 69 characters (yes, I've seen such long names in the real world).  The first 51 characters of the title are used for the URL, and any spaces are converted to %20 - but only the first 69 characters of the canonicalized string is used.  What's weird is that if you use nothing but numbers for the title, it's truncated at 49 characters!!  I'd experiment further but what's the point??

 

One last rule:

 

  • Document Libraries and List Titles cannot exceed 256 characters
Published Thursday, April 26, 2007 4:30 PM by legault
Filed under:

Comments

# File Name, Length, Size and Invalid Character Restrictions and Recommendations

Something that often comes up in deployments and migrations is what is allowed? What characters are supported.

Wednesday, June 27, 2007 3:38 PM by Joel Oleson's SharePoint Land

# Points to Share from Venkat Varkala &raquo; Naming onventions in SharePoint vs. Windows File System

# re: Invalid characters and URLs in SharePoint

I have had the task of creating new Document Libraries to match project names, and through trial and error, have come up with the following rules to convert the name of the Document Library to the URL (not including the server name etc, obviously):

Remove all the following characters:

'  :  (  )  -  /  &  .  @  +  !  #  [  ]  ,

This probably means that the following characters would also be automatically stripped out, but I just haven't come across these in a project name yet:

%  ~  *  {  }  \  <  >  ? / |  

Trim the resulting string to 50 characters.

Remove any trailing spaces.

Replace all the remaining spaces with %20

I wouldn't mind so much if this was properly documented somewhere, but if it is I certainly haven't been able to find it.

Wednesday, October 17, 2007 3:45 PM by sharvfish

# Cleaning invalid characters from SharePoint

I stumbled onto one of those &quot;gotchas&quot; you get with SharePoint. We were creating new document

Friday, April 25, 2008 7:13 AM by Community Blogs
Anonymous comments are disabled