Show More
@@ -1,403 +1,405 b'' | |||
|
1 | 1 | all_tags = [ |
|
2 | 2 | "a", "abbr", "acronym", "address", "applet", "area", "article", "aside", "audio", |
|
3 | 3 | "b", "base", "basefont", "bdi", "bdo", "bgsound", "big", "blink", "blockquote", "body", "br", "button", |
|
4 | 4 | "canvas", "caption", "center", "cite", "code", "col", "colgroup", "command", "content", |
|
5 | 5 | "data", "datalist", "dd", "del", "detals", "dfn", "dialog", "dir", "div", "dl", "dt", |
|
6 | 6 | "element", "em", "embed", |
|
7 | 7 | "fieldset", "figcaption", "figure", "font", "footer", "form", "frame", "frameset", |
|
8 | 8 | "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", |
|
9 | 9 | "i", "iframe", "image", "img", "input", "ins", "isindex", |
|
10 | 10 | "kbd", "keygen", |
|
11 | 11 | "label", "legend", "li", "link", "listing", |
|
12 | 12 | "main", "map", "mark", "marquee", "menu", "menuitem", "meta", "meter", "multicol", |
|
13 | 13 | "nav", "nobr", "noembed", "noframes", "noscript", |
|
14 | 14 | "object", "ol", "optgroup", "option", "output", |
|
15 | 15 | "p", "param", "picture", "plaintext", "pre", "progress", |
|
16 | 16 | "q", |
|
17 | 17 | "rp", "rt", "ruby", |
|
18 | 18 | "s", "samp", "script", "section", "select", "shadow", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", |
|
19 | 19 | "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", |
|
20 | 20 | "u", "ul", |
|
21 | 21 | "var", "video", |
|
22 | 22 | "wbr", |
|
23 | 23 | "xmp", |
|
24 | 24 | ] |
|
25 | 25 | |
|
26 | 26 | # List tags that, if included in a page, could break markup or open XSS. |
|
27 | 27 | generally_xss_unsafe = [ |
|
28 | 28 | "applet", "audio", |
|
29 | 29 | "bgsound", "body", |
|
30 | 30 | "canvas", |
|
31 | 31 | "embed", |
|
32 | 32 | "frame", "frameset", |
|
33 | 33 | "head", "html", |
|
34 | 34 | "iframe", |
|
35 | 35 | "link", |
|
36 | 36 | "meta", |
|
37 | 37 | "object", |
|
38 | 38 | "param", |
|
39 | 39 | "source", "script", |
|
40 | 40 | "ruby", "rt", |
|
41 | 41 | "title", "track", |
|
42 | 42 | "video", |
|
43 | 43 | "xmp" |
|
44 | 44 | ] |
|
45 | 45 | |
|
46 | 46 | # Tags that, if included on the page, will probably not break markup or open |
|
47 | 47 | # XSS. Note that these must be combined with attribute whitelisting, or things |
|
48 | 48 | # like <img> and <style> could still be unsafe. |
|
49 | 49 | generally_xss_safe = list(set(all_tags) - set(generally_xss_unsafe)) |
|
50 | 50 | generally_xss_safe.sort() |
|
51 | 51 | |
|
52 | 52 | # Tags suitable for rendering markdown |
|
53 | 53 | markdown_tags = [ |
|
54 | 54 | "h1", "h2", "h3", "h4", "h5", "h6", |
|
55 | 55 | "b", "i", "strong", "em", "tt", |
|
56 | 56 | "p", "br", |
|
57 | 57 | "span", "div", "blockquote", "code", "hr", "pre", "del", |
|
58 | 58 | "ul", "ol", "li", |
|
59 | 59 | "dl", "dd", "dt", |
|
60 | 60 | "table", "thead", "tbody", "tfoot", "tr", "th", "td", |
|
61 | 61 | "img", |
|
62 | 62 | "a", |
|
63 | "input", | |
|
63 | 64 | ] |
|
64 | 65 | |
|
65 | 66 | markdown_attrs = { |
|
66 | 67 | "*": ["class", "style", "align"], |
|
67 | 68 | "img": ["src", "alt", "title"], |
|
68 | 69 | "a": ["href", "alt", "title", "name"], |
|
69 | 70 | "abbr": ["title"], |
|
70 | 71 | "acronym": ["title"], |
|
71 | "pre": ["lang"] | |
|
72 | "pre": ["lang"], | |
|
73 | "input": ["type", "disabled"] | |
|
72 | 74 | } |
|
73 | 75 | |
|
74 | 76 | standard_styles = [ |
|
75 | 77 | # Taken from https://developer.mozilla.org/en-US/docs/Web/CSS/Reference |
|
76 | 78 | # This includes pseudo-classes, pseudo-elements, @-rules, units, and |
|
77 | 79 | # selectors in addition to properties, but it doesn't matter for our |
|
78 | 80 | # purposes -- we don't need to filter styles.. |
|
79 | 81 | ":active", "::after (:after)", "align-content", "align-items", "align-self", |
|
80 | 82 | "all", "<angle>", "animation", "animation-delay", "animation-direction", |
|
81 | 83 | "animation-duration", "animation-fill-mode", "animation-iteration-count", |
|
82 | 84 | "animation-name", "animation-play-state", "animation-timing-function", |
|
83 | 85 | "@annotation", "annotation()", "attr()", "::backdrop", "backface-visibility", |
|
84 | 86 | "background", "background-attachment", "background-blend-mode", |
|
85 | 87 | "background-clip", "background-color", "background-image", "background-origin", |
|
86 | 88 | "background-position", "background-repeat", "background-size", "<basic-shape>", |
|
87 | 89 | "::before (:before)", "<blend-mode>", "blur()", "border", "border-bottom", |
|
88 | 90 | "border-bottom-color", "border-bottom-left-radius", |
|
89 | 91 | "border-bottom-right-radius", "border-bottom-style", "border-bottom-width", |
|
90 | 92 | "border-collapse", "border-color", "border-image", "border-image-outset", |
|
91 | 93 | "border-image-repeat", "border-image-slice", "border-image-source", |
|
92 | 94 | "border-image-width", "border-left", "border-left-color", "border-left-style", |
|
93 | 95 | "border-left-width", "border-radius", "border-right", "border-right-color", |
|
94 | 96 | "border-right-style", "border-right-width", "border-spacing", "border-style", |
|
95 | 97 | "border-top", "border-top-color", "border-top-left-radius", |
|
96 | 98 | "border-top-right-radius", "border-top-style", "border-top-width", |
|
97 | 99 | "border-width", "bottom", "box-decoration-break", "box-shadow", "box-sizing", |
|
98 | 100 | "break-after", "break-before", "break-inside", "brightness()", "calc()", |
|
99 | 101 | "caption-side", "ch", "@character-variant", "character-variant()", "@charset", |
|
100 | 102 | ":checked", "circle()", "clear", "clip", "clip-path", "cm", "color", "<color>", |
|
101 | 103 | "columns", "column-count", "column-fill", "column-gap", "column-rule", |
|
102 | 104 | "column-rule-color", "column-rule-style", "column-rule-width", "column-span", |
|
103 | 105 | "column-width", "content", "contrast()", "<counter>", "counter-increment", |
|
104 | 106 | "counter-reset", "@counter-style", "cubic-bezier()", "cursor", |
|
105 | 107 | "<custom-ident>", ":default", "deg", ":dir()", "direction", ":disabled", |
|
106 | 108 | "display", "@document", "dpcm", "dpi", "dppx", "drop-shadow()", "element()", |
|
107 | 109 | "ellipse()", "em", ":empty", "empty-cells", ":enabled", "ex", "filter", |
|
108 | 110 | ":first", ":first-child", "::first-letter", "::first-line", |
|
109 | 111 | ":first-of-type", "flex", "flex-basis", "flex-direction", |
|
110 | 112 | "flex-flow", "flex-grow", "flex-shrink", "flex-wrap", "float", ":focus", |
|
111 | 113 | "font", "@font-face", "font-family", "font-feature-settings", |
|
112 | 114 | "@font-feature-values", "font-kerning", "font-language-override", "font-size", |
|
113 | 115 | "font-size-adjust", "font-stretch", "font-style", "font-synthesis", |
|
114 | 116 | "font-variant", "font-variant-alternates", "font-variant-caps", |
|
115 | 117 | "font-variant-east-asian", "font-variant-ligatures", "font-variant-numeric", |
|
116 | 118 | "font-variant-position", "font-weight", "<frequency>", ":fullscreen", "grad", |
|
117 | 119 | "<gradient>", "grayscale()", "grid", "grid-area", "grid-auto-columns", |
|
118 | 120 | "grid-auto-flow", "grid-auto-position", "grid-auto-rows", "grid-column", |
|
119 | 121 | "grid-column-start", "grid-column-end", "grid-row", "grid-row-start", |
|
120 | 122 | "grid-row-end", "grid-template", "grid-template-areas", "grid-template-rows", |
|
121 | 123 | "grid-template-columns", "height", ":hover", "hsl()", "hsla()", "hue-rotate()", |
|
122 | 124 | "hyphens", "hz", "<image>", "image()", "image-rendering", "image-resolution", |
|
123 | 125 | "image-orientation", "ime-mode", "@import", "in", ":indeterminate", "inherit", |
|
124 | 126 | "initial", ":in-range", "inset()", "<integer>", ":invalid", "invert()", |
|
125 | 127 | "isolation", "justify-content", "@keyframes", "khz", ":lang()", ":last-child", |
|
126 | 128 | ":last-of-type", "left", ":left", "<length>", "letter-spacing", |
|
127 | 129 | "linear-gradient()", "line-break", "line-height", ":link", "list-style", |
|
128 | 130 | "list-style-image", "list-style-position", "list-style-type", "margin", |
|
129 | 131 | "margin-bottom", "margin-left", "margin-right", "margin-top", "marks", "mask", |
|
130 | 132 | "mask-type", "matrix()", "matrix3d()", "max-height", "max-width", "@media", |
|
131 | 133 | "min-height", "minmax()", "min-width", "mix-blend-mode", "mm", "ms", |
|
132 | 134 | "@namespace", ":not()", ":nth-child()", ":nth-last-child()", |
|
133 | 135 | ":nth-last-of-type()", ":nth-of-type()", "<number>", "object-fit", |
|
134 | 136 | "object-position", ":only-child", ":only-of-type", "opacity", "opacity()", |
|
135 | 137 | ":optional", "order", "@ornaments", "ornaments()", "orphans", "outline", |
|
136 | 138 | "outline-color", "outline-offset", "outline-style", "outline-width", |
|
137 | 139 | ":out-of-range", "overflow", "overflow-wrap", "overflow-x", "overflow-y", |
|
138 | 140 | "padding", "padding-bottom", "padding-left", "padding-right", "padding-top", |
|
139 | 141 | "@page", "page-break-after", "page-break-before", "page-break-inside", "pc", |
|
140 | 142 | "<percentage>", "perspective", "perspective()", "perspective-origin", |
|
141 | 143 | "pointer-events", "polygon()", "position", "<position>", "pt", "px", "quotes", |
|
142 | 144 | "rad", "radial-gradient()", "<ratio>", ":read-only", ":read-write", "rect()", |
|
143 | 145 | "rem", "repeat()", "::repeat-index", "::repeat-item", |
|
144 | 146 | "repeating-linear-gradient()", "repeating-radial-gradient()", ":required", |
|
145 | 147 | "resize", "<resolution>", "rgb()", "rgba()", "right", ":right", ":root", |
|
146 | 148 | "rotate()", "rotatex()", "rotatey()", "rotatez()", "rotate3d()", "ruby-align", |
|
147 | 149 | "ruby-merge", "ruby-position", "s", "saturate()", "scale()", "scalex()", |
|
148 | 150 | "scaley()", "scalez()", "scale3d()", ":scope", "scroll-behavior", |
|
149 | 151 | "::selection", "sepia()", "<shape>", "shape-image-threshold", "shape-margin", |
|
150 | 152 | "shape-outside", "skew()", "skewx()", "skewy()", "steps()", "<string>", |
|
151 | 153 | "@styleset", "styleset()", "@stylistic", "stylistic()", "@supports", "@swash", |
|
152 | 154 | "swash()", "symbol()", "table-layout", "tab-size", ":target", "text-align", |
|
153 | 155 | "text-align-last", "text-combine-upright", "text-decoration", |
|
154 | 156 | "text-decoration-color", "text-decoration-line", "text-decoration-style", |
|
155 | 157 | "text-indent", "text-orientation", "text-overflow", "text-rendering", |
|
156 | 158 | "text-shadow", "text-transform", "text-underline-position", "<time>", |
|
157 | 159 | "<timing-function>", "top", "touch-action", "transform", "transform-origin", |
|
158 | 160 | "transform-style", "transition", "transition-delay", "transition-duration", |
|
159 | 161 | "transition-property", "transition-timing-function", "translate()", |
|
160 | 162 | "translatex()", "translatey()", "translatez()", "translate3d()", "turn", |
|
161 | 163 | "unicode-bidi", "unicode-range", "unset", "<uri>", "url()", "<user-ident>", |
|
162 | 164 | ":valid", "::value", "var()", "vertical-align", "vh", "@viewport", |
|
163 | 165 | "visibility", ":visited", "vmax", "vmin", "vw", "white-space", "widows", |
|
164 | 166 | "width", "will-change", "word-break", "word-spacing", "word-wrap", |
|
165 | 167 | "writing-mode", "z-index", |
|
166 | 168 | |
|
167 | 169 | ] |
|
168 | 170 | |
|
169 | 171 | webkit_prefixed_styles = [ |
|
170 | 172 | # Webkit-prefixed styles |
|
171 | 173 | # https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Webkit_Extensions |
|
172 | 174 | "-webkit-animation", "-webkit-animation-delay", "-webkit-animation-direction", |
|
173 | 175 | "-webkit-animation-duration", "-webkit-animation-fill-mode", |
|
174 | 176 | "-webkit-animation-iteration-count", "-webkit-animation-name", |
|
175 | 177 | "-webkit-animation-play-state", "-webkit-animation-timing-function", |
|
176 | 178 | "-webkit-backface-visibility", "-webkit-border-image", "-webkit-column-count", |
|
177 | 179 | "-webkit-column-gap", "-webkit-column-width", "-webkit-column-rule", |
|
178 | 180 | "-webkit-column-rule-width", "-webkit-column-rule-style", |
|
179 | 181 | "-webkit-column-rule-color", "-webkit-columns", "-webkit-column-span", |
|
180 | 182 | "-webkit-font-feature-settings", "-webkit-font-kerning", |
|
181 | 183 | "-webkit-font-size-delta", "-webkit-font-variant-ligatures", |
|
182 | 184 | "-webkit-grid-column", "-webkit-grid-row", "-webkit-hyphens", "-webkit-mask", |
|
183 | 185 | "-webkit-mask-clip", "-webkit-mask-composite", "-webkit-mask-image", |
|
184 | 186 | "-webkit-mask-origin", "-webkit-mask-position", "-webkit-mask-repeat", |
|
185 | 187 | "-webkit-mask-size", "-webkit-perspective", "-webkit-perspective-origin", |
|
186 | 188 | "-webkit-region-fragment", "-webkit-shape-outside", "-webkit-text-emphasis", |
|
187 | 189 | "-webkit-text-emphasis-color", "-webkit-text-emphasis-position", |
|
188 | 190 | "-webkit-text-emphasis-style", "-webkit-transform", "-webkit-transform-origin", |
|
189 | 191 | "-webkit-transform-style", "-webkit-transition", "-webkit-transition-delay", |
|
190 | 192 | "-webkit-transition-duration", "-webkit-transition-property", |
|
191 | 193 | "-webkit-transition-timing-function", "-epub-word-break", "-epub-writing-mode", |
|
192 | 194 | # WebKit-prefixed properties with an unprefixed counterpart |
|
193 | 195 | "-webkit-background-clip", "-webkit-background-origin", |
|
194 | 196 | "-webkit-background-size", "-webkit-border-bottom-left-radius", |
|
195 | 197 | "-webkit-border-bottom-right-radius", "-webkit-border-radius", |
|
196 | 198 | "-webkit-border-top-left-radius", "-webkit-border-top-right-radius", |
|
197 | 199 | "-webkit-box-sizing", "-epub-caption-side", "-webkit-opacity", |
|
198 | 200 | "-epub-text-transform", |
|
199 | 201 | ] |
|
200 | 202 | |
|
201 | 203 | mozilla_prefixed_styles = [ |
|
202 | 204 | "-moz-column-count", "-moz-column-fill", "-moz-column-gap", |
|
203 | 205 | "-moz-column-width", "-moz-column-rule", "-moz-column-rule-width", |
|
204 | 206 | "-moz-column-rule-style", "-moz-column-rule-color", |
|
205 | 207 | "-moz-font-feature-settings", "-moz-font-language-override", "-moz-hyphens", |
|
206 | 208 | "-moz-text-align-last", "-moz-text-decoration-color", |
|
207 | 209 | "-moz-text-decoration-line", "-moz-text-decoration-style", |
|
208 | 210 | ] |
|
209 | 211 | |
|
210 | 212 | all_prefixed_styles = [ |
|
211 | 213 | # From http://peter.sh/experiments/vendor-prefixed-css-property-overview/ |
|
212 | 214 | "-ms-accelerator", "-webkit-app-region", "-webkit-appearance", |
|
213 | 215 | "-webkit-appearance", "-moz-appearance", "-webkit-aspect-ratio", |
|
214 | 216 | "-webkit-backdrop-filter", "backface-visibility", |
|
215 | 217 | "-webkit-backface-visibility", "backface-visibility", "backface-visibility", |
|
216 | 218 | "-webkit-background-composite", "-webkit-background-composite", "-moz-binding", |
|
217 | 219 | "-ms-block-progression", "-webkit-border-after", "-webkit-border-after", |
|
218 | 220 | "-webkit-border-after-color", "-webkit-border-after-color", |
|
219 | 221 | "-webkit-border-after-style", "-webkit-border-after-style", |
|
220 | 222 | "-webkit-border-after-width", "-webkit-border-after-width", |
|
221 | 223 | "-webkit-border-before", "-webkit-border-before", |
|
222 | 224 | "-webkit-border-before-color", "-webkit-border-before-color", |
|
223 | 225 | "-webkit-border-before-style", "-webkit-border-before-style", |
|
224 | 226 | "-webkit-border-before-width", "-webkit-border-before-width", |
|
225 | 227 | "-moz-border-bottom-colors", "-webkit-border-end", "-webkit-border-end", |
|
226 | 228 | "-moz-border-end", "-webkit-border-end-color", "-webkit-border-end-color", |
|
227 | 229 | "-moz-border-end-color", "-webkit-border-end-style", |
|
228 | 230 | "-webkit-border-end-style", "-moz-border-end-style", |
|
229 | 231 | "-webkit-border-end-width", "-webkit-border-end-width", |
|
230 | 232 | "-moz-border-end-width", "-webkit-border-fit", |
|
231 | 233 | "-webkit-border-horizontal-spacing", "-webkit-border-horizontal-spacing", |
|
232 | 234 | "-moz-border-left-colors", "-moz-border-right-colors", "-webkit-border-start", |
|
233 | 235 | "-webkit-border-start", "-moz-border-start", "-webkit-border-start-color", |
|
234 | 236 | "-webkit-border-start-color", "-moz-border-start-color", |
|
235 | 237 | "-webkit-border-start-style", "-webkit-border-start-style", |
|
236 | 238 | "-moz-border-start-style", "-webkit-border-start-width", |
|
237 | 239 | "-webkit-border-start-width", "-moz-border-start-width", |
|
238 | 240 | "-moz-border-top-colors", "-webkit-border-vertical-spacing", |
|
239 | 241 | "-webkit-border-vertical-spacing", "-webkit-box-align", "-webkit-box-align", |
|
240 | 242 | "-moz-box-align", "-webkit-box-decoration-break", |
|
241 | 243 | "-webkit-box-decoration-break", "box-decoration-break", |
|
242 | 244 | "-webkit-box-direction", "-webkit-box-direction", "-moz-box-direction", |
|
243 | 245 | "-webkit-box-flex", "-webkit-box-flex", "-moz-box-flex", |
|
244 | 246 | "-webkit-box-flex-group", "-webkit-box-flex-group", "-webkit-box-lines", |
|
245 | 247 | "-webkit-box-lines", "-webkit-box-ordinal-group", "-webkit-box-ordinal-group", |
|
246 | 248 | "-moz-box-ordinal-group", "-webkit-box-orient", "-webkit-box-orient", |
|
247 | 249 | "-moz-box-orient", "-webkit-box-pack", "-webkit-box-pack", "-moz-box-pack", |
|
248 | 250 | "-webkit-box-reflect", "-webkit-box-reflect", "clip-path", "-webkit-clip-path", |
|
249 | 251 | "clip-path", "clip-path", "-webkit-color-correction", "-webkit-column-axis", |
|
250 | 252 | "-webkit-column-break-after", "-webkit-column-break-after", |
|
251 | 253 | "-webkit-column-break-before", "-webkit-column-break-before", |
|
252 | 254 | "-webkit-column-break-inside", "-webkit-column-break-inside", |
|
253 | 255 | "-webkit-column-count", "column-count", "-moz-column-count", "column-count", |
|
254 | 256 | "column-fill", "column-fill", "-moz-column-fill", "column-fill", |
|
255 | 257 | "-webkit-column-gap", "column-gap", "-moz-column-gap", "column-gap", |
|
256 | 258 | "-webkit-column-rule", "column-rule", "-moz-column-rule", "column-rule", |
|
257 | 259 | "-webkit-column-rule-color", "column-rule-color", "-moz-column-rule-color", |
|
258 | 260 | "column-rule-color", "-webkit-column-rule-style", "column-rule-style", |
|
259 | 261 | "-moz-column-rule-style", "column-rule-style", "-webkit-column-rule-width", |
|
260 | 262 | "column-rule-width", "-moz-column-rule-width", "column-rule-width", |
|
261 | 263 | "-webkit-column-span", "column-span", "column-span", "-webkit-column-width", |
|
262 | 264 | "column-width", "-moz-column-width", "column-width", "-webkit-columns", |
|
263 | 265 | "columns", "-moz-columns", "columns", "-ms-content-zoom-chaining", |
|
264 | 266 | "-ms-content-zoom-limit", "-ms-content-zoom-limit-max", |
|
265 | 267 | "-ms-content-zoom-limit-min", "-ms-content-zoom-snap", |
|
266 | 268 | "-ms-content-zoom-snap-points", "-ms-content-zoom-snap-type", |
|
267 | 269 | "-ms-content-zooming", "-moz-control-character-visibility", |
|
268 | 270 | "-webkit-cursor-visibility", "-webkit-dashboard-region", "filter", |
|
269 | 271 | "-webkit-filter", "filter", "filter", "-ms-flex-align", "-ms-flex-item-align", |
|
270 | 272 | "-ms-flex-line-pack", "-ms-flex-negative", "-ms-flex-order", "-ms-flex-pack", |
|
271 | 273 | "-ms-flex-positive", "-ms-flex-preferred-size", "-moz-float-edge", |
|
272 | 274 | "-webkit-flow-from", "-ms-flow-from", "-webkit-flow-into", "-ms-flow-into", |
|
273 | 275 | "-webkit-font-feature-settings", "-webkit-font-feature-settings", |
|
274 | 276 | "font-feature-settings", "font-feature-settings", "font-kerning", |
|
275 | 277 | "-webkit-font-kerning", "font-kerning", "-webkit-font-size-delta", |
|
276 | 278 | "-webkit-font-size-delta", "-webkit-font-smoothing", "-webkit-font-smoothing", |
|
277 | 279 | "font-variant-ligatures", "-webkit-font-variant-ligatures", |
|
278 | 280 | "font-variant-ligatures", "-moz-force-broken-image-icon", "grid", |
|
279 | 281 | "-webkit-grid", "grid", "grid-area", "-webkit-grid-area", "grid-area", |
|
280 | 282 | "grid-auto-columns", "-webkit-grid-auto-columns", "grid-auto-columns", |
|
281 | 283 | "grid-auto-flow", "-webkit-grid-auto-flow", "grid-auto-flow", "grid-auto-rows", |
|
282 | 284 | "-webkit-grid-auto-rows", "grid-auto-rows", "grid-column", |
|
283 | 285 | "-webkit-grid-column", "grid-column", "-ms-grid-column", |
|
284 | 286 | "-ms-grid-column-align", "grid-column-end", "-webkit-grid-column-end", |
|
285 | 287 | "grid-column-end", "-ms-grid-column-span", "grid-column-start", |
|
286 | 288 | "-webkit-grid-column-start", "grid-column-start", "-ms-grid-columns", |
|
287 | 289 | "grid-row", "-webkit-grid-row", "grid-row", "-ms-grid-row", |
|
288 | 290 | "-ms-grid-row-align", "grid-row-end", "-webkit-grid-row-end", "grid-row-end", |
|
289 | 291 | "-ms-grid-row-span", "grid-row-start", "-webkit-grid-row-start", |
|
290 | 292 | "grid-row-start", "-ms-grid-rows", "grid-template", "-webkit-grid-template", |
|
291 | 293 | "grid-template", "grid-template-areas", "-webkit-grid-template-areas", |
|
292 | 294 | "grid-template-areas", "grid-template-columns", |
|
293 | 295 | "-webkit-grid-template-columns", "grid-template-columns", "grid-template-rows", |
|
294 | 296 | "-webkit-grid-template-rows", "grid-template-rows", "-ms-high-contrast-adjust", |
|
295 | 297 | "-webkit-highlight", "-webkit-hyphenate-character", |
|
296 | 298 | "-webkit-hyphenate-character", "-webkit-hyphenate-limit-after", |
|
297 | 299 | "-webkit-hyphenate-limit-before", "-ms-hyphenate-limit-chars", |
|
298 | 300 | "-webkit-hyphenate-limit-lines", "-ms-hyphenate-limit-lines", |
|
299 | 301 | "-ms-hyphenate-limit-zone", "-webkit-hyphens", "-moz-hyphens", "-ms-hyphens", |
|
300 | 302 | "-moz-image-region", "-ms-ime-align", "-webkit-initial-letter", |
|
301 | 303 | "-ms-interpolation-mode", "justify-self", "-webkit-justify-self", |
|
302 | 304 | "-webkit-line-align", "-webkit-line-box-contain", "-webkit-line-box-contain", |
|
303 | 305 | "-webkit-line-break", "-webkit-line-break", "line-break", "-webkit-line-clamp", |
|
304 | 306 | "-webkit-line-clamp", "-webkit-line-grid", "-webkit-line-snap", |
|
305 | 307 | "-webkit-locale", "-webkit-locale", "-webkit-logical-height", |
|
306 | 308 | "-webkit-logical-height", "-webkit-logical-width", "-webkit-logical-width", |
|
307 | 309 | "-webkit-margin-after", "-webkit-margin-after", |
|
308 | 310 | "-webkit-margin-after-collapse", "-webkit-margin-after-collapse", |
|
309 | 311 | "-webkit-margin-before", "-webkit-margin-before", |
|
310 | 312 | "-webkit-margin-before-collapse", "-webkit-margin-before-collapse", |
|
311 | 313 | "-webkit-margin-bottom-collapse", "-webkit-margin-bottom-collapse", |
|
312 | 314 | "-webkit-margin-collapse", "-webkit-margin-collapse", "-webkit-margin-end", |
|
313 | 315 | "-webkit-margin-end", "-moz-margin-end", "-webkit-margin-start", |
|
314 | 316 | "-webkit-margin-start", "-moz-margin-start", "-webkit-margin-top-collapse", |
|
315 | 317 | "-webkit-margin-top-collapse", "-webkit-marquee", "-webkit-marquee-direction", |
|
316 | 318 | "-webkit-marquee-increment", "-webkit-marquee-repetition", |
|
317 | 319 | "-webkit-marquee-speed", "-webkit-marquee-style", "mask", "-webkit-mask", |
|
318 | 320 | "mask", "-webkit-mask-box-image", "-webkit-mask-box-image", |
|
319 | 321 | "-webkit-mask-box-image-outset", "-webkit-mask-box-image-outset", |
|
320 | 322 | "-webkit-mask-box-image-repeat", "-webkit-mask-box-image-repeat", |
|
321 | 323 | "-webkit-mask-box-image-slice", "-webkit-mask-box-image-slice", |
|
322 | 324 | "-webkit-mask-box-image-source", "-webkit-mask-box-image-source", |
|
323 | 325 | "-webkit-mask-box-image-width", "-webkit-mask-box-image-width", |
|
324 | 326 | "-webkit-mask-clip", "-webkit-mask-clip", "-webkit-mask-composite", |
|
325 | 327 | "-webkit-mask-composite", "-webkit-mask-image", "-webkit-mask-image", |
|
326 | 328 | "-webkit-mask-origin", "-webkit-mask-origin", "-webkit-mask-position", |
|
327 | 329 | "-webkit-mask-position", "-webkit-mask-position-x", "-webkit-mask-position-x", |
|
328 | 330 | "-webkit-mask-position-y", "-webkit-mask-position-y", "-webkit-mask-repeat", |
|
329 | 331 | "-webkit-mask-repeat", "-webkit-mask-repeat-x", "-webkit-mask-repeat-x", |
|
330 | 332 | "-webkit-mask-repeat-y", "-webkit-mask-repeat-y", "-webkit-mask-size", |
|
331 | 333 | "-webkit-mask-size", "mask-source-type", "-webkit-mask-source-type", |
|
332 | 334 | "-moz-math-display", "-moz-math-variant", "-webkit-max-logical-height", |
|
333 | 335 | "-webkit-max-logical-height", "-webkit-max-logical-width", |
|
334 | 336 | "-webkit-max-logical-width", "-webkit-min-logical-height", |
|
335 | 337 | "-webkit-min-logical-height", "-webkit-min-logical-width", |
|
336 | 338 | "-webkit-min-logical-width", "-webkit-nbsp-mode", "-moz-orient", |
|
337 | 339 | "-moz-osx-font-smoothing", "-moz-outline-radius", |
|
338 | 340 | "-moz-outline-radius-bottomleft", "-moz-outline-radius-bottomright", |
|
339 | 341 | "-moz-outline-radius-topleft", "-moz-outline-radius-topright", |
|
340 | 342 | "-webkit-overflow-scrolling", "-ms-overflow-style", "-webkit-padding-after", |
|
341 | 343 | "-webkit-padding-after", "-webkit-padding-before", "-webkit-padding-before", |
|
342 | 344 | "-webkit-padding-end", "-webkit-padding-end", "-moz-padding-end", |
|
343 | 345 | "-webkit-padding-start", "-webkit-padding-start", "-moz-padding-start", |
|
344 | 346 | "perspective", "-webkit-perspective", "perspective", "perspective", |
|
345 | 347 | "perspective-origin", "-webkit-perspective-origin", "perspective-origin", |
|
346 | 348 | "perspective-origin", "-webkit-perspective-origin-x", |
|
347 | 349 | "-webkit-perspective-origin-x", "perspective-origin-x", |
|
348 | 350 | "-webkit-perspective-origin-y", "-webkit-perspective-origin-y", |
|
349 | 351 | "perspective-origin-y", "-webkit-print-color-adjust", |
|
350 | 352 | "-webkit-print-color-adjust", "-webkit-region-break-after", |
|
351 | 353 | "-webkit-region-break-before", "-webkit-region-break-inside", |
|
352 | 354 | "-webkit-region-fragment", "-webkit-rtl-ordering", "-webkit-rtl-ordering", |
|
353 | 355 | "-webkit-ruby-position", "-webkit-ruby-position", "ruby-position", |
|
354 | 356 | "-moz-script-level", "-moz-script-min-size", "-moz-script-size-multiplier", |
|
355 | 357 | "-ms-scroll-chaining", "-ms-scroll-limit", "-ms-scroll-limit-x-max", |
|
356 | 358 | "-ms-scroll-limit-x-min", "-ms-scroll-limit-y-max", "-ms-scroll-limit-y-min", |
|
357 | 359 | "-ms-scroll-rails", "-webkit-scroll-snap-coordinate", |
|
358 | 360 | "-webkit-scroll-snap-destination", "-webkit-scroll-snap-points-x", |
|
359 | 361 | "-ms-scroll-snap-points-x", "-webkit-scroll-snap-points-y", |
|
360 | 362 | "-ms-scroll-snap-points-y", "-webkit-scroll-snap-type", "-ms-scroll-snap-type", |
|
361 | 363 | "-ms-scroll-snap-x", "-ms-scroll-snap-y", "-ms-scroll-translation", |
|
362 | 364 | "-ms-scrollbar-3dlight-color", "shape-image-threshold", |
|
363 | 365 | "-webkit-shape-image-threshold", "shape-margin", "-webkit-shape-margin", |
|
364 | 366 | "shape-outside", "-webkit-shape-outside", "-moz-stack-sizing", "tab-size", |
|
365 | 367 | "tab-size", "-moz-tab-size", "-webkit-tap-highlight-color", |
|
366 | 368 | "-webkit-tap-highlight-color", "text-align-last", "-webkit-text-align-last", |
|
367 | 369 | "-moz-text-align-last", "text-align-last", "-webkit-text-combine", |
|
368 | 370 | "-webkit-text-combine", "-ms-text-combine-horizontal", "text-decoration-color", |
|
369 | 371 | "-webkit-text-decoration-color", "text-decoration-color", |
|
370 | 372 | "text-decoration-color", "text-decoration-line", |
|
371 | 373 | "-webkit-text-decoration-line", "text-decoration-line", |
|
372 | 374 | "-webkit-text-decoration-skip", "text-decoration-style", |
|
373 | 375 | "-webkit-text-decoration-style", "text-decoration-style", |
|
374 | 376 | "-webkit-text-decorations-in-effect", "-webkit-text-decorations-in-effect", |
|
375 | 377 | "-webkit-text-emphasis", "text-emphasis", "-webkit-text-emphasis-color", |
|
376 | 378 | "text-emphasis-color", "-webkit-text-emphasis-position", |
|
377 | 379 | "text-emphasis-position", "-webkit-text-emphasis-style", "text-emphasis-style", |
|
378 | 380 | "-webkit-text-fill-color", "-webkit-text-fill-color", "text-justify", |
|
379 | 381 | "-webkit-text-justify", "text-justify", "-webkit-text-orientation", |
|
380 | 382 | "-webkit-text-orientation", "text-orientation", "-webkit-text-security", |
|
381 | 383 | "-webkit-text-security", "-webkit-text-size-adjust", "-moz-text-size-adjust", |
|
382 | 384 | "-ms-text-size-adjust", "-webkit-text-stroke", "-webkit-text-stroke", |
|
383 | 385 | "-webkit-text-stroke-color", "-webkit-text-stroke-color", |
|
384 | 386 | "-webkit-text-stroke-width", "-webkit-text-stroke-width", |
|
385 | 387 | "text-underline-position", "-webkit-text-underline-position", |
|
386 | 388 | "text-underline-position", "-webkit-touch-callout", "-ms-touch-select", |
|
387 | 389 | "transform", "-webkit-transform", "transform", "transform", "transform-origin", |
|
388 | 390 | "-webkit-transform-origin", "transform-origin", "transform-origin", |
|
389 | 391 | "-webkit-transform-origin-x", "-webkit-transform-origin-x", |
|
390 | 392 | "transform-origin-x", "-webkit-transform-origin-y", |
|
391 | 393 | "-webkit-transform-origin-y", "transform-origin-y", |
|
392 | 394 | "-webkit-transform-origin-z", "-webkit-transform-origin-z", |
|
393 | 395 | "transform-origin-z", "transform-style", "-webkit-transform-style", |
|
394 | 396 | "transform-style", "transform-style", "-webkit-user-drag", "-webkit-user-drag", |
|
395 | 397 | "-moz-user-focus", "-moz-user-input", "-webkit-user-modify", |
|
396 | 398 | "-webkit-user-modify", "-moz-user-modify", "-webkit-user-select", |
|
397 | 399 | "-webkit-user-select", "-moz-user-select", "-ms-user-select", |
|
398 | 400 | "-moz-window-dragging", "-moz-window-shadow", "-ms-wrap-flow", |
|
399 | 401 | "-ms-wrap-margin", "-ms-wrap-through", "writing-mode", "-webkit-writing-mode", |
|
400 | 402 | "writing-mode", "writing-mode", |
|
401 | 403 | ] |
|
402 | 404 | |
|
403 | 405 | all_styles = standard_styles + all_prefixed_styles No newline at end of file |
@@ -1,106 +1,77 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | # Copyright (C) 2010-2018 RhodeCode GmbH |
|
4 | 4 | # |
|
5 | 5 | # This program is free software: you can redistribute it and/or modify |
|
6 | 6 | # it under the terms of the GNU Affero General Public License, version 3 |
|
7 | 7 | # (only), as published by the Free Software Foundation. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU Affero General Public License |
|
15 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
16 | 16 | # |
|
17 | 17 | # This program is dual-licensed. If you wish to learn more about the |
|
18 | 18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
19 | 19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
20 | 20 | |
|
21 | 21 | import re |
|
22 | 22 | |
|
23 | 23 | import markdown |
|
24 | 24 | |
|
25 |
from mdx_gfm import GithubFlavoredMarkdownExtension # |
|
|
26 | ||
|
27 | ||
|
28 | class FlavoredCheckboxExtension(markdown.Extension): | |
|
29 | ||
|
30 | def extendMarkdown(self, md, md_globals): | |
|
31 | md.preprocessors.add('checklist', | |
|
32 | FlavoredCheckboxPreprocessor(md), '<reference') | |
|
33 | md.postprocessors.add('checklist', | |
|
34 | FlavoredCheckboxPostprocessor(md), '>unescape') | |
|
35 | ||
|
36 | ||
|
37 | class FlavoredCheckboxPreprocessor(markdown.preprocessors.Preprocessor): | |
|
38 | """ | |
|
39 | Replaces occurrences of [ ] or [x] to checkbox input | |
|
40 | """ | |
|
41 | ||
|
42 | pattern = re.compile(r'^([*-]) \[([ x])\]') | |
|
43 | ||
|
44 | def run(self, lines): | |
|
45 | return [self._transform_line(line) for line in lines] | |
|
46 | ||
|
47 | def _transform_line(self, line): | |
|
48 | return self.pattern.sub(self._replacer, line) | |
|
49 | ||
|
50 | def _replacer(self, match): | |
|
51 | list_prefix, state = match.groups() | |
|
52 | checked = '' if state == ' ' else ' checked="checked"' | |
|
53 | return '%s <input type="checkbox" disabled="disabled"%s>' % (list_prefix, | |
|
54 | checked) | |
|
25 | from mdx_gfm import GithubFlavoredMarkdownExtension # pragma: no cover | |
|
55 | 26 | |
|
56 | 27 | |
|
57 | 28 | class FlavoredCheckboxPostprocessor(markdown.postprocessors.Postprocessor): |
|
58 | 29 | """ |
|
59 | 30 | Adds `flavored_checkbox_list` class to list of checkboxes |
|
60 | 31 | """ |
|
61 | 32 | |
|
62 | 33 | pattern = re.compile(r'^([*-]) \[([ x])\]') |
|
63 | 34 | |
|
64 | 35 | def run(self, html): |
|
65 | 36 | before = '<ul>\n<li><input type="checkbox"' |
|
66 | 37 | after = '<ul class="flavored_checkbox_list">\n<li><input type="checkbox"' |
|
67 | 38 | return html.replace(before, after) |
|
68 | 39 | |
|
69 | 40 | |
|
70 | 41 | # Global Vars |
|
71 | 42 | URLIZE_RE = '(%s)' % '|'.join([ |
|
72 | 43 | r'<(?:f|ht)tps?://[^>]*>', |
|
73 | 44 | r'\b(?:f|ht)tps?://[^)<>\s]+[^.,)<>\s]', |
|
74 | 45 | r'\bwww\.[^)<>\s]+[^.,)<>\s]', |
|
75 | 46 | r'[^(<\s]+\.(?:com|net|org)\b', |
|
76 | 47 | ]) |
|
77 | 48 | |
|
78 | 49 | |
|
79 | 50 | class UrlizePattern(markdown.inlinepatterns.Pattern): |
|
80 | 51 | """ Return a link Element given an autolink (`http://example/com`). """ |
|
81 | 52 | def handleMatch(self, m): |
|
82 | 53 | url = m.group(2) |
|
83 | 54 | |
|
84 | 55 | if url.startswith('<'): |
|
85 | 56 | url = url[1:-1] |
|
86 | 57 | |
|
87 | 58 | text = url |
|
88 | 59 | |
|
89 | 60 | if not url.split('://')[0] in ('http','https','ftp'): |
|
90 | 61 | if '@' in url and not '/' in url: |
|
91 | 62 | url = 'mailto:' + url |
|
92 | 63 | else: |
|
93 | 64 | url = 'http://' + url |
|
94 | 65 | |
|
95 | 66 | el = markdown.util.etree.Element("a") |
|
96 | 67 | el.set('href', url) |
|
97 | 68 | el.text = markdown.util.AtomicString(text) |
|
98 | 69 | return el |
|
99 | 70 | |
|
100 | 71 | |
|
101 | 72 | class UrlizeExtension(markdown.Extension): |
|
102 | 73 | """ Urlize Extension for Python-Markdown. """ |
|
103 | 74 | |
|
104 | 75 | def extendMarkdown(self, md, md_globals): |
|
105 | 76 | """ Replace autolink with UrlizePattern """ |
|
106 | 77 | md.inlinePatterns['autolink'] = UrlizePattern(URLIZE_RE, md) |
General Comments 0
You need to be logged in to leave comments.
Login now