forked from Kieran/snort
Filter malformed tags
This commit is contained in:
parent
6a28f2dc5a
commit
ae133130ef
@ -5,6 +5,11 @@ import Thread from './Thread';
|
||||
|
||||
export default class Event {
|
||||
constructor() {
|
||||
/**
|
||||
* The original event
|
||||
*/
|
||||
this.Original = null;
|
||||
|
||||
/**
|
||||
* Id of the event
|
||||
* @type {string}
|
||||
@ -117,11 +122,12 @@ export default class Event {
|
||||
}
|
||||
|
||||
let ret = new Event();
|
||||
ret.Original = obj;
|
||||
ret.Id = obj.id;
|
||||
ret.PubKey = obj.pubkey;
|
||||
ret.CreatedAt = obj.created_at;
|
||||
ret.Kind = obj.kind;
|
||||
ret.Tags = obj.tags.map((e, i) => new Tag(e, i));
|
||||
ret.Tags = obj.tags.map((e, i) => new Tag(e, i)).filter(a => !a.Invalid);
|
||||
ret.Content = obj.content;
|
||||
ret.Signature = obj.sig;
|
||||
return ret;
|
||||
|
@ -7,6 +7,7 @@ export default class Tag {
|
||||
this.Marker = null;
|
||||
this.Other = null;
|
||||
this.Index = index;
|
||||
this.Invalid = false;
|
||||
|
||||
switch (this.Key) {
|
||||
case "e": {
|
||||
@ -14,11 +15,17 @@ export default class Tag {
|
||||
this.Event = tag[1];
|
||||
this.Relay = tag.length > 2 ? tag[2] : null;
|
||||
this.Marker = tag.length > 3 ? tag[3] : null;
|
||||
if (!this.Event) {
|
||||
this.Invalid = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "p": {
|
||||
// ["p", <pubkey>]
|
||||
this.PubKey = tag[1];
|
||||
if (!this.PubKey) {
|
||||
this.Invalid = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
Loading…
Reference in New Issue
Block a user