How can we set SafeAgainstScript attribute to true while adding SafeControl entries using WSPBuilder

Mar 7, 2012 at 6:22 AM

We are adding the safe control entries in the web.config file for our SharePoint 2010 application using wspbuilder.

The problem is that by default the safeagainstscript attribute is false when it add the entry. I want to set it to true using wspbuilder only.

How can we set SafeAgainstScript attribute to true while adding SafeControl entries using WSPBuilder?

Any help is highly appreciated.

Thanks,

Vijay

Jul 31, 2012 at 10:22 AM

Any news on this subject?? We also need settings this property to true.

Only option we see is to migrate to the new Project standaard for SP2010 solutions in Visual Studio, but we have a sln with 90+ projects...

Sep 13, 2012 at 8:53 AM

Powershell to the rescue:

function SetSafeAgainstScriptTrue($url)
{
	$webapp = Get-SPWebApplication $url
	
	$path = $webapp.IisSettings.get_Item(0).Path.FullName + "\web.config"
	$now = [datetime]::now.ToString('yyyy-MM-dd')
	Copy-Item $path "$path.$now"	
	Write-Host "Backupped"
	Write-Host "Modifying web.config file in path $path"
	(Get-Content $path) | 
		Foreach-Object {$_ -replace "SafeAgainstScript=`"False`"", "SafeAgainstScript=`"True`""} | 
	Set-Content $path
		
}