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

the secedit export processing doesnt handle multiline strings #130

Open
robscott64 opened this issue Jan 23, 2023 · 0 comments
Open

the secedit export processing doesnt handle multiline strings #130

robscott64 opened this issue Jan 23, 2023 · 0 comments

Comments

@robscott64
Copy link

robscott64 commented Jan 23, 2023

if an element such as LegalNoticeText spans multiple lines then the output from the export looks like
MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System\LegalNoticeText=7,line 1
line2
line3
in order to process it as an inifile the set of lines need to be converted to the format where , are used to separate lines (any commas in the text have to appear as ",")

here is my proposed patch:

mkr-services# diff .orig/policy.rb .
50,51c50,51
<         # remove /r/n and remove the BOM
<         inffile_content = file.read.force_encoding('utf-16le').encode('utf-8', universal_newline: true).delete("\xEF\xBB\xBF")
---
>         # remove /r/n, the BOM, and make multiline strings into ,  sep single lines
>         inffile_content = file.read.force_encoding('utf-16le').encode('utf-8', universal_newline: true).delete("\xEF\xBB\xBF").gsub(/(^MACHINE(?:(?!MACHINE).)*?7,(?:(?:(?!MACHINE)[^\n])*?\n)*?)\nMACHINE/m) { |m| m.gsub(/\n(?!MACHINE)/m, ',') }

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

1 participant