docker/docker — pull request #8004 by duglin (2014-09-11 23:53:25+00:00)
Title: Fix parsing of proto/port - issue 6447

Fix for #6447
Here's what I think is going on. Using the old code at: https://github.com/docker/docker/blob/master/nat/nat.go#L65 I think the parsing is a bit off. The old parse would do this ( "old string" -> port / protocol ):
123/tcp -> 123/tcp
123/ -> 123/"" (#6447 issue)
/tcp -> tcp/"" (error)
/ -> ""/""
"" -> ""/""

And I think its the 123/ -> 123/"" case that is the cause of the issue in #6447, it should return 123/tcp.
With this change the parser now returns:
123/tcp -> tcp/123
123/ -> 123/tcp (now it'll default to tcp to fix #6447)
/tcp -> ""/"" (treat the same as / and "")
/ -> ""/""
"" -> ""/""

I also added some new tests to enforce this.

Signed-off-by: Doug Davis