loot / libloot

A C++ library for accessing LOOT's metadata and sorting functionality.
GNU General Public License v3.0
32 stars 12 forks source link

Issue with Regex Capture Groups #48

Closed MacSplody closed 5 years ago

MacSplody commented 5 years ago

Having an issue with regex, capture groups don't seem to be working.

Could be causing these issues: https://github.com/loot/loot/issues/1077 https://github.com/loot/loot/issues/1074#issuecomment-455860099

I've tried the following

active("RUSTIC SOULGEMS - (Sorted|Unsorted)\.esp") and not active("GIST-RusticSoulGems-patch.esp")

active("(RUSTIC SOULGEMS - (Sorted|Unsorted))\.esp") and not active("GIST-RusticSoulGems-patch.esp")

active("RUSTIC SOULGEMS - (Sorted|Unsorted)?.*\.esp") and not active("GIST-RusticSoulGems-patch.esp")

active("RUSTIC SOULGEMS - (Sorted|Unsorted).*\.esp") and not active("GIST-RusticSoulGems-patch.esp")

active("(RUSTIC SOULGEMS - (Sorted|Unsorted)).*\.esp") and not active("GIST-RusticSoulGems-patch.esp")

active("(RUSTIC SOULGEMS - (Sorted|Unsorted))?.*\.esp") and not active("GIST-RusticSoulGems-patch.esp")

but the warning message is still displayed. image

Used for reference. https://docs.rs/regex/1.0.5/regex/#syntax

Used for testing. https://regex101.com/r/fN7xaL/1

Ortham commented 5 years ago

OK, I can replicate this. It looks like parsing stops early when it hits a regex special character, so it's not parsing the and not active("GIST-RusticSoulGems-patch.esp") bit.

Ortham commented 5 years ago

Well, turns out I missed a check for a single ) in the parser, so it would hit that and stop matching input.

I've fixed that, and also made it so that the parser will error if it doesn't consume all input, to help catch similar bugs or invalid input that was being silently ignored.

Ortham commented 5 years ago

OK, it should be fixed in this build.

MacSplody commented 5 years ago

Have this error now,

An error occurred while parsing the metadata list(s): yaml-cpp: error at line 4379, column 9: bad conversion: invalid condition syntax: Failed to parse condition "active("Cutting Room Floor.esp") and not active("PAN_NPCs.esp") and not active ("The Ordinary Women.esp") and not active("Qw_AIOverhaul_CRF Patch.esp")". Details: The parser did not consume the following input: " and not active ("The Ordinary Women.esp") and not active("Qw_AIOverhaul_CRF Patch.esp")".

Try updating your masterlist to resolve the error. If the error is with your user metadata, this probably happened because an update to LOOT changed its metadata syntax support. Your user metadata will have to be updated manually.

To do so, use the 'Open Debug Log Location' in LOOT's main menu to open its data folder, then open your 'userlist.yaml' file in the relevant game folder. You can then edit the metadata it contains with reference to the documentation, which is accessible through LOOT's main menu.
MacSplody commented 5 years ago

Might have been my local masterlist, one sec.

MacSplody commented 5 years ago

LOOTDebugLog.txt No same if I clear local files.

Ortham commented 5 years ago

It's probably this: active ("The Ordinary Women.esp")

MacSplody commented 5 years ago

Yeah, missed it when reviewing, I'll fix that now.

Regex is working now with that build. image

Ortham commented 5 years ago

I'll release a new metadata validator so that it has the updated parsing logic too, so it'll catch the same mistakes in CI.

MacSplody commented 5 years ago

Okay will test that build out a bit, looks good so far.

Ortham commented 5 years ago

Fixed in fd29783e41cf1cc19a2198b440ee270bd01ae3eb.