smalltalk
/
osmo-st-all
Archived
1
0
Fork 0

parser: Be aple to parse From/To with display_name in it

A rule like "ANY star / quoted_string" will only parse the ANY
rules for '0' times. Change the order to avoid this and add a
small test that we properly parse the From address now.
This commit is contained in:
Holger Hans Peter Freyther 2014-05-27 14:19:58 +02:00
parent 33f1e40cbe
commit 15f1f07631
2 changed files with 6 additions and 4 deletions

View File

@ -148,7 +148,7 @@ PP.PPCompositeParserTest subclass: SIPParserTest [
^ (WriteStream on: String new)
nextPutAll: 'SIP/2.0 416 Unsupported URI Scheme'; cr; nl;
nextPutAll: 'Via: SIP/2.0/UDP 192.168.0.101:5061;branch=z9hG4bKMzQ4ODYxODcyOCwyMDg0MA__'; cr; nl;
nextPutAll: 'From: <sip:1000@osmocom.org>;tag=MzQ4ODYyNTkyODQxMDY0OTAxMzI_'; cr; nl;
nextPutAll: 'From: "abc" <sip:1000@osmocom.org>;tag=MzQ4ODYyNTkyODQxMDY0OTAxMzI_'; cr; nl;
nextPutAll: 'To: <1000@192.168.0.106>;tag=5UtDUa1DeFa4S'; cr; nl;
nextPutAll: 'Call-ID: MTg3NzU0Mjk2MQ__@xiaoyu'; cr; nl;
nextPutAll: 'CSeq: 1 INVITE'; cr; nl;
@ -161,9 +161,11 @@ PP.PPCompositeParserTest subclass: SIPParserTest [
]
testStatusResponse [
| res dlg |
| res from |
res := SIPParser parse: self statusResponseData.
"dlg := SIPDialog fromMessage: res."
from := (res parameter: 'From' ifAbsent: []).
self assert: from address equals: 'sip:1000@osmocom.org'.
self assert: from tag equals: 'MzQ4ODYyNTkyODQxMDY0OTAxMzI_'.
]
resultUnauthorized [

View File

@ -494,7 +494,7 @@ PP.PPCompositeParser subclass: SIPGrammar [
display_name [
<category: 'to-from'>
^ ((self token, LWS) star / self quoted_string) flatten
^ (self quoted_string / (self token, LWS) star) flatten
]
addr_spec [