| 761 | } |
| 762 | |
| 763 | func (this *Rule) unescape(v string) string { |
| 764 | // replace urlencoded characters |
| 765 | |
| 766 | for _, c := range unescapeChars { |
| 767 | if !strings.Contains(v, c[0]) { |
| 768 | continue |
| 769 | } |
| 770 | var pieces = strings.Split(v, c[0]) |
| 771 | |
| 772 | // 修复piece中错误的\ |
| 773 | for pieceIndex, piece := range pieces { |
| 774 | var l = len(piece) |
| 775 | if l == 0 { |
| 776 | continue |
| 777 | } |
| 778 | if piece[l-1] != '\\' { |
| 779 | continue |
| 780 | } |
| 781 | |
| 782 | // 计算\的数量 |
| 783 | var countBackSlashes = 0 |
| 784 | for i := l - 1; i >= 0; i-- { |
| 785 | if piece[i] == '\\' { |
| 786 | countBackSlashes++ |
| 787 | } else { |
| 788 | break |
| 789 | } |
| 790 | } |
| 791 | if countBackSlashes%2 == 1 { |
| 792 | // 去掉最后一个 |
| 793 | pieces[pieceIndex] = piece[:len(piece)-1] |
| 794 | } |
| 795 | } |
| 796 | |
| 797 | v = strings.Join(pieces, c[1]) |
| 798 | } |
| 799 | |
| 800 | return v |
| 801 | } |
| 802 | |
| 803 | func (this *Rule) containsIP(value any) bool { |
| 804 | if this.ipRangeListValue == nil { |