EvotecIT / PSTeams

PSTeams is a PowerShell Module working on Windows / Linux and Mac. It allows sending notifications to Microsoft Teams via WebHook Notifications. It's pretty flexible and provides a bunch of options. Initially, it only supported one sort of Team Cards but since version 2.X.X it supports Adaptive Cards, Hero Cards, List Cards, and Thumbnail Cards. All those new cards have their own cmdlets and the old version of creating Teams Cards stays as-is for compatibility reasons.
MIT License
409 stars 41 forks source link

New-TeamsFact ignores literal string as values and/or eats slashes #12

Closed weq closed 4 years ago

weq commented 4 years ago
$section_info = New-TeamsSection {
    New-TeamsFact -name "test" -value "test\"
    New-TeamsFact -name "test" -value "test\\"
    New-TeamsFact -name "test" -value "test\\\"
    New-TeamsFact -name "test" -value 'test\'
    New-TeamsFact -name "test" -value 'test\\'
    New-TeamsFact -name "test" -value 'test\\\'
    New-TeamsFact -name "test" -value "\test\"
    New-TeamsFact -name "test" -value '\test\'
    New-TeamsFact -name "test" -value "\\\\te\\st\\"
    New-TeamsFact -name "test" -value '\\\\\\test\\123'

}
$message = @{
    uri = $teamsID
    messageTitle = "crap"
    sections = $section_info
}
Send-TeamsMessage @message

image

It behaves the both with single quotes and double quotes and just eats slashes depending on where they are.

PrzemyslawKlys commented 4 years ago

The output created by PSTeams seems to be correct. It looks like Teams Hooks are doing the removal and I believe it's simply "escaping" special chars, just like you would normally do.

VERBOSE: Send-TeamsMessage - Execute 1 Body

{
    "sections":  [
                     {
                         "facts":  [
                                       {
                                           "name":  "test",  
                                           "value":  "test\\"
                                       },
                                       {
                                           "name":  "test",  
                                           "value":  "test\\\\"
                                       },
                                       {
                                           "name":  "test",
                                           "value":  "test\\\\\\"
                                       },
                                       {
                                           "name":  "test",
                                           "value":  "test\\"
                                       },
                                       {
                                           "name":  "test",
                                           "value":  "test\\\\"
                                       },
                                       {
                                           "name":  "test",
                                           "value":  "test\\\\\\"
                                       },
                                       {
                                           "name":  "test",
                                           "value":  "\\test\\"
                                       },
                                       {
                                           "name":  "test",
                                           "value":  "\\test\\"
                                       },
                                       {
                                           "name":  "test",
                                           "value":  "\\\\\\\\te\\\\st\\\\"
                                       },
                                       {
                                           "name":  "test",
                                           "value":  "\\\\\\\\\\\\test\\\\123"
                                       }
                                   ]
                     }
                 ],
    "title":  "crap",
    "summary":  "crap"
}
weq commented 4 years ago

Urk yeah you are right.. I saw at this a tad quickly on it as suspected it first being an encoding issue or something.