1

I have a url_regex acl: ^http(s)://bitbucket.org/example/*

However, it's matching the url: http(s)://bitbucket.org/example_test/*

This seems to not consider the "/" at the end of ^http(s)://bitbucket.org/example/*

I'd like to match anything with subfolder matching example. Eg: bitbucket.org/example/case_1 bitbucket.org/example/case_2 But not, bitbucket.org/example_bad/case_3

It seems like a special blend of regex and its not considering the "/" –

Can anyone see what is wrong here ?

3
  • I'm not familiar with squid url_regex specifically, but normally the quantifier * would match zero or more of the previous atom (i.e. /* matches zero or more "/" characters. I suspect you want /.* or perhaps just / Commented Apr 4, 2022 at 23:54
  • Thanks for your reply. I'd like to match anything with subfolder matching example. Eg: bitbucket.org/example/case_1 bitbucket.org/example/case_2 But not, bitbucket.org/example_bad/case_3 It seems like a special blend of regex and its not considering the "/"
    – David Co
    Commented Apr 4, 2022 at 23:57
  • Yes that is the intention. I DO NOT want it to match example_test/ but it seems like it is. So I’m here scratching my head
    – David Co
    Commented Apr 5, 2022 at 0:31

1 Answer 1

1

As steeldriver said, it’s matching for the same reason car*t matches cat  —  * means any number of the preceding character, including zero.  r* matches the zero r’s between a and t, and your /* is matching the zero slashes between example and _test/*.

Do you want to match http(s)://bitbucket.org/example (without any subdirectory)?  If not, it’s easy; just use

^http(s)://bitbucket.org/example/

or

^http(s)://bitbucket.org/example/.*$

If you do want to match http(s)://bitbucket.org/example, it’s a bit trickier.  You need example to be either at the end of the URL, or followed by a slash.  Some regex engines will let you say

^http(s)://bitbucket.org/example(/|$)

where the | inside () means “or”.  For example, grep -E supports this.  I don’t know whether this will work in Squid.


Does Squid let you specify multiple regexes?  If it does, specify

^http(s)://bitbucket.org/example$

and

^http(s)://bitbucket.org/example/
1
  • Thanks ! That really explains it. I put in an extra / and it works now !
    – David Co
    Commented Apr 5, 2022 at 6:02

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.