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

Eric Legault

Microsoft Outlook MVP (15 yrs). Author: Microsoft Office 2013 Pro Step By Step. Consultant/speaker/Outlook add-in builder/SharePoint pioneer. Guitarist: Maiden Canada (Iron Maiden tribute band)

You may also like...

1 Response

  1. Aakash Morya says:

    My document library was having – character. The library got created but when i tried creating folder withing that it throws me error for invalid file name. I was totally frustrated working 3 full days just to resolve the issue and 4th day I found this article and problem identified in 2 seconds and fixed in 5 minutes. I was working with codes to deal with SharePoint

    This is really a great article which should every developer must read.

    Really a great job :-)

%d bloggers like this: