-
Notifications
You must be signed in to change notification settings - Fork 24
(FACT-2553) remove double backslashes from windows path #456
Conversation
@@ -65,7 +65,8 @@ def hash_to_facter_format(facts_hash) | |||
@log.debug('Remove quotes from parent nodes') | |||
pretty_json.gsub!(/\"(.*)\"\ =>/, '\1 =>') | |||
|
|||
pretty_json | |||
@log.debug('Remove double backslashes from paths') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is dangerous. UNC paths use double backslashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After JSON.generate all backslashes are doubled, this means that UNC paths now have 4 backslashes. I simply want to revert that by replacing 2 backslashes with one, resulting, in this case, that UNC paths will be 2 backslashes.
|
||
expect(formatted_output).to eq(expected_output) | ||
it 'formats path with double escaped backslashes' do | ||
expect(yaml_formatter.format(resolved_fact_list)).to eq(expected_output) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect the resolved fact to contain a string with single backslashes (like 'C:\Program Files\...'
), and have the formatter preserve that:
irb(main):003:0> puts YAML.dump('C:\Program')
--- C:\Program
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What you described is exactly the behaviour of Facter 4. When facter-ng is executed with '--yaml' backslashes are not doubled, the need to double them came from the fact that facter 3 prints doubled backslashes when is executed with '--yaml'
Co-authored-by: Bogdan Irimie <bogdan.irimie@puppet.com>
Description of the problem: On Windows facts that contains paths (like path and system32 fact) are double backslashed when facter is executed without any formatter. When facter is executed with --yaml argument the same facts (path and system32) are single backslashed instead of double backslashed.