Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/brianary/Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
brianary committed Sep 24, 2023
2 parents 232413d + d525625 commit 36f1f44
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ConvertTo-XmlElements.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Begin
elseif($InputObject -is [datetime])
{ [Xml.XmlConvert]::ToString($InputObject,'yyyy-MM-dd\THH:mm:ss') }
elseif($InputObject -is [string] -or $InputObject -is [char])
{ [Net.WebUtility]::HtmlEncode($InputObject) }
{ [Security.SecurityElement]::Escape($InputObject) }
elseif($InputObject -is [Hashtable] -or $InputObject -is [Collections.Specialized.OrderedDictionary])
{
if($Depth -gt 1) {$InputObject.Keys |ConvertTo-CompoundXmlElement -IsFirst:$IsFirst}
Expand Down
6 changes: 3 additions & 3 deletions Format-HtmlDataTable.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ and alternates the rows between pale yellow and white.
Begin
{
$odd = $false
if($OddRowBackground) {$OddRowBackground = [Net.WebUtility]::HtmlEncode($OddRowBackground) -replace '"','"'}
if($EvenRowBackground) {$EvenRowBackground = [Net.WebUtility]::HtmlEncode($EvenRowBackground) -replace '"','"'}
if($OddRowBackground) {$OddRowBackground = [Security.SecurityElement]::Escape($OddRowBackground)}
if($EvenRowBackground) {$EvenRowBackground = [Security.SecurityElement]::Escape($EvenRowBackground)}
}
Process
{
Expand All @@ -68,7 +68,7 @@ Process
else {$Html -replace '<td>([-$]?\d+(?:,\d{3})*(?:\.\d+)?)</td>','<td align="right">$1</td>'}
if($Html -like '*<table>*')
{
if($Caption) {$Html = $Html -replace '<table>',"<table><caption $CaptionAttributes>$([Net.WebUtility]::HtmlEncode($Caption))</caption>"}
if($Caption) {$Html = $Html -replace '<table>',"<table><caption $CaptionAttributes>$([Security.SecurityElement]::Escape($Caption))</caption>"}
if($TableAttributes) {$Html = $Html -replace '<table>',"<table $TableAttributes>"}
}
if($odd -and $OddRowBackground) {$Html -replace '^<tr>',"<tr style=`"background:$OddRowBackground`">"}
Expand Down
10 changes: 5 additions & 5 deletions Get-CharacterDetails.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ PasswordCategory
ActiveDirectory complexity rules typically require a character from at least
three of these fairly arbitrary categories.
HtmlEncode
The result of HTML-encoding the character using
System.Net.WebUtility.HtmlEncode().
XmlEscape
The result of XML-encoding the character using
System.Security.SecurityElement.Escape().
HtmlAttributeEncode
The result of HTML-encoding the character using
Expand Down Expand Up @@ -232,7 +232,7 @@ UnicodeBlock : BasicLatin
MatchesBlock : True
UnicodeCategory : ConnectorPunctuation
CategoryClasses : {Pc, P}
HtmlEncode : _
XmlEncode : _
HtmlAttributeEncode : _
UrlEncode : _
HttpUrlEncode : _
Expand Down Expand Up @@ -778,7 +778,7 @@ VerticalForms
UnicodeCategory = [char]::GetUnicodeCategory($c)
CategoryClasses = Find-UnicodeCategoryClass($c)
PasswordCategory = [PasswordCharacter]::GetCharacterType($c)
HtmlEncode = [Net.WebUtility]::HtmlEncode($c)
XmlEscape = [Security.SecurityElement]::Escape($c)
HtmlAttributeEncode = [Web.HttpUtility]::HtmlAttributeEncode($c)
UrlEncode = [Net.WebUtility]::UrlEncode($c)
HttpUrlEncode = [Web.HttpUtility]::UrlEncode("$c")
Expand Down
2 changes: 1 addition & 1 deletion Send-SqlReport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ try
{
$Msg.Add('Body',@"
$PreContent
<a href=`"$([Net.WebUtility]::HtmlEncode($ReportFile))`">$([Net.WebUtility]::HtmlEncode((Split-Path $ReportFile -Leaf)))</a>
<a href=`"$([Security.SecurityElement]::Escape($ReportFile))`">$([Security.SecurityElement]::Escape((Split-Path $ReportFile -Leaf)))</a>
$PostContent
"@)
}
Expand Down

0 comments on commit 36f1f44

Please sign in to comment.