provision for future versions sending profiles with search results

dbus-notify
Zlatin Balevsky 2022-04-13 20:09:42 +01:00
parent cb695ff751
commit a3f40da51c
No known key found for this signature in database
GPG Key ID: A72832072D525E41
2 changed files with 12 additions and 1 deletions

View File

@ -339,6 +339,9 @@ class ConnectionAcceptor {
boolean feed = false
if (headers.containsKey('Feed'))
feed = Boolean.parseBoolean(headers['Feed'])
boolean profile = false
if (headers.containsKey("Profile"))
profile = Boolean.parseBoolean(headers['Profile'])
byte [] personaBytes = Base64.decode(headers['Sender'])
Persona sender = new Persona(new ByteArrayInputStream(personaBytes))
@ -348,7 +351,14 @@ class ConnectionAcceptor {
int nResults = Integer.parseInt(headers['Count'])
if (nResults > Constants.MAX_RESULTS)
throw new IOException("too many results $nResults")
if (profile) {
int profileLength = dis.readInt()
if (profileLength > Constants.MAX_PROFILE_LENGTH)
throw new IOException("profile too large $profileLength")
dis.skipBytes(profileLength) // skip profile data for now
}
dis = new DataInputStream(new GZIPInputStream(dis))
UIResultEvent[] results = new UIResultEvent[Math.min(RESULT_BATCH_SIZE, nResults)]
int j = 0

View File

@ -23,6 +23,7 @@ public class Constants {
public static final long MAX_HEADER_TIME = 60 * 1000;
public static final int MAX_RESULTS = 0x1 << 20;
public static final int MAX_PROFILE_LENGTH = 0x1 << 18;
public static final int MAX_COMMENT_LENGTH = 0x1 << 15;