You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Fix empty string handling in push notifications
Fixes https://github.com/vector-im/riot-web/issues/11460 Empty strings are falsey, and the state key match for a tombstone event is an empty string. Ergo, nothing happens because all the conditions fail.
This commit is contained in:
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {escapeRegExp, globToRegexp} from "./utils";
|
import {escapeRegExp, globToRegexp, isNullOrUndefined} from "./utils";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @module pushprocessor
|
* @module pushprocessor
|
||||||
@@ -268,7 +268,7 @@ function PushProcessor(client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const val = valueForDottedKey(cond.key, ev);
|
const val = valueForDottedKey(cond.key, ev);
|
||||||
if (!val || typeof val != 'string') {
|
if (isNullOrUndefined(val) || typeof val != 'string') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,10 +304,10 @@ function PushProcessor(client) {
|
|||||||
|
|
||||||
// special-case the first component to deal with encrypted messages
|
// special-case the first component to deal with encrypted messages
|
||||||
const firstPart = parts[0];
|
const firstPart = parts[0];
|
||||||
if (firstPart == 'content') {
|
if (firstPart === 'content') {
|
||||||
val = ev.getContent();
|
val = ev.getContent();
|
||||||
parts.shift();
|
parts.shift();
|
||||||
} else if (firstPart == 'type') {
|
} else if (firstPart === 'type') {
|
||||||
val = ev.getType();
|
val = ev.getType();
|
||||||
parts.shift();
|
parts.shift();
|
||||||
} else {
|
} else {
|
||||||
@@ -316,11 +316,11 @@ function PushProcessor(client) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (parts.length > 0) {
|
while (parts.length > 0) {
|
||||||
const thispart = parts.shift();
|
const thisPart = parts.shift();
|
||||||
if (!val[thispart]) {
|
if (isNullOrUndefined(val[thisPart])) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
val = val[thispart];
|
val = val[thisPart];
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -714,3 +714,7 @@ module.exports.ensureNoTrailingSlash = function(url) {
|
|||||||
module.exports.sleep = (ms, value) => new Promise((resolve => {
|
module.exports.sleep = (ms, value) => new Promise((resolve => {
|
||||||
setTimeout(resolve, ms, value);
|
setTimeout(resolve, ms, value);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
module.exports.isNullOrUndefined = function(val) {
|
||||||
|
return val === null || val === undefined;
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user