Skip to content

Conversation

@rcorredera
Copy link

I find out some values can be empty, so I changed the Regex to manage this case.

rcorredera and others added 2 commits October 6, 2017 11:52
It can happen that registry values are juste used for their names.
(For UpgradesCodes for example)
lib/registry.js Outdated

/* registry item pattern */
, ITEM_PATTERN = /^(.*)\s(REG_SZ|REG_MULTI_SZ|REG_EXPAND_SZ|REG_DWORD|REG_QWORD|REG_BINARY|REG_NONE)\s+([^\s].*)$/
, ITEM_PATTERN = /^(.*)\s(REG_SZ|REG_MULTI_SZ|REG_EXPAND_SZ|REG_DWORD|REG_QWORD|REG_BINARY|REG_NONE)(\s+([^\s].*)){0,1}$/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{0, 1} can be replaced by ?.

@alexanderturinske
Copy link

@fresc81

@cwalther
Copy link

cwalther commented Dec 2, 2019

I just ran into the same bug, however your solution does not work for me. It gives me undefined instead of the expected empty string for empty REG_SZ values. It also still doesn’t properly handle names and values that start or end with spaces.

My version of reg.exe (10.0.18362.476) appears to use exactly four spaces as delimiters, so this works for me (in combination with removing some unjustified trim()s):

ITEM_PATTERN  = /^    (.*)    (REG_SZ|REG_MULTI_SZ|REG_EXPAND_SZ|REG_DWORD|REG_QWORD|REG_BINARY|REG_NONE)    (.*?)[\r\n]*$/

That is, until we get into the territory of names and values containing <space><space><space><space>REG_SZ and the like, in which case all bets are off because the output of reg.exe becomes ambiguous.

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

Successfully merging this pull request may close these issues.

4 participants