Allow empty region info

This commit is contained in:
lion 2025-09-24 15:56:40 +08:00
parent 93c5088591
commit cb3329390a
4 changed files with 18 additions and 12 deletions

View File

@ -285,7 +285,8 @@ func (m *Maker) Start() error {
var dataLen = len(seg.Region)
if dataLen < 1 {
// @TODO: could this even be a case ?
return fmt.Errorf("empty region info for segment '%s'", seg)
// return fmt.Errorf("empty region info for segment '%s'", seg)
// Allow empty region info since 2024/09/24
}
var _offset = 0

View File

@ -142,9 +142,10 @@ func IterateSegments(handle *os.File, before func(l string), cb func(seg *Segmen
return fmt.Errorf("start ip(%s) should not be greater than end ip(%s)", ps[0], ps[1])
}
if len(ps[2]) < 1 {
return fmt.Errorf("empty region info in segment line `%s`", l)
}
// Allow empty region info since 2024/09/24
// if len(ps[2]) < 1 {
// return fmt.Errorf("empty region info in segment line `%s`", l)
// }
var seg = &Segment{
StartIP: sip,

View File

@ -178,9 +178,11 @@ public class Maker {
// apply the field filtering
final String region = Util.regionFiltering(seg.region, fields);
if (region.length() < 1) {
throw new Exception("empty region info for segment `"+seg+"`");
}
// allow empty region
// if (region.length() < 1) {
// throw new Exception("empty region info for segment `"+seg+"`");
// }
segments.add(new Segment(seg.startIP, seg.endIP, region));
last = seg;
@ -235,7 +237,8 @@ public class Maker {
// get the utf-8 bytes of the region info
final byte[] regionBuff = seg.region.getBytes(bytesCharset);
if (regionBuff.length < 1) {
throw new Exception("empty region info for segment `"+seg+"`");
// allow empty region info
// throw new Exception("empty region info for segment `"+seg+"`");
} else if (regionBuff.length > 0xFFFF) {
throw new Exception("too long region info `"+seg.region+"`: should be less than 65535 bytes");
}

View File

@ -169,10 +169,11 @@ public class Segment {
throw new Exception("start ip("+ps[0]+") should not be greater than end ip("+ps[1]+")");
}
if (ps[2].isEmpty()) {
br.close();
throw new Exception("empty region info in segment line `"+ps[2]+"`");
}
// allow empty region info
// if (ps[2].isEmpty()) {
// br.close();
// throw new Exception("empty region info in segment line `"+ps[2]+"`");
// }
final Segment seg = new Segment(sip, eip, ps[2]);
// check and set the last segment