Special Character Restrictions In Sharepoint – Why They Exist And How To Work Around Them

Why SharePoint Restricts Special Characters

SharePoint places restrictions on special characters for several important reasons related to functionality, compatibility, and security:

  • Special characters can break functionality or cause unexpected behavior in SharePoint sites, lists, libraries, and other components. For example, the percent (%) sign is used for encoding in URLs, so it can cause issues if used in file or folder names.
  • Special characters can cause compatibility problems with certain browsers, client applications, or devices when accessing SharePoint. Some characters are handled differently across platforms and may not render correctly.
  • Special characters open up security risks like cross-site scripting (XSS) or code injection attacks. SharePoint blocks certain characters to help prevent malicious input.
  • Special characters can impact performance. SharePoint tries to minimize special character use to optimize speed and efficiency behind the scenes in areas like caching, indexing, and queries.
  • Some special characters go against SharePoint best practices around metadata standards, naming conventions, taxonomy guidelines, etc. Restricting them helps ensure consistency.

In summary, character restrictions aim to provide the best SharePoint experience possible in terms of functionality, compatibility, security, performance, and best practices.

Understanding Character Restrictions in SharePoint

SharePoint applies character restrictions across many different areas, including:

  • File and folder names
  • Page titles, column names, and other site components
  • Managed metadata fields and column values
  • User profiles and user-related fields like logins
  • List items and document properties
  • Query strings and encoded URLs

The specific characters that are restricted depends on the context, but some that are frequently blocked include:

  • Percent (%) sign
  • Ampersand (&) symbol
  • At (@) sign
  • Number (#) sign
  • Caret (^) symbol
  • Plus (+) sign
  • Equal (=) sign
  • Colon (:)
  • Asterisk (*)
  • Backslash (\\)
  • Forward slash (/)
  • Question mark (?)
  • Less than (<) and greater than (>) signs
  • Brackets ([ ])
  • Curly braces ({ })
  • Single quotation marks (‘)
  • Double quotation marks (“)

These kinds of special characters may be fully restricted in some places and only allowed in certain quantities in others. For example, file names can include some punctuation like dashes (-) and underscores (_), but other symbols like asterisks are blocked entirely.

Common Characters That Cause Issues

While many special characters can lead to issues in SharePoint, the most common problem characters are:

  • Percent (%) sign – Often causes broken functionality or display issues. Problematic due to URL encoding conflicts.
  • Ampersand (&) symbol – Can sometimes break features or be exploited for attacks. Used for encoding.
  • Number (#) sign – May cause errors with links and navigation when used in page names or URLs.
  • Forward slash (/) and backward slash (\\) – File paths don’t allow these characters which can prevent uploads or references.
  • Apostrophe (‘) and quotation marks (“) – Can interfere with string literals used in column values, metadata, etc.
  • Brackets ([ ]) and braces ({ }) – Special meaning for code blocks, regex, etc. so SharePoint blocks them.
  • Plus (+) sign – Sometimes interpreted as a space, so it can confuse searches or content processing.
  • Less than (<) and greater than (>) signs – Risk for exploitation as they have special meaning in languages like HTML.

As a rule of thumb, avoid using any symbol, punctuation, non-standard character, or special operator in SharePoint structure, metadata, or content if possible. Standard letters, numbers, hyphens, underscores, and spaces are best for maximum compatibility.

When Special Characters Break Functionality

Special characters can manifest in different SharePoint problems including:

  • Display Issues – Weird characters, question marks, or boxes showing instead of content.
  • Broken Links – URLs or referenced files not working due to encoding conflicts.
  • Incorrect Search Behavior – Items not appearing properly in search, failed queries, etc.
  • Upload or Sync Failures – Files not uploading to libraries from clients or syncing to OneDrive.
  • Interoperability Problems – Issues opening files, interacting with workflows, or using SharePoint from other Office apps.
  • Form Validation Errors – Metadata inputs rejected. Problems saving item properties or column values.
  • Security Warnings – Blocked inputs, stripped characters, or error messages to prevent attacks.

In many cases, functionality breaks because SharePoint is designed to simply reject, block, or fail on special characters it doesn’t understand or perceives as risky rather than try to interpret them. The system takes a “block first, ask questions later” approach to unusual inputs.

Working Around Character Restrictions

When faced with SharePoint’s character limitations, there are a few common workarounds including:

  • Substitute restricted characters – Swap problematic characters with allowed ones like hyphens (-) or underscores (_).
  • Remove restricted characters completely – Strip them out rather than replace them if possible.
  • Encode restricted characters – Use URL encoding (%20 for spaces for example) to sneak some past filters.
  • Alter related naming conventions – Rename files, lists, columns etc. to avoid special characters.
  • Adjust input validation settings – Sometimes character restrictions can be changed or configured differently.
  • Use character aliases – Work with values copied from canonical forms without special characters.

However, the best approach is to avoid restricted characters entirely when possible rather than relying on workarounds which may be inconsistent across SharePoint versions and scenarios.

Best Practices for Special Characters

When working in SharePoint, adhere to these special character best practices:

  • Audit site content and infrastructure to inventory occurrences of restricted characters.
  • Replace risky special characters with more standard alternatives like hyphens, spaces underscores when practical.
  • Normalize metadata values, file names, URLs, and other components to eliminate special characters.
  • Prefix special character sequences like forward slashes (/) with underscores (_) or another character to prevent issues.
  • Use canonical or alias versions for filenames and metadata values instead of special characters.
  • If maintaining special characters, escape them with markup like URLs to avoid functionality issues.
  • Encode values submitted to search to account for differences in special character handling.
  • Consider purging old content with special characters not handled by latest SharePoint releases.
  • Always test to confirm whether special characters break anything prior to SharePoint changes.

Applying best practices for managing special characters proactively can help mitigate issues down the road as SharePoint platform restrictions continue to evolve.

Example Code for Replacing Restricted Characters

Here is some sample C# .NET code for removing or replacing restricted characters from strings in SharePoint:

using System.Text.RegularExpressions;

namespace SharePointCharacterReplacement {

  class Program {
 
    static string RemoveRestrictedCharacters(string input) {
      String regex = "[/%&=+\s]#";
      return Regex.Replace(input, regex, ""); 
    }

    static string ReplaceRestrictedCharacters(string input) {
      String regex = "[/%&=+]#";
      return Regex.Replace(input, regex, "-");
    }

  }

}

Key points about the code:

  • It imports regex capabilities from System.Text.RegularExpressions.
  • The RemoveRestrictedCharacters method strips out symbols like %, /, &, =, +, spaces, and # completely.
  • The ReplaceRestrictedCharacters method swaps those characters with hyphens instead of removing them.
  • The regex can be adjusted to target other special characters that need replaced.
  • Custom logic can be added for encoding certain characters instead of replacing them.

This allows standardized preprocessing of SharePoint metadata, filenames, URLs etc. to avoid issues with restricted characters programmatically on upload, update, etc.

Frequently Asked Questions

Here are some common questions around SharePoint and special characters:

Why are special characters I enter getting stripped out or changed?

SharePoint automatically filters out some special characters on input to prevent potential issues. It changes or blocks them without notice behind the scenes rather than allowing potential problems.

What are some examples of special SharePoint character restrictions?

Common examples are blocking percent signs (%) in filenames, stripping apostrophes (‘) from wiki content, failing on ampersands (&) in column values, not allowing forward slashes (/) in page names, etc. Many symbols and punctuation are restricted.

Where is the list of all restricted SharePoint special characters?

Microsoft does not publish a definitive list, but the most commonly blocked characters are %, /, \, &, +, =, #, [, ], {, }, ‘, “, :, <, >, ?, |, and ~. The restrictions depend on location and context.

Can I get around SharePoint special character limitations?

Workarounds exist like encoding values or substituting restricted characters, but avoiding them entirely is better. Character filters evolve across SharePoint versions, so replacements may break over time or have unintended consequences.

Leave a Reply

Your email address will not be published. Required fields are marked *