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

Get-M365DSCDRGComplexTypeToString: Special characters not handled correctly for Convert-DSCStringParamToVariable #5623

Closed
mlhickey opened this issue Jan 13, 2025 · 4 comments · Fixed by #5848 or #5881

Comments

@mlhickey
Copy link
Contributor

mlhickey commented Jan 13, 2025

Description of the issue

When Get-M365DSCDRGComplexTypeToString resolves fancyDoubleQuotes at 480:

if ($null -ne $currentProperty) { $fancySingleQuotes = "[\u2019\u2018]" $fancyDoubleQuotes = "[\u201C\u201D]" $currentProperty = [regex]::Replace($currentProperty, $fancySingleQuotes, "''") $currentProperty = [regex]::Replace($currentProperty, $fancyDoubleQuotes, '"') }
it results in broken strings when the fancyDoubleQuotes are located inside the string. Example string:
'
WÓJCIK - VENTILATION S.A.
'
where the double-quote is a UTF8 double-quote. This causes Convert-DSCStringParamToVariable to terminate the string early :
Convert-DSCStringParamToVariable: Exception calling "IndexOf" with "2" argument(s): "Index was out of range. Must be non-negative and less than or equal to the size of the collection. (Parameter 'startIndex')"

Microsoft 365 DSC Version

DEV/1.25.108.1

Which workloads are affected

other

The DSC configuration

Verbose logs showing the problem

Environment Information + PowerShell Version

@FabienTschanz
Copy link
Collaborator

@mlhickey Do you have a sample configuration that we can use to check and fix it? Or quickly explain the steps to reproduce? We're currently working on an updated way to handle the exports, so it would be great if we can consider this issue in there too.

@mlhickey
Copy link
Contributor Author

mlhickey commented Jan 17, 2025 via email

@martincaddick
Copy link
Contributor

@FabienTschanz
Probably related.

Exporting this morning using 1.25.219.2

=== Error1 ====

    <FilePublisherRule Id=`"nnnn`" Name=`"MAXTHON.EXE, in MX5, from O=MAXTHON TECHNOLOGY CO, LTD., L=北京, S=北京, C=CN`" Description=`"`" UserOrGroupSid=`"S-1-5-32-544`" Action=`"Deny`">
      <Conditions>
        <FilePublisherCondition PublisherName=`"O=MAXTHON TECHNOLOGY CO, LTD., L=北京, S=北京, C=CN`" ProductName=`"MX5`" BinaryName=`"MAXTHON.EXE`">
          <BinaryVersionRange LowSection=`"*`" HighSection=`"*`" />
        </FilePublisherCondition>
      </Conditions>
    </FilePublisherRule>

=== Error2 ====

    <FilePublisherRule Id=`"xxxxx`" Name=`"PALEMOON.EXE, in PALE MOON, from O=MARK STRAVER, L=TRANÅS, S=JÖNKÖPINGSLÄN, C=SE`" Description=`"`" UserOrGroupSid=`"S-1-5-32-544`" Action=`"Deny`">
      <Conditions>
        <FilePublisherCondition PublisherName=`"O=MARK STRAVER, L=TRANÅS, S=JÖNKÖPINGSLÄN, C=SE`" ProductName=`"PALE MOON`" BinaryName=`"PALEMOON.EXE`">
          <BinaryVersionRange LowSection=`"*`" HighSection=`"*`" />
        </FilePublisherCondition>
      </Conditions>
    </FilePublisherRule>

@FabienTschanz
Copy link
Collaborator

FabienTschanz commented Feb 21, 2025

@martincaddick What's the resource you're exporting? And how should it look like to be correct?

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