1
Vote

createNewDocumentWithProgID: special characters on savelocation url

description

Hi all,
there's an issue when I use TLC on a Document Library with special characters on its name (for example: "My 1° DocLib", please see the special character "°" ).
The issue is visible when you create a new document (word, excel...) using TLC. The new document is created correctly, word or excel opens using the template but when you click on Save the location points on desktop because webdav is unable to point to save location url.
 
The javascript method createNewDocumentWithProgID used inside Selector.aspx.cs (private method AddTemplates) is currently dynamically created using as second parameter (save location url) the targetFolderUrl variable (it refers to Request.UrlReferrer).
 
My suggestion (I have already locally fixed and tested) is to use a specific method of SPHttpUtility to encode the url in ECMA standard. This is the fix:
 
Microsoft.SharePoint.Utilities.SPHttpUtility.EcmaScriptStringLiteralEncode(targetFolderUrl)
 
This is the code before and after the correction...
BEFORE:
 
string navigateUrl = string.Format(
                @"javascript:createNewDocumentWithProgID('{0}/{1}', '{2}', 'SharePoint.OpenDocuments', false);window.frameElement.commitPopup();",
                fileItem.ParentList.ParentWeb.Url, fileItem.File.Url, targetFolderUrl);
 
AFTER:
 
string navigateUrl = string.Format(
                @"javascript:createNewDocumentWithProgID('{0}/{1}', '{2}', 'SharePoint.OpenDocuments', false);window.frameElement.commitPopup();",
                fileItem.ParentList.ParentWeb.Url, fileItem.File.Url, Microsoft.SharePoint.Utilities.SPHttpUtility.EcmaScriptStringLiteralEncode(targetFolderUrl));
 
Hope this helps.
Luca Ritossa

comments