From cfa42ff2645402e4574264e8c8bd45d4ad0b707f Mon Sep 17 00:00:00 2001
From: Christoph Petrausch <christoph.petrausch@inovex.de>
Date: Wed, 20 Jun 2018 21:42:38 +0200
Subject: [PATCH] revert regex implementation

---
 protocols/bgp/packet/large_community.go | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/protocols/bgp/packet/large_community.go b/protocols/bgp/packet/large_community.go
index 7547fd60..5b3f7788 100644
--- a/protocols/bgp/packet/large_community.go
+++ b/protocols/bgp/packet/large_community.go
@@ -2,13 +2,10 @@ package packet
 
 import (
 	"fmt"
-	"regexp"
 	"strconv"
 	"strings"
 )
 
-var largeCommunityRegEx = regexp.MustCompile("^\\(?\\d+,\\d+,\\d+\\)?$")
-
 type LargeCommunity struct {
 	GlobalAdministrator uint32
 	DataPart1           uint32
@@ -20,12 +17,13 @@ func (c LargeCommunity) String() string {
 }
 
 func ParseLargeCommunityString(s string) (com LargeCommunity, err error) {
-	if !largeCommunityRegEx.Match([]byte(s)) {
-		return com, fmt.Errorf("malformed large community string %s", s)
-	}
 	s = strings.Trim(s, "()")
 	t := strings.Split(s, ",")
 
+	if len(t) != 3 {
+		return com, fmt.Errorf("can not parse large community %s", s)
+	}
+
 	v, err := strconv.ParseUint(t[0], 10, 32)
 	if err != nil {
 		return com, err
-- 
GitLab