Saving and sign script removes last charactor in script

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
jessondergaard
Posts: 2
Last visit: Tue Jan 16, 2024 11:56 pm

Saving and sign script removes last charactor in script

Post by jessondergaard »

To help you better we need some information from you.

Product, version and build: SAPIEN PowerShell Studio 2019, Version 5.6.160
32 or 64 bit version of product: 64 bit
Operating system: Windows 10 Enterprise 1709 OS Build 16299.1029
32 or 64 bit OS: 64 Bit

*** Please add details and screenshots as needed below. ***
When ever I save my script on PowerShell Studio it removes at last charactor in the script.
It seems to be related to the automatic signing of the script.
However it does not happen when I just select "Sign Script".
If I remove the setting to automatically sign the script on save, the error is gone.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Saving and sign script removes last charactor in script

Post by davidc »

Is the file using Unix line ends?
David
SAPIEN Technologies, Inc.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Saving and sign script removes last charactor in script

Post by davidc »

If you are using Unix line endings, the signing process unfortunately chops the last line because it expects and uses Windows line ends.
I will ask the Dev team to look into it, but since the signing process is external, I'm not sure there much we can do.
David
SAPIEN Technologies, Inc.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Saving and sign script removes last charactor in script

Post by davidc »

I confirmed this also occurs if you use the Set-AuthenticodeSignature cmdlet.
David
SAPIEN Technologies, Inc.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Saving and sign script removes last charactor in script

Post by Alexander Riedel »

It's a bug in the WIndows API basically, it assumes that ALL files are CR/LF and acts accordingly. We will see what we can do as a workaround.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
jessondergaard
Posts: 2
Last visit: Tue Jan 16, 2024 11:56 pm

Re: Saving and sign script removes last charactor in script

Post by jessondergaard »

I have now changed the file to use Windows CRLF line ends and then the problem is gone.
I was not aware of this, an actually not sure why the files was in Unix format. So this workaround is good enough for me.

Thank you for your quick help on this.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Saving and sign script removes last charactor in script

Post by davidc »

We made some changes to hopefully work around the issue in case someone else uses Unix line endings.
David
SAPIEN Technologies, Inc.
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Saving and sign script removes last charactor in script

Post by davidc »

We released the v5.6.161 service build that includes the work around.
David
SAPIEN Technologies, Inc.
This topic is 4 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.