Skip to content

Commit 5a350b6

Browse files
Revert "fix: unescaped property keys in push rule evaluator + tests"
This reverts commit 89343e0.
1 parent c77814e commit 5a350b6

File tree

2 files changed

+2
-78
lines changed

2 files changed

+2
-78
lines changed

lib/src/utils/pushrule_evaluator.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,7 @@ class _PatternCondition {
8282
if (tempField == null) {
8383
throw 'No field to match pattern on!';
8484
}
85-
// Unescape \. to . per Matrix spec for property access paths
86-
field = tempField.replaceAll(r'\.', '.');
85+
field = tempField;
8786

8887
var tempPat = condition.pattern;
8988
if (tempPat == null) {
@@ -127,8 +126,7 @@ class _EventPropertyCondition {
127126
if (tempField == null) {
128127
throw 'No field to check event property on!';
129128
}
130-
// Unescape \. to . per Matrix spec for property access paths
131-
field = tempField.replaceAll(r'\.', '.');
129+
field = tempField;
132130

133131
final tempValue = condition.value;
134132
if (![String, int, bool, Null].contains(tempValue.runtimeType)) {

test/pushevaluator_test.dart

Lines changed: 0 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -811,79 +811,5 @@ void main() {
811811
returnsNormally,
812812
);
813813
});
814-
815-
test('escaped dot in property key (m.mentions)', () async {
816-
// The Matrix spec uses \. to escape literal dots in property paths.
817-
// e.g., content.m\.mentions.room means content["m.mentions"]["room"]
818-
final event = Event.fromJson(jsonObj, room);
819-
820-
// Test 1: event_property_is with escaped dot - room mention
821-
event.content['m.mentions'] = {'room': true};
822-
823-
final roomMentionRuleset = PushRuleSet(
824-
override: [
825-
PushRule(
826-
ruleId: '.m.is_room_mention',
827-
default$: true,
828-
enabled: true,
829-
actions: [
830-
'notify',
831-
{'set_tweak': 'highlight', 'value': true},
832-
{'set_tweak': 'sound', 'value': 'goose.wav'},
833-
],
834-
conditions: [
835-
PushCondition(
836-
kind: 'event_property_is',
837-
key: r'content.m\.mentions.room', // escaped dot!
838-
value: true,
839-
),
840-
],
841-
),
842-
],
843-
);
844-
845-
var evaluator = PushruleEvaluator.fromRuleset(roomMentionRuleset);
846-
var actions = evaluator.match(event);
847-
expect(actions.notify, true, reason: 'room mention should match');
848-
expect(actions.highlight, true);
849-
850-
// Test 2: same rule shouldn't match when room is false
851-
event.content['m.mentions'] = {'room': false};
852-
evaluator = PushruleEvaluator.fromRuleset(roomMentionRuleset);
853-
actions = evaluator.match(event);
854-
expect(actions.notify, false, reason: 'room=false should not match');
855-
856-
// Test 3: event_property_contains with escaped dot - user mention
857-
event.content['m.mentions'] = {
858-
'user_ids': ['@alice:example.com', '@bob:example.com'],
859-
};
860-
861-
final userMentionRuleset = PushRuleSet(
862-
override: [
863-
PushRule(
864-
ruleId: '.m.is_user_mention',
865-
default$: true,
866-
enabled: true,
867-
actions: [
868-
'notify',
869-
{'set_tweak': 'highlight', 'value': true},
870-
{'set_tweak': 'sound', 'value': 'goose.wav'},
871-
],
872-
conditions: [
873-
PushCondition(
874-
kind: 'event_property_contains',
875-
key: r'content.m\.mentions.user_ids', // escaped dot!
876-
value: '@alice:example.com',
877-
),
878-
],
879-
),
880-
],
881-
);
882-
883-
evaluator = PushruleEvaluator.fromRuleset(userMentionRuleset);
884-
actions = evaluator.match(event);
885-
expect(actions.notify, true, reason: 'user mention should match');
886-
expect(actions.highlight, true);
887-
});
888814
});
889815
}

0 commit comments

Comments
 (0)