Title: -Fix adding UTF-8 BOM to files · Issue #1743 · PowerShell/PSScriptAnalyzer · GitHub
Open Graph Title: -Fix adding UTF-8 BOM to files · Issue #1743 · PowerShell/PSScriptAnalyzer
X Title: -Fix adding UTF-8 BOM to files · Issue #1743 · PowerShell/PSScriptAnalyzer
Description: Steps to reproduce Create a file with a fixable violation Function Test-Function { param ( [String] $Password ) $Password } Run Invoke-ScriptAnalyzer -Path ./file.ps1 -Fix to fix the violation Expected behavior The violation is fixed but...
Open Graph Description: Steps to reproduce Create a file with a fixable violation Function Test-Function { param ( [String] $Password ) $Password } Run Invoke-ScriptAnalyzer -Path ./file.ps1 -Fix to fix the violation Expe...
X Description: Steps to reproduce Create a file with a fixable violation Function Test-Function { param ( [String] $Password ) $Password } Run Invoke-ScriptAnalyzer -Path ./file.ps1 -Fix to fix the violation Expe...
Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/1743
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"-Fix adding UTF-8 BOM to files","articleBody":"Steps to reproduce\r\n------------------\r\n\r\nCreate a file with a fixable violation\r\n\r\n```PowerShell\r\nFunction Test-Function {\r\n param (\r\n [String]\r\n $Password\r\n )\r\n\r\n $Password\r\n}\r\n```\r\n\r\nRun `Invoke-ScriptAnalyzer -Path ./file.ps1 -Fix` to fix the violation\r\n\r\nExpected behavior\r\n-----------------\r\n\r\nThe violation is fixed but the BOM isn't added to the file. It should preserve whatever is there already.\r\n\r\nActual behavior\r\n---------------\r\n\r\nThe violation is fixed but there is a UTF-8 BOM character added to the file\r\n\r\n```base\r\n# Before\r\n$ hexdump -C file.ps1\r\n\r\n00000000 46 75 6e 63 74 69 6f 6e 20 54 65 73 74 2d 46 75 |Function Test-Fu|\r\n00000010 6e 63 74 69 6f 6e 20 7b 0a 20 20 20 20 70 61 72 |nction {. par|\r\n00000020 61 6d 20 28 0a 20 20 20 20 20 20 20 20 5b 53 74 |am (. [St|\r\n00000030 72 69 6e 67 5d 0a 20 20 20 20 20 20 20 20 24 50 |ring]. $P|\r\n00000040 61 73 73 77 6f 72 64 0a 20 20 20 20 29 0a 0a 20 |assword. ).. |\r\n00000050 20 20 20 24 50 61 73 73 77 6f 72 64 0a 7d 0a | $Password.}.|\r\n0000005f\r\n\r\n# After running -Fix\r\n# hexdump -C file.ps1\r\n\r\n00000000 ef bb bf 46 75 6e 63 74 69 6f 6e 20 54 65 73 74 |...Function Test|\r\n00000010 2d 46 75 6e 63 74 69 6f 6e 20 7b 0a 20 20 20 20 |-Function {. |\r\n00000020 70 61 72 61 6d 20 28 0a 20 20 20 20 20 20 20 20 |param (. |\r\n00000030 5b 53 65 63 75 72 65 53 74 72 69 6e 67 5d 0a 20 |[SecureString]. |\r\n00000040 20 20 20 20 20 20 20 24 50 61 73 73 77 6f 72 64 | $Password|\r\n00000050 0a 20 20 20 20 29 0a 0a 20 20 20 20 24 50 61 73 |. ).. $Pas|\r\n00000060 73 77 6f 72 64 0a 7d 0a |sword.}.|\r\n00000068\r\n```\r\n\r\nNote the `ef bb bf` (UTF-8 BOM) present. I tried explicitly ignoring the rule `UseBOMForUnicodeEncodedFile` as well but the BOM is still added.\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\u003c!-- Provide the output of the following 2 commands -->\r\n\r\n```PowerShell\r\n> $PSVersionTable\r\n\r\nName Value\r\n---- -----\r\nPSVersion 7.2.0\r\nPSEdition Core\r\nGitCommitId 7.2.0\r\nOS Linux 5.14.16-201.fc34.x86_64 #1 SMP Wed Nov 3 13:57:29 UTC 2021\r\nPlatform Unix\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n\r\n> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }\r\n\r\n1.20.0\r\n```\r\n","author":{"url":"https://github.com/jborean93","@type":"Person","name":"jborean93"},"datePublished":"2021-11-11T01:40:13Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/1743"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:acf08d96-8869-bf15-194d-2829599c0b5a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8DA0:27FCA3:1BCEBC9:26CAA22:6AFD0823 |
| html-safe-nonce | 03f29dc38eafd6380700755496d01ff573a60cd1697a6c35178889260fdbdbfb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4REEwOjI3RkNBMzoxQkNFQkM5OjI2Q0FBMjI6NkFGRDA4MjMiLCJ2aXNpdG9yX2lkIjoiMTc2MjI5MzMwMDMwOTMyOTk1NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 4c24227bca128c45d245e8c522b9fdee48c26d9ec565d1c4d7f619c817b9ebc1 |
| hovercard-subject-tag | issue:1050485546 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PSScriptAnalyzer/1743/issue_layout |
| twitter:image | https://opengraph.githubassets.com/978572aeb74625551f9d8734fa8026e48bb12b2934f5d96194aeeec8ca2fce61/PowerShell/PSScriptAnalyzer/issues/1743 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/978572aeb74625551f9d8734fa8026e48bb12b2934f5d96194aeeec8ca2fce61/PowerShell/PSScriptAnalyzer/issues/1743 |
| og:image:alt | Steps to reproduce Create a file with a fixable violation Function Test-Function { param ( [String] $Password ) $Password } Run Invoke-ScriptAnalyzer -Path ./file.ps1 -Fix to fix the violation Expe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jborean93 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b29de2abb97b6307b16270785efeb58b51a117d5a9b659acf00b77aa00e7043b |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PSScriptAnalyzer git https://github.com/PowerShell/PSScriptAnalyzer.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 33149177 |
| octolytics-dimension-repository_nwo | PowerShell/PSScriptAnalyzer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33149177 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PSScriptAnalyzer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c9e619def6d670dc18a45d3b02cea938c1c7e47 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width