##// END OF EJS Templates
markdown: fixed sanitization of checkbox extensions that removed "checked" attribute....
dan -
r3528:74d317ee stable
parent child Browse files
Show More
@@ -1,405 +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 63 "input",
64 64 ]
65 65
66 66 markdown_attrs = {
67 67 "*": ["class", "style", "align"],
68 68 "img": ["src", "alt", "title"],
69 69 "a": ["href", "alt", "title", "name"],
70 70 "abbr": ["title"],
71 71 "acronym": ["title"],
72 72 "pre": ["lang"],
73 "input": ["type", "disabled"]
73 "input": ["type", "disabled", "checked"]
74 74 }
75 75
76 76 standard_styles = [
77 77 # Taken from https://developer.mozilla.org/en-US/docs/Web/CSS/Reference
78 78 # This includes pseudo-classes, pseudo-elements, @-rules, units, and
79 79 # selectors in addition to properties, but it doesn't matter for our
80 80 # purposes -- we don't need to filter styles..
81 81 ":active", "::after (:after)", "align-content", "align-items", "align-self",
82 82 "all", "<angle>", "animation", "animation-delay", "animation-direction",
83 83 "animation-duration", "animation-fill-mode", "animation-iteration-count",
84 84 "animation-name", "animation-play-state", "animation-timing-function",
85 85 "@annotation", "annotation()", "attr()", "::backdrop", "backface-visibility",
86 86 "background", "background-attachment", "background-blend-mode",
87 87 "background-clip", "background-color", "background-image", "background-origin",
88 88 "background-position", "background-repeat", "background-size", "<basic-shape>",
89 89 "::before (:before)", "<blend-mode>", "blur()", "border", "border-bottom",
90 90 "border-bottom-color", "border-bottom-left-radius",
91 91 "border-bottom-right-radius", "border-bottom-style", "border-bottom-width",
92 92 "border-collapse", "border-color", "border-image", "border-image-outset",
93 93 "border-image-repeat", "border-image-slice", "border-image-source",
94 94 "border-image-width", "border-left", "border-left-color", "border-left-style",
95 95 "border-left-width", "border-radius", "border-right", "border-right-color",
96 96 "border-right-style", "border-right-width", "border-spacing", "border-style",
97 97 "border-top", "border-top-color", "border-top-left-radius",
98 98 "border-top-right-radius", "border-top-style", "border-top-width",
99 99 "border-width", "bottom", "box-decoration-break", "box-shadow", "box-sizing",
100 100 "break-after", "break-before", "break-inside", "brightness()", "calc()",
101 101 "caption-side", "ch", "@character-variant", "character-variant()", "@charset",
102 102 ":checked", "circle()", "clear", "clip", "clip-path", "cm", "color", "<color>",
103 103 "columns", "column-count", "column-fill", "column-gap", "column-rule",
104 104 "column-rule-color", "column-rule-style", "column-rule-width", "column-span",
105 105 "column-width", "content", "contrast()", "<counter>", "counter-increment",
106 106 "counter-reset", "@counter-style", "cubic-bezier()", "cursor",
107 107 "<custom-ident>", ":default", "deg", ":dir()", "direction", ":disabled",
108 108 "display", "@document", "dpcm", "dpi", "dppx", "drop-shadow()", "element()",
109 109 "ellipse()", "em", ":empty", "empty-cells", ":enabled", "ex", "filter",
110 110 ":first", ":first-child", "::first-letter", "::first-line",
111 111 ":first-of-type", "flex", "flex-basis", "flex-direction",
112 112 "flex-flow", "flex-grow", "flex-shrink", "flex-wrap", "float", ":focus",
113 113 "font", "@font-face", "font-family", "font-feature-settings",
114 114 "@font-feature-values", "font-kerning", "font-language-override", "font-size",
115 115 "font-size-adjust", "font-stretch", "font-style", "font-synthesis",
116 116 "font-variant", "font-variant-alternates", "font-variant-caps",
117 117 "font-variant-east-asian", "font-variant-ligatures", "font-variant-numeric",
118 118 "font-variant-position", "font-weight", "<frequency>", ":fullscreen", "grad",
119 119 "<gradient>", "grayscale()", "grid", "grid-area", "grid-auto-columns",
120 120 "grid-auto-flow", "grid-auto-position", "grid-auto-rows", "grid-column",
121 121 "grid-column-start", "grid-column-end", "grid-row", "grid-row-start",
122 122 "grid-row-end", "grid-template", "grid-template-areas", "grid-template-rows",
123 123 "grid-template-columns", "height", ":hover", "hsl()", "hsla()", "hue-rotate()",
124 124 "hyphens", "hz", "<image>", "image()", "image-rendering", "image-resolution",
125 125 "image-orientation", "ime-mode", "@import", "in", ":indeterminate", "inherit",
126 126 "initial", ":in-range", "inset()", "<integer>", ":invalid", "invert()",
127 127 "isolation", "justify-content", "@keyframes", "khz", ":lang()", ":last-child",
128 128 ":last-of-type", "left", ":left", "<length>", "letter-spacing",
129 129 "linear-gradient()", "line-break", "line-height", ":link", "list-style",
130 130 "list-style-image", "list-style-position", "list-style-type", "margin",
131 131 "margin-bottom", "margin-left", "margin-right", "margin-top", "marks", "mask",
132 132 "mask-type", "matrix()", "matrix3d()", "max-height", "max-width", "@media",
133 133 "min-height", "minmax()", "min-width", "mix-blend-mode", "mm", "ms",
134 134 "@namespace", ":not()", ":nth-child()", ":nth-last-child()",
135 135 ":nth-last-of-type()", ":nth-of-type()", "<number>", "object-fit",
136 136 "object-position", ":only-child", ":only-of-type", "opacity", "opacity()",
137 137 ":optional", "order", "@ornaments", "ornaments()", "orphans", "outline",
138 138 "outline-color", "outline-offset", "outline-style", "outline-width",
139 139 ":out-of-range", "overflow", "overflow-wrap", "overflow-x", "overflow-y",
140 140 "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
141 141 "@page", "page-break-after", "page-break-before", "page-break-inside", "pc",
142 142 "<percentage>", "perspective", "perspective()", "perspective-origin",
143 143 "pointer-events", "polygon()", "position", "<position>", "pt", "px", "quotes",
144 144 "rad", "radial-gradient()", "<ratio>", ":read-only", ":read-write", "rect()",
145 145 "rem", "repeat()", "::repeat-index", "::repeat-item",
146 146 "repeating-linear-gradient()", "repeating-radial-gradient()", ":required",
147 147 "resize", "<resolution>", "rgb()", "rgba()", "right", ":right", ":root",
148 148 "rotate()", "rotatex()", "rotatey()", "rotatez()", "rotate3d()", "ruby-align",
149 149 "ruby-merge", "ruby-position", "s", "saturate()", "scale()", "scalex()",
150 150 "scaley()", "scalez()", "scale3d()", ":scope", "scroll-behavior",
151 151 "::selection", "sepia()", "<shape>", "shape-image-threshold", "shape-margin",
152 152 "shape-outside", "skew()", "skewx()", "skewy()", "steps()", "<string>",
153 153 "@styleset", "styleset()", "@stylistic", "stylistic()", "@supports", "@swash",
154 154 "swash()", "symbol()", "table-layout", "tab-size", ":target", "text-align",
155 155 "text-align-last", "text-combine-upright", "text-decoration",
156 156 "text-decoration-color", "text-decoration-line", "text-decoration-style",
157 157 "text-indent", "text-orientation", "text-overflow", "text-rendering",
158 158 "text-shadow", "text-transform", "text-underline-position", "<time>",
159 159 "<timing-function>", "top", "touch-action", "transform", "transform-origin",
160 160 "transform-style", "transition", "transition-delay", "transition-duration",
161 161 "transition-property", "transition-timing-function", "translate()",
162 162 "translatex()", "translatey()", "translatez()", "translate3d()", "turn",
163 163 "unicode-bidi", "unicode-range", "unset", "<uri>", "url()", "<user-ident>",
164 164 ":valid", "::value", "var()", "vertical-align", "vh", "@viewport",
165 165 "visibility", ":visited", "vmax", "vmin", "vw", "white-space", "widows",
166 166 "width", "will-change", "word-break", "word-spacing", "word-wrap",
167 167 "writing-mode", "z-index",
168 168
169 169 ]
170 170
171 171 webkit_prefixed_styles = [
172 172 # Webkit-prefixed styles
173 173 # https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Webkit_Extensions
174 174 "-webkit-animation", "-webkit-animation-delay", "-webkit-animation-direction",
175 175 "-webkit-animation-duration", "-webkit-animation-fill-mode",
176 176 "-webkit-animation-iteration-count", "-webkit-animation-name",
177 177 "-webkit-animation-play-state", "-webkit-animation-timing-function",
178 178 "-webkit-backface-visibility", "-webkit-border-image", "-webkit-column-count",
179 179 "-webkit-column-gap", "-webkit-column-width", "-webkit-column-rule",
180 180 "-webkit-column-rule-width", "-webkit-column-rule-style",
181 181 "-webkit-column-rule-color", "-webkit-columns", "-webkit-column-span",
182 182 "-webkit-font-feature-settings", "-webkit-font-kerning",
183 183 "-webkit-font-size-delta", "-webkit-font-variant-ligatures",
184 184 "-webkit-grid-column", "-webkit-grid-row", "-webkit-hyphens", "-webkit-mask",
185 185 "-webkit-mask-clip", "-webkit-mask-composite", "-webkit-mask-image",
186 186 "-webkit-mask-origin", "-webkit-mask-position", "-webkit-mask-repeat",
187 187 "-webkit-mask-size", "-webkit-perspective", "-webkit-perspective-origin",
188 188 "-webkit-region-fragment", "-webkit-shape-outside", "-webkit-text-emphasis",
189 189 "-webkit-text-emphasis-color", "-webkit-text-emphasis-position",
190 190 "-webkit-text-emphasis-style", "-webkit-transform", "-webkit-transform-origin",
191 191 "-webkit-transform-style", "-webkit-transition", "-webkit-transition-delay",
192 192 "-webkit-transition-duration", "-webkit-transition-property",
193 193 "-webkit-transition-timing-function", "-epub-word-break", "-epub-writing-mode",
194 194 # WebKit-prefixed properties with an unprefixed counterpart
195 195 "-webkit-background-clip", "-webkit-background-origin",
196 196 "-webkit-background-size", "-webkit-border-bottom-left-radius",
197 197 "-webkit-border-bottom-right-radius", "-webkit-border-radius",
198 198 "-webkit-border-top-left-radius", "-webkit-border-top-right-radius",
199 199 "-webkit-box-sizing", "-epub-caption-side", "-webkit-opacity",
200 200 "-epub-text-transform",
201 201 ]
202 202
203 203 mozilla_prefixed_styles = [
204 204 "-moz-column-count", "-moz-column-fill", "-moz-column-gap",
205 205 "-moz-column-width", "-moz-column-rule", "-moz-column-rule-width",
206 206 "-moz-column-rule-style", "-moz-column-rule-color",
207 207 "-moz-font-feature-settings", "-moz-font-language-override", "-moz-hyphens",
208 208 "-moz-text-align-last", "-moz-text-decoration-color",
209 209 "-moz-text-decoration-line", "-moz-text-decoration-style",
210 210 ]
211 211
212 212 all_prefixed_styles = [
213 213 # From http://peter.sh/experiments/vendor-prefixed-css-property-overview/
214 214 "-ms-accelerator", "-webkit-app-region", "-webkit-appearance",
215 215 "-webkit-appearance", "-moz-appearance", "-webkit-aspect-ratio",
216 216 "-webkit-backdrop-filter", "backface-visibility",
217 217 "-webkit-backface-visibility", "backface-visibility", "backface-visibility",
218 218 "-webkit-background-composite", "-webkit-background-composite", "-moz-binding",
219 219 "-ms-block-progression", "-webkit-border-after", "-webkit-border-after",
220 220 "-webkit-border-after-color", "-webkit-border-after-color",
221 221 "-webkit-border-after-style", "-webkit-border-after-style",
222 222 "-webkit-border-after-width", "-webkit-border-after-width",
223 223 "-webkit-border-before", "-webkit-border-before",
224 224 "-webkit-border-before-color", "-webkit-border-before-color",
225 225 "-webkit-border-before-style", "-webkit-border-before-style",
226 226 "-webkit-border-before-width", "-webkit-border-before-width",
227 227 "-moz-border-bottom-colors", "-webkit-border-end", "-webkit-border-end",
228 228 "-moz-border-end", "-webkit-border-end-color", "-webkit-border-end-color",
229 229 "-moz-border-end-color", "-webkit-border-end-style",
230 230 "-webkit-border-end-style", "-moz-border-end-style",
231 231 "-webkit-border-end-width", "-webkit-border-end-width",
232 232 "-moz-border-end-width", "-webkit-border-fit",
233 233 "-webkit-border-horizontal-spacing", "-webkit-border-horizontal-spacing",
234 234 "-moz-border-left-colors", "-moz-border-right-colors", "-webkit-border-start",
235 235 "-webkit-border-start", "-moz-border-start", "-webkit-border-start-color",
236 236 "-webkit-border-start-color", "-moz-border-start-color",
237 237 "-webkit-border-start-style", "-webkit-border-start-style",
238 238 "-moz-border-start-style", "-webkit-border-start-width",
239 239 "-webkit-border-start-width", "-moz-border-start-width",
240 240 "-moz-border-top-colors", "-webkit-border-vertical-spacing",
241 241 "-webkit-border-vertical-spacing", "-webkit-box-align", "-webkit-box-align",
242 242 "-moz-box-align", "-webkit-box-decoration-break",
243 243 "-webkit-box-decoration-break", "box-decoration-break",
244 244 "-webkit-box-direction", "-webkit-box-direction", "-moz-box-direction",
245 245 "-webkit-box-flex", "-webkit-box-flex", "-moz-box-flex",
246 246 "-webkit-box-flex-group", "-webkit-box-flex-group", "-webkit-box-lines",
247 247 "-webkit-box-lines", "-webkit-box-ordinal-group", "-webkit-box-ordinal-group",
248 248 "-moz-box-ordinal-group", "-webkit-box-orient", "-webkit-box-orient",
249 249 "-moz-box-orient", "-webkit-box-pack", "-webkit-box-pack", "-moz-box-pack",
250 250 "-webkit-box-reflect", "-webkit-box-reflect", "clip-path", "-webkit-clip-path",
251 251 "clip-path", "clip-path", "-webkit-color-correction", "-webkit-column-axis",
252 252 "-webkit-column-break-after", "-webkit-column-break-after",
253 253 "-webkit-column-break-before", "-webkit-column-break-before",
254 254 "-webkit-column-break-inside", "-webkit-column-break-inside",
255 255 "-webkit-column-count", "column-count", "-moz-column-count", "column-count",
256 256 "column-fill", "column-fill", "-moz-column-fill", "column-fill",
257 257 "-webkit-column-gap", "column-gap", "-moz-column-gap", "column-gap",
258 258 "-webkit-column-rule", "column-rule", "-moz-column-rule", "column-rule",
259 259 "-webkit-column-rule-color", "column-rule-color", "-moz-column-rule-color",
260 260 "column-rule-color", "-webkit-column-rule-style", "column-rule-style",
261 261 "-moz-column-rule-style", "column-rule-style", "-webkit-column-rule-width",
262 262 "column-rule-width", "-moz-column-rule-width", "column-rule-width",
263 263 "-webkit-column-span", "column-span", "column-span", "-webkit-column-width",
264 264 "column-width", "-moz-column-width", "column-width", "-webkit-columns",
265 265 "columns", "-moz-columns", "columns", "-ms-content-zoom-chaining",
266 266 "-ms-content-zoom-limit", "-ms-content-zoom-limit-max",
267 267 "-ms-content-zoom-limit-min", "-ms-content-zoom-snap",
268 268 "-ms-content-zoom-snap-points", "-ms-content-zoom-snap-type",
269 269 "-ms-content-zooming", "-moz-control-character-visibility",
270 270 "-webkit-cursor-visibility", "-webkit-dashboard-region", "filter",
271 271 "-webkit-filter", "filter", "filter", "-ms-flex-align", "-ms-flex-item-align",
272 272 "-ms-flex-line-pack", "-ms-flex-negative", "-ms-flex-order", "-ms-flex-pack",
273 273 "-ms-flex-positive", "-ms-flex-preferred-size", "-moz-float-edge",
274 274 "-webkit-flow-from", "-ms-flow-from", "-webkit-flow-into", "-ms-flow-into",
275 275 "-webkit-font-feature-settings", "-webkit-font-feature-settings",
276 276 "font-feature-settings", "font-feature-settings", "font-kerning",
277 277 "-webkit-font-kerning", "font-kerning", "-webkit-font-size-delta",
278 278 "-webkit-font-size-delta", "-webkit-font-smoothing", "-webkit-font-smoothing",
279 279 "font-variant-ligatures", "-webkit-font-variant-ligatures",
280 280 "font-variant-ligatures", "-moz-force-broken-image-icon", "grid",
281 281 "-webkit-grid", "grid", "grid-area", "-webkit-grid-area", "grid-area",
282 282 "grid-auto-columns", "-webkit-grid-auto-columns", "grid-auto-columns",
283 283 "grid-auto-flow", "-webkit-grid-auto-flow", "grid-auto-flow", "grid-auto-rows",
284 284 "-webkit-grid-auto-rows", "grid-auto-rows", "grid-column",
285 285 "-webkit-grid-column", "grid-column", "-ms-grid-column",
286 286 "-ms-grid-column-align", "grid-column-end", "-webkit-grid-column-end",
287 287 "grid-column-end", "-ms-grid-column-span", "grid-column-start",
288 288 "-webkit-grid-column-start", "grid-column-start", "-ms-grid-columns",
289 289 "grid-row", "-webkit-grid-row", "grid-row", "-ms-grid-row",
290 290 "-ms-grid-row-align", "grid-row-end", "-webkit-grid-row-end", "grid-row-end",
291 291 "-ms-grid-row-span", "grid-row-start", "-webkit-grid-row-start",
292 292 "grid-row-start", "-ms-grid-rows", "grid-template", "-webkit-grid-template",
293 293 "grid-template", "grid-template-areas", "-webkit-grid-template-areas",
294 294 "grid-template-areas", "grid-template-columns",
295 295 "-webkit-grid-template-columns", "grid-template-columns", "grid-template-rows",
296 296 "-webkit-grid-template-rows", "grid-template-rows", "-ms-high-contrast-adjust",
297 297 "-webkit-highlight", "-webkit-hyphenate-character",
298 298 "-webkit-hyphenate-character", "-webkit-hyphenate-limit-after",
299 299 "-webkit-hyphenate-limit-before", "-ms-hyphenate-limit-chars",
300 300 "-webkit-hyphenate-limit-lines", "-ms-hyphenate-limit-lines",
301 301 "-ms-hyphenate-limit-zone", "-webkit-hyphens", "-moz-hyphens", "-ms-hyphens",
302 302 "-moz-image-region", "-ms-ime-align", "-webkit-initial-letter",
303 303 "-ms-interpolation-mode", "justify-self", "-webkit-justify-self",
304 304 "-webkit-line-align", "-webkit-line-box-contain", "-webkit-line-box-contain",
305 305 "-webkit-line-break", "-webkit-line-break", "line-break", "-webkit-line-clamp",
306 306 "-webkit-line-clamp", "-webkit-line-grid", "-webkit-line-snap",
307 307 "-webkit-locale", "-webkit-locale", "-webkit-logical-height",
308 308 "-webkit-logical-height", "-webkit-logical-width", "-webkit-logical-width",
309 309 "-webkit-margin-after", "-webkit-margin-after",
310 310 "-webkit-margin-after-collapse", "-webkit-margin-after-collapse",
311 311 "-webkit-margin-before", "-webkit-margin-before",
312 312 "-webkit-margin-before-collapse", "-webkit-margin-before-collapse",
313 313 "-webkit-margin-bottom-collapse", "-webkit-margin-bottom-collapse",
314 314 "-webkit-margin-collapse", "-webkit-margin-collapse", "-webkit-margin-end",
315 315 "-webkit-margin-end", "-moz-margin-end", "-webkit-margin-start",
316 316 "-webkit-margin-start", "-moz-margin-start", "-webkit-margin-top-collapse",
317 317 "-webkit-margin-top-collapse", "-webkit-marquee", "-webkit-marquee-direction",
318 318 "-webkit-marquee-increment", "-webkit-marquee-repetition",
319 319 "-webkit-marquee-speed", "-webkit-marquee-style", "mask", "-webkit-mask",
320 320 "mask", "-webkit-mask-box-image", "-webkit-mask-box-image",
321 321 "-webkit-mask-box-image-outset", "-webkit-mask-box-image-outset",
322 322 "-webkit-mask-box-image-repeat", "-webkit-mask-box-image-repeat",
323 323 "-webkit-mask-box-image-slice", "-webkit-mask-box-image-slice",
324 324 "-webkit-mask-box-image-source", "-webkit-mask-box-image-source",
325 325 "-webkit-mask-box-image-width", "-webkit-mask-box-image-width",
326 326 "-webkit-mask-clip", "-webkit-mask-clip", "-webkit-mask-composite",
327 327 "-webkit-mask-composite", "-webkit-mask-image", "-webkit-mask-image",
328 328 "-webkit-mask-origin", "-webkit-mask-origin", "-webkit-mask-position",
329 329 "-webkit-mask-position", "-webkit-mask-position-x", "-webkit-mask-position-x",
330 330 "-webkit-mask-position-y", "-webkit-mask-position-y", "-webkit-mask-repeat",
331 331 "-webkit-mask-repeat", "-webkit-mask-repeat-x", "-webkit-mask-repeat-x",
332 332 "-webkit-mask-repeat-y", "-webkit-mask-repeat-y", "-webkit-mask-size",
333 333 "-webkit-mask-size", "mask-source-type", "-webkit-mask-source-type",
334 334 "-moz-math-display", "-moz-math-variant", "-webkit-max-logical-height",
335 335 "-webkit-max-logical-height", "-webkit-max-logical-width",
336 336 "-webkit-max-logical-width", "-webkit-min-logical-height",
337 337 "-webkit-min-logical-height", "-webkit-min-logical-width",
338 338 "-webkit-min-logical-width", "-webkit-nbsp-mode", "-moz-orient",
339 339 "-moz-osx-font-smoothing", "-moz-outline-radius",
340 340 "-moz-outline-radius-bottomleft", "-moz-outline-radius-bottomright",
341 341 "-moz-outline-radius-topleft", "-moz-outline-radius-topright",
342 342 "-webkit-overflow-scrolling", "-ms-overflow-style", "-webkit-padding-after",
343 343 "-webkit-padding-after", "-webkit-padding-before", "-webkit-padding-before",
344 344 "-webkit-padding-end", "-webkit-padding-end", "-moz-padding-end",
345 345 "-webkit-padding-start", "-webkit-padding-start", "-moz-padding-start",
346 346 "perspective", "-webkit-perspective", "perspective", "perspective",
347 347 "perspective-origin", "-webkit-perspective-origin", "perspective-origin",
348 348 "perspective-origin", "-webkit-perspective-origin-x",
349 349 "-webkit-perspective-origin-x", "perspective-origin-x",
350 350 "-webkit-perspective-origin-y", "-webkit-perspective-origin-y",
351 351 "perspective-origin-y", "-webkit-print-color-adjust",
352 352 "-webkit-print-color-adjust", "-webkit-region-break-after",
353 353 "-webkit-region-break-before", "-webkit-region-break-inside",
354 354 "-webkit-region-fragment", "-webkit-rtl-ordering", "-webkit-rtl-ordering",
355 355 "-webkit-ruby-position", "-webkit-ruby-position", "ruby-position",
356 356 "-moz-script-level", "-moz-script-min-size", "-moz-script-size-multiplier",
357 357 "-ms-scroll-chaining", "-ms-scroll-limit", "-ms-scroll-limit-x-max",
358 358 "-ms-scroll-limit-x-min", "-ms-scroll-limit-y-max", "-ms-scroll-limit-y-min",
359 359 "-ms-scroll-rails", "-webkit-scroll-snap-coordinate",
360 360 "-webkit-scroll-snap-destination", "-webkit-scroll-snap-points-x",
361 361 "-ms-scroll-snap-points-x", "-webkit-scroll-snap-points-y",
362 362 "-ms-scroll-snap-points-y", "-webkit-scroll-snap-type", "-ms-scroll-snap-type",
363 363 "-ms-scroll-snap-x", "-ms-scroll-snap-y", "-ms-scroll-translation",
364 364 "-ms-scrollbar-3dlight-color", "shape-image-threshold",
365 365 "-webkit-shape-image-threshold", "shape-margin", "-webkit-shape-margin",
366 366 "shape-outside", "-webkit-shape-outside", "-moz-stack-sizing", "tab-size",
367 367 "tab-size", "-moz-tab-size", "-webkit-tap-highlight-color",
368 368 "-webkit-tap-highlight-color", "text-align-last", "-webkit-text-align-last",
369 369 "-moz-text-align-last", "text-align-last", "-webkit-text-combine",
370 370 "-webkit-text-combine", "-ms-text-combine-horizontal", "text-decoration-color",
371 371 "-webkit-text-decoration-color", "text-decoration-color",
372 372 "text-decoration-color", "text-decoration-line",
373 373 "-webkit-text-decoration-line", "text-decoration-line",
374 374 "-webkit-text-decoration-skip", "text-decoration-style",
375 375 "-webkit-text-decoration-style", "text-decoration-style",
376 376 "-webkit-text-decorations-in-effect", "-webkit-text-decorations-in-effect",
377 377 "-webkit-text-emphasis", "text-emphasis", "-webkit-text-emphasis-color",
378 378 "text-emphasis-color", "-webkit-text-emphasis-position",
379 379 "text-emphasis-position", "-webkit-text-emphasis-style", "text-emphasis-style",
380 380 "-webkit-text-fill-color", "-webkit-text-fill-color", "text-justify",
381 381 "-webkit-text-justify", "text-justify", "-webkit-text-orientation",
382 382 "-webkit-text-orientation", "text-orientation", "-webkit-text-security",
383 383 "-webkit-text-security", "-webkit-text-size-adjust", "-moz-text-size-adjust",
384 384 "-ms-text-size-adjust", "-webkit-text-stroke", "-webkit-text-stroke",
385 385 "-webkit-text-stroke-color", "-webkit-text-stroke-color",
386 386 "-webkit-text-stroke-width", "-webkit-text-stroke-width",
387 387 "text-underline-position", "-webkit-text-underline-position",
388 388 "text-underline-position", "-webkit-touch-callout", "-ms-touch-select",
389 389 "transform", "-webkit-transform", "transform", "transform", "transform-origin",
390 390 "-webkit-transform-origin", "transform-origin", "transform-origin",
391 391 "-webkit-transform-origin-x", "-webkit-transform-origin-x",
392 392 "transform-origin-x", "-webkit-transform-origin-y",
393 393 "-webkit-transform-origin-y", "transform-origin-y",
394 394 "-webkit-transform-origin-z", "-webkit-transform-origin-z",
395 395 "transform-origin-z", "transform-style", "-webkit-transform-style",
396 396 "transform-style", "transform-style", "-webkit-user-drag", "-webkit-user-drag",
397 397 "-moz-user-focus", "-moz-user-input", "-webkit-user-modify",
398 398 "-webkit-user-modify", "-moz-user-modify", "-webkit-user-select",
399 399 "-webkit-user-select", "-moz-user-select", "-ms-user-select",
400 400 "-moz-window-dragging", "-moz-window-shadow", "-ms-wrap-flow",
401 401 "-ms-wrap-margin", "-ms-wrap-through", "writing-mode", "-webkit-writing-mode",
402 402 "writing-mode", "writing-mode",
403 403 ]
404 404
405 405 all_styles = standard_styles + all_prefixed_styles No newline at end of file
@@ -1,77 +1,62 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2010-2019 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 import re
22
23 21 import markdown
24 22
25 23 from mdx_gfm import GithubFlavoredMarkdownExtension # pragma: no cover
26 24
27 25
28 class FlavoredCheckboxPostprocessor(markdown.postprocessors.Postprocessor):
29 """
30 Adds `flavored_checkbox_list` class to list of checkboxes
31 """
32
33 pattern = re.compile(r'^([*-]) \[([ x])\]')
34
35 def run(self, html):
36 before = '<ul>\n<li><input type="checkbox"'
37 after = '<ul class="flavored_checkbox_list">\n<li><input type="checkbox"'
38 return html.replace(before, after)
39
40
41 26 # Global Vars
42 27 URLIZE_RE = '(%s)' % '|'.join([
43 28 r'<(?:f|ht)tps?://[^>]*>',
44 29 r'\b(?:f|ht)tps?://[^)<>\s]+[^.,)<>\s]',
45 30 r'\bwww\.[^)<>\s]+[^.,)<>\s]',
46 31 r'[^(<\s]+\.(?:com|net|org)\b',
47 32 ])
48 33
49 34
50 35 class UrlizePattern(markdown.inlinepatterns.Pattern):
51 36 """ Return a link Element given an autolink (`http://example/com`). """
52 37 def handleMatch(self, m):
53 38 url = m.group(2)
54 39
55 40 if url.startswith('<'):
56 41 url = url[1:-1]
57 42
58 43 text = url
59 44
60 45 if not url.split('://')[0] in ('http','https','ftp'):
61 46 if '@' in url and not '/' in url:
62 47 url = 'mailto:' + url
63 48 else:
64 49 url = 'http://' + url
65 50
66 51 el = markdown.util.etree.Element("a")
67 52 el.set('href', url)
68 53 el.text = markdown.util.AtomicString(text)
69 54 return el
70 55
71 56
72 57 class UrlizeExtension(markdown.Extension):
73 58 """ Urlize Extension for Python-Markdown. """
74 59
75 60 def extendMarkdown(self, md, md_globals):
76 61 """ Replace autolink with UrlizePattern """
77 62 md.inlinePatterns['autolink'] = UrlizePattern(URLIZE_RE, md)
General Comments 0
You need to be logged in to leave comments. Login now