Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Certain characters crash the notification system #32

Open
potatoqualitee opened this issue Dec 21, 2020 · 17 comments
Open

Certain characters crash the notification system #32

potatoqualitee opened this issue Dec 21, 2020 · 17 comments

Comments

@potatoqualitee
Copy link

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 🤔

@TylerLeonhardt
Copy link
Collaborator

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

@Windos
Copy link
Owner

Windos commented Dec 21, 2020

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

@MarvTheRobot
Copy link

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 ;)

@Windos
Copy link
Owner

Windos commented Dec 21, 2020

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

@potatoqualitee
Copy link
Author

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.

@Windos
Copy link
Owner

Windos commented Dec 21, 2020

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

@potatoqualitee
Copy link
Author

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
Copy link
Author

Ohh maybe it's .NET

@Windos
Copy link
Owner

Windos commented Dec 21, 2020

Hmm. That's a new one for me, and I can't repro 🤔

@MarvTheRobot
Copy link

@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.

@potatoqualitee
Copy link
Author

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
Copy link
Author

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.

@Windos
Copy link
Owner

Windos commented Dec 21, 2020

... 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.

@potatoqualitee
Copy link
Author

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 🤔

@Windos
Copy link
Owner

Windos commented Dec 21, 2020

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

@potatoqualitee
Copy link
Author

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

@vexx32
Copy link

vexx32 commented Dec 21, 2020

Format-Hex is the only way sometimes. 😔

Pesky control characters hidden in the string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants