Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/nbconvert/filters/svg_constants.py: 100%

2 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-07-01 06:54 +0000

1"""SVG constants for sanitization.""" 

2# These are lifted from html5lib's sanitizer module, which is deprecated. 

3# 

4# Quoth the migration guide (https://github.com/mozilla/bleach/blob/main/docs/migrating.rst#different-allow-lists): 

5# 

6# > If you want to stick to the html5lib sanitizer's allow lists, get them from the sanitizer code. 

7# > It's probably best to copy them as static lists. 

8 

9# TODO: Bleach currently drops attribute namespaces; cleaning SVGs will probably require more elbow grease. 

10# See https://github.com/mozilla/bleach/issues/362 

11 

12ALLOWED_SVG_TAGS = { 

13 "a", 

14 "animate", 

15 "animateColor", 

16 "animateMotion", 

17 "animateTransform", 

18 "circle", 

19 "clipPath", 

20 "defs", 

21 "desc", 

22 "ellipse", 

23 "font-face", 

24 "font-face-name", 

25 "font-face-src", 

26 "g", 

27 "glyph", 

28 "hkern", 

29 "line", 

30 "linearGradient", 

31 "marker", 

32 "metadata", 

33 "missing-glyph", 

34 "mpath", 

35 "path", 

36 "polygon", 

37 "polyline", 

38 "radialGradient", 

39 "rect", 

40 "set", 

41 "stop", 

42 "svg", 

43 "switch", 

44 "text", 

45 "title", 

46 "tspan", 

47 "use", 

48} 

49ALLOWED_SVG_ATTRIBUTES = { 

50 "accent-height", 

51 "accumulate", 

52 "additive", 

53 "alphabetic", 

54 "arabic-form", 

55 "ascent", 

56 "attributeName", 

57 "attributeType", 

58 "baseProfile", 

59 "bbox", 

60 "begin", 

61 "by", 

62 "calcMode", 

63 "cap-height", 

64 "class", 

65 "clip-path", 

66 "color", 

67 "color-rendering", 

68 "content", 

69 "cx", 

70 "cy", 

71 "d", 

72 "descent", 

73 "display", 

74 "dur", 

75 "dx", 

76 "dy", 

77 "end", 

78 "fill", 

79 "fill-opacity", 

80 "fill-rule", 

81 "font-family", 

82 "font-size", 

83 "font-stretch", 

84 "font-style", 

85 "font-variant", 

86 "font-weight", 

87 "from", 

88 "fx", 

89 "fy", 

90 "g1", 

91 "g2", 

92 "glyph-name", 

93 "gradientUnits", 

94 "hanging", 

95 "height", 

96 "horiz-adv-x", 

97 "horiz-origin-x", 

98 "id", 

99 "ideographic", 

100 "k", 

101 "keyPoints", 

102 "keySplines", 

103 "keyTimes", 

104 "lang", 

105 "marker-end", 

106 "marker-mid", 

107 "marker-start", 

108 "markerHeight", 

109 "markerUnits", 

110 "markerWidth", 

111 "mathematical", 

112 "max", 

113 "min", 

114 "name", 

115 "offset", 

116 "opacity", 

117 "orient", 

118 "origin", 

119 "overline-position", 

120 "overline-thickness", 

121 "panose-1", 

122 "path", 

123 "pathLength", 

124 "points", 

125 "preserveAspectRatio", 

126 "r", 

127 "refX", 

128 "refY", 

129 "repeatCount", 

130 "repeatDur", 

131 "requiredExtensions", 

132 "requiredFeatures", 

133 "restart", 

134 "rotate", 

135 "rx", 

136 "ry", 

137 "slope", 

138 "stemh", 

139 "stemv", 

140 "stop-color", 

141 "stop-opacity", 

142 "strikethrough-position", 

143 "strikethrough-thickness", 

144 "stroke", 

145 "stroke-dasharray", 

146 "stroke-dashoffset", 

147 "stroke-linecap", 

148 "stroke-linejoin", 

149 "stroke-miterlimit", 

150 "stroke-opacity", 

151 "stroke-width", 

152 "style", 

153 "systemLanguage", 

154 "target", 

155 "text-anchor", 

156 "to", 

157 "transform", 

158 "type", 

159 "u1", 

160 "u2", 

161 "underline-position", 

162 "underline-thickness", 

163 "unicode", 

164 "unicode-range", 

165 "units-per-em", 

166 "values", 

167 "version", 

168 "viewBox", 

169 "visibility", 

170 "width", 

171 "widths", 

172 "x", 

173 "x-height", 

174 "x1", 

175 "x2", 

176 "xlink:actuate", 

177 "xlink:arcrole", 

178 "xlink:href", 

179 "xlink:role", 

180 "xlink:show", 

181 "xlink:title", 

182 "xlink:type", 

183 "xml:base", 

184 "xml:lang", 

185 "xml:space", 

186 "y", 

187 "y1", 

188 "y2", 

189 "zoomAndPan", 

190}