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

Setting and querying web properties with special characters fails #1263

Closed
1 task done
LeHailender opened this issue Aug 24, 2023 · 3 comments
Closed
1 task done

Setting and querying web properties with special characters fails #1263

LeHailender opened this issue Aug 24, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@LeHailender
Copy link
Contributor

Category

  • Bug

Describe the bug

When a web property is set with a key name containing special characters (e.g. "-") this can no longer be queried correctly. Because the name of a property named e.g. "SetWebProperties-Test1" is converted to "SetWebProperties_x002d_Test1" when it is set. The query of the property with the original name then fails.

Steps to reproduce

Sample test code:

 var propertyKey1 = "SetWebProperties-Test1";
 var myProperty = web.AllProperties.GetInteger(propertyKey1, 0);
 if (myProperty == 0)
 {
     web.AllProperties[propertyKey1] = 55;
     await web.AllProperties.UpdateAsync();
 }

 web = await context.Web.GetAsync(p => p.AllProperties);
 myProperty = web.AllProperties.GetInteger(propertyKey1, 0);
 // Here we are testing that the property was set correctly and exepect the previous set value. But it fails, the value is 0
 Assert.IsTrue(myProperty == 55);

When I try to query the value with the converted key name, it works. Like:

var propertyKey1 = "SetWebProperties-Test1";
var myProperty = web.AllProperties.GetInteger(propertyKey1, 0);
if (myProperty == 0)
{
    web.AllProperties[propertyKey1] = 55;
    await web.AllProperties.UpdateAsync();
}

web = await context.Web.GetAsync(p => p.AllProperties);
myProperty = web.AllProperties.GetInteger("SetWebProperties_x002d_Test1", 0);
Assert.IsTrue(myProperty == 55);

Expected behavior

The property should be retrieved even if the key name contains the following characters - . / : < > | [ ]

@jansenbe jansenbe self-assigned this Aug 25, 2023
@jansenbe jansenbe added the question Further information is requested label Aug 25, 2023
@jansenbe
Copy link
Contributor

Hi @LeHailender ,

I've just ran this existing test (https://github.com/pnp/pnpcore/blob/dev/src/sdk/PnP.Core.Test/SharePoint/WebTests.cs#L420-L455) with a dash included in the property name and this indeed fails. Let me check for a solution

@jansenbe jansenbe added bug Something isn't working and removed question Further information is requested labels Aug 25, 2023
jansenbe added a commit that referenced this issue Aug 25, 2023
…y of these chars was used in the property name: -./:<>|[] #1263
@jansenbe
Copy link
Contributor

@LeHailender : I've just pushed a fix, will be part of the next nightly release so closing this issue now. Thanks for using PnP Core SDK and reporting this!

@LeHailender
Copy link
Contributor Author

That's what I call fast. Thank you...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants