PoshNotify icon indicating copy to clipboard operation
PoshNotify copied to clipboard

Certain characters crash the notification system

Open potatoqualitee opened this issue 5 years ago β€’ 17 comments

Hello! I have a chatbot and when the following text is sent, it crashes my whole bot.

" ☺ACTION πŸ‘€ New FOLLOW(S) ❀ username ❀, WELCOME! (1255 followers) (+19).☺"

We think it's that smiley πŸ€”

potatoqualitee avatar Dec 21 '20 17:12 potatoqualitee

Interesting... What OS is this? This module doesn't do much beyond turning around and calling into another PowerShell module per-platform.

TylerLeonhardt avatar Dec 21 '20 18:12 TylerLeonhardt

Mac from my understanding.

@potatoqualitee Are you able to try with the raw MacNotify module (should already be installed as a dependency of this module)?

Function to use would be Invoke-AlerterNotification

Windos avatar Dec 21 '20 18:12 Windos

This was on Windows 10; @potatoqualitee 's bot sends the message to PoshNotify and then gets an exception to do with XML. I'll take a look later too.

Not sure if she recorded her str but it's on there ;)

MarvTheRobot avatar Dec 21 '20 19:12 MarvTheRobot

If it was Windows 10, @potatoqualitee, which version of PowerShell was it?

I have a hunch what the issue will be in Windows... but it won't be the emoji πŸ˜„

image

Windos avatar Dec 21 '20 19:12 Windos

Thank you, everyone! Such a fast response 😊 I arm running PS version 5.1.19041.610

Maybe I need to throw a .Trim() on that? Something about the /me on Twitch is killing the notifier.

potatoqualitee avatar Dec 21 '20 19:12 potatoqualitee

If you've got a copy of the error handy (even a screenshot from the stream), I can dive in a bit

Windos avatar Dec 21 '20 19:12 Windos

It's the weirdest error, but doesn't happen if I remove the notify

PSMessageDetails      :
Exception             : System.Management.Automation.RuntimeException:
                        Cannot read stream: Exception calling "LoadXml" with
                        "1" argument(s): "Exception from HRESULT: 0xC00CE508"
TargetObject          : Cannot read stream: Exception calling "LoadXml" with
                        "1" argument(s): "Exception from HRESULT: 0xC00CE508"
CategoryInfo          : OperationStopped: (Cannot read str...LT:
                        0xC00CE508":String) [], RuntimeException
FullyQualifiedErrorId : Cannot read stream: Exception calling "LoadXml" with
                        "1" argument(s): "Exception from HRESULT: GetStream 0xC00CE508"
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Wait-TvResponse<Process>, <No file>: line 102
                        at Start-TvBot<Process>, <No file>: line 86
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}

how it's related, I have no idea

potatoqualitee avatar Dec 21 '20 19:12 potatoqualitee

Ohh maybe it's .NET

potatoqualitee avatar Dec 21 '20 19:12 potatoqualitee

Hmm. That's a new one for me, and I can't repro πŸ€”

Windos avatar Dec 21 '20 19:12 Windos

@potatoqualitee; what happens if you send just the string to PoshNotify? I was going to test but I don't think your latest code is up.

MarvTheRobot avatar Dec 21 '20 19:12 MarvTheRobot

I'll try that on stream momentarily - I just pushed the code to a PR https://github.com/potatoqualitee/tvbot/pull/7/files#diff-3d86d59729663fe1cebc7fca9f571b09cdf789a4d106d0ddbf2e6c71a36301e0R52

potatoqualitee avatar Dec 21 '20 19:12 potatoqualitee

ah ha!

Send-OSNotification -Title gzb -Body "< sup"
Exception calling "LoadXml" with "1" argument(s): "Exception from HRESULT: 0xC00CE513"
At C:\Users\ctrlb\Documents\WindowsPowerShell\Modules\PoshNotify\0.1.3\Private\Pop-WindowsNotification.ps1:46 char:5
+     $ToastXml.LoadXml($XmlString)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : Exception

Exception calling "Show" with "1" argument(s): "The parameter is incorrect.
The parameter is incorrect.

potatoqualitee avatar Dec 21 '20 21:12 potatoqualitee

... I need to escape some shiz πŸ˜›

In all seriousness, I'd originally made it so that this didn't need to take a dependency on BurntToast. That will change now to fix the 7.1+ issue... and it should also fix this.

Windos avatar Dec 21 '20 21:12 Windos

thank you! we ended up escaping and fixing that issue but now we're back to working on .. if we type out emojis it works, but if it's passed emojis by the parsed IRC output, it dies πŸ€”

potatoqualitee avatar Dec 21 '20 21:12 potatoqualitee

Hmm. Any visible difference on the string being passed into Title/Body?

Windos avatar Dec 21 '20 22:12 Windos

we figured it out!! well, @vexx32 did :D :D :D :D :D let me get you the code that we used

$xml = [System.Security.SecurityElement]::Escape($message)
$string = $xml -replace '\x01'
Send-OSNotification -Title $user -Body $string

potatoqualitee avatar Dec 21 '20 22:12 potatoqualitee

Format-Hex is the only way sometimes. πŸ˜”

Pesky control characters hidden in the string.

vexx32 avatar Dec 21 '20 22:12 vexx32