Skip to content

Commit

Permalink
Fixed decoding of XProperty values
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Jul 28, 2021
1 parent 9b25cac commit 77adb7a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/main/java/net/fortuna/ical4j/model/PropertyBuilder.java
Expand Up @@ -53,9 +53,6 @@ public Property build() throws ParseException, IOException, URISyntaxException {
for (PropertyFactory<?> factory : factories) {
if (factory.supports(name)) {
property = factory.createProperty(parameters, value);
if (property instanceof Encodable) {
property.setValue(decodedValue);
}
}
}

Expand All @@ -69,6 +66,10 @@ public Property build() throws ParseException, IOException, URISyntaxException {
}
}

if (property instanceof Encodable) {
property.setValue(decodedValue);
}

return property;
}
}
@@ -1,6 +1,5 @@
package net.fortuna.ical4j.model


import net.fortuna.ical4j.model.property.Version
import spock.lang.Ignore
import spock.lang.Specification
Expand Down Expand Up @@ -35,4 +34,18 @@ class PropertyBuilderTest extends Specification {
then: 'an exception is thrown'
thrown(IllegalArgumentException)
}

def 'test build encoded property'() {
given: 'a property builder instance'
PropertyBuilder builder = []

and: 'builder is initialised'
builder.name('X-MICROSOFT-LOCATIONS').value('[{\\"DisplayName\\":\\"Microsoft Teams Meeting\\"\\, \\"LocationCode\\":\\"013454\\"}]')

when: 'build method called'
Property p = builder.build()

then: 'resulting property is initialised accordingly'
p.value == '[{"DisplayName":"Microsoft Teams Meeting", "LocationCode":"013454"}]'
}
}

0 comments on commit 77adb7a

Please sign in to comment.