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

Manage empty values #47

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Manage empty values #47

wants to merge 4 commits into from

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
@@ -41,7 +41,7 @@ var util = require('util')
, PATH_PATTERN = /^(HKEY_LOCAL_MACHINE|HKEY_CURRENT_USER|HKEY_CLASSES_ROOT|HKEY_USERS|HKEY_CURRENT_CONFIG)(.*)$/

/* 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