pnp / pnp/pnpframework

Bug: Token Regex for fileuniqueid* matches too broadly

Open
#751 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
259
Forks
161
Avg merge
10h 33m
Merged PRs (30d)
1

Description

This Regex matches more than just fileuniqueid* tokens:

https://github.com/pnp/pnpframework/blob/83eaf1f88370b8fd35245a3ce2a01272178f4869/src/lib/PnP.Framework/Provisioning/ObjectHandlers/Utilities/ListItemUtilities.cs#L283

image

This will be handled OK since exceptions are swallowed, but calls are made that are not necessary (for every field content containing curly braces). So this Regex could be improved to not trigger those redundant calls.

Alternative easy improvement: after this line:
https://github.com/pnp/pnpframework/blob/83eaf1f88370b8fd35245a3ce2a01272178f4869/src/lib/PnP.Framework/Provisioning/ObjectHandlers/Utilities/ListItemUtilities.cs#L308

Add:

if (tokenParts.Length < 2)
{
    continue;
}

This catches most mismatches and prevents further redundant calls.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/lib/PnP.Framework/Provisioning/ObjectHandlers/Utilities/ListItemUtilities.cs around lines 283 and 308, and inspect how the token regex and tokenParts handling process field content containing curly braces. Confirm the change limits processing to fileuniqueid* tokens and prevents redundant calls for mismatches; done means unrelated curly-brace content no longer reaches the lookup path.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.