| 531 | } |
| 532 | |
| 533 | func (l *Limits) compileQueryAttributeRegex() error { |
| 534 | if !l.QueryPriority.Enabled && !l.QueryRejection.Enabled { |
| 535 | return nil |
| 536 | } |
| 537 | regexChanged := l.hasQueryAttributeRegexChanged() |
| 538 | newCompiledRegex := map[string]*regexp.Regexp{} |
| 539 | |
| 540 | if l.QueryPriority.Enabled { |
| 541 | prioritySet := map[int64]struct{}{} |
| 542 | |
| 543 | for i, priority := range l.QueryPriority.Priorities { |
| 544 | // Check for duplicate priority entry |
| 545 | if _, exists := prioritySet[priority.Priority]; exists { |
| 546 | return errDuplicateQueryPriorities |
| 547 | } |
| 548 | prioritySet[priority.Priority] = struct{}{} |
| 549 | |
| 550 | err := l.compileQueryAttributeRegexes(l.QueryPriority.Priorities[i].QueryAttributes, regexChanged, newCompiledRegex) |
| 551 | if err != nil { |
| 552 | return err |
| 553 | } |
| 554 | } |
| 555 | } |
| 556 | |
| 557 | if l.QueryRejection.Enabled { |
| 558 | err := l.compileQueryAttributeRegexes(l.QueryRejection.QueryAttributes, regexChanged, newCompiledRegex) |
| 559 | if err != nil { |
| 560 | return err |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | if regexChanged { |
| 565 | l.queryAttributeCompiledRegex = newCompiledRegex |
| 566 | } |
| 567 | |
| 568 | return nil |
| 569 | } |
| 570 | |
| 571 | func (l *Limits) compileQueryAttributeRegexes(queryAttributes []QueryAttribute, regexChanged bool, newCompiledRegex map[string]*regexp.Regexp) error { |
| 572 | for j, attribute := range queryAttributes { |