Skip to content

Commit 195efb8

Browse files
committed
Fix rport parse, close #144.
1 parent 93573f5 commit 195efb8

File tree

4 files changed

+641
-731
lines changed

4 files changed

+641
-731
lines changed

lib/src/grammar.peg

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
var data = ParsedData();
1313

1414
int parseInt(str){
15-
return int.parse(str);
15+
return int.tryParse(str) ?? null;
1616
}
1717

1818
double parseFloat(str){
@@ -396,7 +396,7 @@ SIP_URI <- uri_scheme ":" userinfo? hostport uri_parameters headers? {
396396
$$ == -1;
397397
}}
398398

399-
uri_scheme <- (uri_scheme_sips / uri_scheme_sip)
399+
uri_scheme <- uri_scheme_sips / uri_scheme_sip
400400

401401
uri_scheme_sips <- scheme: "sips"i {
402402
data.scheme = scheme.toLowerCase(); }
@@ -426,7 +426,7 @@ host <- ( hostname / IPv4address / IPv6reference ) {
426426
## 'hostname' grammar is relaxed from RFC 3261:
427427
## 'domainlabel' and 'toplabel' can end with dash or hypen
428428

429-
hostname <- ((( domainlabel "." )* toplabel "." ?) / token ){
429+
hostname <- (( domainlabel "." )* toplabel "." ?) {
430430
data.host = _text().toLowerCase();
431431
data.host_type = 'domain';
432432
var result = {};
@@ -1095,8 +1095,9 @@ via_branch <- "branch"i EQUAL via_branch: token {
10951095
}
10961096

10971097
response_port <- "rport"i EQUAL (response_port: (DIGIT ? DIGIT ? DIGIT ? DIGIT ? DIGIT ?) )? {
1098-
if(response_port != null)
1099-
data.rport = parseInt(response_port.join(''));
1098+
if(response_port != null) {
1099+
data.rport = parseInt(response_port.map((e) => e ?? '').join(''));
1100+
}
11001101
}
11011102

11021103

0 commit comments

Comments
 (0)