Improve IP_PATTERN in DirectRTCClient in Android AppRTC Demo

Earlier, strings like "aaaa" and "1111" would be interpreted as IP
addresses, which is not optimal. This CL improves the IP_PATTERN and
adds a test for it.

Review-Url: https://codereview.webrtc.org/2009493002
Cr-Commit-Position: refs/heads/master@{#12887}
This commit is contained in:
sakal
2016-05-25 02:26:22 -07:00
committed by Commit bot
parent 834081aadf
commit b0cf1a8916
2 changed files with 50 additions and 2 deletions

View File

@ -42,10 +42,10 @@ public class DirectRTCClient implements AppRTCClient, TCPChannelClient.TCPChanne
// IPv6
+ "\\[((([0-9a-fA-F]{1,4}:)*[0-9a-fA-F]{1,4})?::"
+ "(([0-9a-fA-F]{1,4}:)*[0-9a-fA-F]{1,4})?)\\]|"
+ "\\[(([0-9a-fA-F]{1,4}:)*[0-9a-fA-F]{1,4})\\]|"
+ "\\[(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4})\\]|"
// IPv6 without []
+ "((([0-9a-fA-F]{1,4}:)*[0-9a-fA-F]{1,4})?::(([0-9a-fA-F]{1,4}:)*[0-9a-fA-F]{1,4})?)|"
+ "(([0-9a-fA-F]{1,4}:)*[0-9a-fA-F]{1,4})|"
+ "(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4})|"
// Literals
+ "localhost"
+ ")"