Skip to content

Setting and querying web properties with special characters fails #1263

@LeHailender

Description

@LeHailender

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 - . / : < > | [ ]

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions