(entity string)
| 912 | } |
| 913 | |
| 914 | func decodeEntity(entity string) (rune, bool) { |
| 915 | if len(entity) == 0 { |
| 916 | return 0, false |
| 917 | } |
| 918 | |
| 919 | if entity[0] == '#' { |
| 920 | entity = entity[1:] |
| 921 | if len(entity) == 0 { |
| 922 | return 0, false |
| 923 | } |
| 924 | |
| 925 | base := 10 |
| 926 | if entity[0] == 'x' { |
| 927 | base = 16 |
| 928 | entity = entity[1:] |
| 929 | } |
| 930 | |
| 931 | if len(entity) == 0 { |
| 932 | return 0, false |
| 933 | } |
| 934 | |
| 935 | for _, c := range entity { |
| 936 | if base == 16 && !stringutil.IsHexDigit(c) { |
| 937 | return 0, false |
| 938 | } |
| 939 | if base == 10 && !stringutil.IsDigit(c) { |
| 940 | return 0, false |
| 941 | } |
| 942 | } |
| 943 | |
| 944 | parsed, err := strconv.ParseInt(entity, base, 32) |
| 945 | if err != nil { |
| 946 | return 0, false |
| 947 | } |
| 948 | return rune(parsed), true |
| 949 | } |
| 950 | |
| 951 | r, ok := entities[entity] |
| 952 | return r, ok |
| 953 | } |
| 954 | |
| 955 | var entities = map[string]rune{ |
| 956 | "quot": 0x0022, |
no test coverage detected