ires 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (1024) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -45
  3. data/ext/Gopkg.lock +31 -1
  4. data/ext/ires/image.go +227 -0
  5. data/ext/ires/ires.go +47 -59
  6. data/ext/ires/uri.go +143 -0
  7. data/ext/main.go +18 -9
  8. data/ext/vendor/github.com/PuerkitoBio/purell/LICENSE +12 -0
  9. data/ext/vendor/github.com/PuerkitoBio/purell/README.md +187 -0
  10. data/ext/vendor/github.com/PuerkitoBio/purell/bench_test.go +57 -0
  11. data/ext/vendor/github.com/PuerkitoBio/purell/benchmarks/v0.1.0 +9 -0
  12. data/ext/vendor/github.com/PuerkitoBio/purell/example_test.go +35 -0
  13. data/ext/vendor/github.com/PuerkitoBio/purell/purell.go +379 -0
  14. data/ext/vendor/github.com/PuerkitoBio/purell/purell_test.go +768 -0
  15. data/ext/vendor/github.com/PuerkitoBio/purell/urlnorm_test.go +53 -0
  16. data/ext/vendor/github.com/PuerkitoBio/urlesc/LICENSE +27 -0
  17. data/ext/vendor/github.com/PuerkitoBio/urlesc/README.md +16 -0
  18. data/ext/vendor/github.com/PuerkitoBio/urlesc/urlesc.go +180 -0
  19. data/ext/vendor/github.com/PuerkitoBio/urlesc/urlesc_test.go +641 -0
  20. data/ext/vendor/github.com/{satori/go.uuid → goware/urlx}/LICENSE +3 -1
  21. data/ext/vendor/github.com/goware/urlx/README.md +172 -0
  22. data/ext/vendor/github.com/goware/urlx/urlx.go +196 -0
  23. data/ext/vendor/github.com/goware/urlx/urlx_test.go +232 -0
  24. data/ext/vendor/golang.org/x/net/AUTHORS +3 -0
  25. data/ext/vendor/golang.org/x/net/CONTRIBUTING.md +31 -0
  26. data/ext/vendor/golang.org/x/net/CONTRIBUTORS +3 -0
  27. data/ext/vendor/golang.org/x/net/LICENSE +27 -0
  28. data/ext/vendor/golang.org/x/net/PATENTS +22 -0
  29. data/ext/vendor/golang.org/x/net/README.md +16 -0
  30. data/ext/vendor/golang.org/x/net/bpf/asm.go +41 -0
  31. data/ext/vendor/golang.org/x/net/bpf/constants.go +218 -0
  32. data/ext/vendor/golang.org/x/net/bpf/doc.go +82 -0
  33. data/ext/vendor/golang.org/x/net/bpf/instructions.go +704 -0
  34. data/ext/vendor/golang.org/x/net/bpf/instructions_test.go +525 -0
  35. data/ext/vendor/golang.org/x/net/bpf/setter.go +10 -0
  36. data/ext/vendor/golang.org/x/net/bpf/testdata/all_instructions.bpf +1 -0
  37. data/ext/vendor/golang.org/x/net/bpf/testdata/all_instructions.txt +79 -0
  38. data/ext/vendor/golang.org/x/net/bpf/vm.go +140 -0
  39. data/ext/vendor/golang.org/x/net/bpf/vm_aluop_test.go +512 -0
  40. data/ext/vendor/golang.org/x/net/bpf/vm_bpf_test.go +192 -0
  41. data/ext/vendor/golang.org/x/net/bpf/vm_extension_test.go +49 -0
  42. data/ext/vendor/golang.org/x/net/bpf/vm_instructions.go +174 -0
  43. data/ext/vendor/golang.org/x/net/bpf/vm_jump_test.go +380 -0
  44. data/ext/vendor/golang.org/x/net/bpf/vm_load_test.go +246 -0
  45. data/ext/vendor/golang.org/x/net/bpf/vm_ret_test.go +115 -0
  46. data/ext/vendor/golang.org/x/net/bpf/vm_scratch_test.go +247 -0
  47. data/ext/vendor/golang.org/x/net/bpf/vm_test.go +144 -0
  48. data/ext/vendor/golang.org/x/net/codereview.cfg +1 -0
  49. data/ext/vendor/golang.org/x/net/context/context.go +54 -0
  50. data/ext/vendor/golang.org/x/net/context/context_test.go +583 -0
  51. data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go +74 -0
  52. data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_17_test.go +29 -0
  53. data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go +147 -0
  54. data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17_test.go +79 -0
  55. data/ext/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_test.go +105 -0
  56. data/ext/vendor/golang.org/x/net/context/go17.go +72 -0
  57. data/ext/vendor/golang.org/x/net/context/go19.go +20 -0
  58. data/ext/vendor/golang.org/x/net/context/pre_go17.go +300 -0
  59. data/ext/vendor/golang.org/x/net/context/pre_go19.go +109 -0
  60. data/ext/vendor/golang.org/x/net/context/withtimeout_test.go +31 -0
  61. data/ext/vendor/golang.org/x/net/dict/dict.go +210 -0
  62. data/ext/vendor/golang.org/x/net/dns/dnsmessage/example_test.go +132 -0
  63. data/ext/vendor/golang.org/x/net/dns/dnsmessage/message.go +1997 -0
  64. data/ext/vendor/golang.org/x/net/dns/dnsmessage/message_test.go +1116 -0
  65. data/ext/vendor/golang.org/x/net/html/atom/atom.go +78 -0
  66. data/ext/vendor/golang.org/x/net/html/atom/atom_test.go +109 -0
  67. data/ext/vendor/golang.org/x/net/html/atom/gen.go +709 -0
  68. data/ext/vendor/golang.org/x/net/html/atom/table.go +777 -0
  69. data/ext/vendor/golang.org/x/net/html/atom/table_test.go +373 -0
  70. data/ext/vendor/golang.org/x/net/html/charset/charset.go +257 -0
  71. data/ext/vendor/golang.org/x/net/html/charset/charset_test.go +237 -0
  72. data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-charset.html +48 -0
  73. data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-UTF-8-BOM.html +48 -0
  74. data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-charset.html +49 -0
  75. data/ext/vendor/golang.org/x/net/html/charset/testdata/HTTP-vs-meta-content.html +49 -0
  76. data/ext/vendor/golang.org/x/net/html/charset/testdata/No-encoding-declaration.html +47 -0
  77. data/ext/vendor/golang.org/x/net/html/charset/testdata/README +9 -0
  78. data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-16BE-BOM.html +0 -0
  79. data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-16LE-BOM.html +0 -0
  80. data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-charset.html +49 -0
  81. data/ext/vendor/golang.org/x/net/html/charset/testdata/UTF-8-BOM-vs-meta-content.html +48 -0
  82. data/ext/vendor/golang.org/x/net/html/charset/testdata/meta-charset-attribute.html +48 -0
  83. data/ext/vendor/golang.org/x/net/html/charset/testdata/meta-content-attribute.html +48 -0
  84. data/ext/vendor/golang.org/x/net/html/const.go +104 -0
  85. data/ext/vendor/golang.org/x/net/html/doc.go +106 -0
  86. data/ext/vendor/golang.org/x/net/html/doctype.go +156 -0
  87. data/ext/vendor/golang.org/x/net/html/entity.go +2253 -0
  88. data/ext/vendor/golang.org/x/net/html/entity_test.go +29 -0
  89. data/ext/vendor/golang.org/x/net/html/escape.go +258 -0
  90. data/ext/vendor/golang.org/x/net/html/escape_test.go +97 -0
  91. data/ext/vendor/golang.org/x/net/html/example_test.go +40 -0
  92. data/ext/vendor/golang.org/x/net/html/foreign.go +226 -0
  93. data/ext/vendor/golang.org/x/net/html/node.go +193 -0
  94. data/ext/vendor/golang.org/x/net/html/node_test.go +146 -0
  95. data/ext/vendor/golang.org/x/net/html/parse.go +2094 -0
  96. data/ext/vendor/golang.org/x/net/html/parse_test.go +388 -0
  97. data/ext/vendor/golang.org/x/net/html/render.go +271 -0
  98. data/ext/vendor/golang.org/x/net/html/render_test.go +156 -0
  99. data/ext/vendor/golang.org/x/net/html/testdata/go1.html +2237 -0
  100. data/ext/vendor/golang.org/x/net/html/testdata/webkit/README +28 -0
  101. data/ext/vendor/golang.org/x/net/html/testdata/webkit/adoption01.dat +194 -0
  102. data/ext/vendor/golang.org/x/net/html/testdata/webkit/adoption02.dat +31 -0
  103. data/ext/vendor/golang.org/x/net/html/testdata/webkit/comments01.dat +135 -0
  104. data/ext/vendor/golang.org/x/net/html/testdata/webkit/doctype01.dat +370 -0
  105. data/ext/vendor/golang.org/x/net/html/testdata/webkit/entities01.dat +603 -0
  106. data/ext/vendor/golang.org/x/net/html/testdata/webkit/entities02.dat +249 -0
  107. data/ext/vendor/golang.org/x/net/html/testdata/webkit/html5test-com.dat +246 -0
  108. data/ext/vendor/golang.org/x/net/html/testdata/webkit/inbody01.dat +43 -0
  109. data/ext/vendor/golang.org/x/net/html/testdata/webkit/isindex.dat +40 -0
  110. data/ext/vendor/golang.org/x/net/html/testdata/webkit/pending-spec-changes-plain-text-unsafe.dat +0 -0
  111. data/ext/vendor/golang.org/x/net/html/testdata/webkit/pending-spec-changes.dat +52 -0
  112. data/ext/vendor/golang.org/x/net/html/testdata/webkit/plain-text-unsafe.dat +0 -0
  113. data/ext/vendor/golang.org/x/net/html/testdata/webkit/scriptdata01.dat +308 -0
  114. data/ext/vendor/golang.org/x/net/html/testdata/webkit/scripted/adoption01.dat +15 -0
  115. data/ext/vendor/golang.org/x/net/html/testdata/webkit/scripted/webkit01.dat +28 -0
  116. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tables01.dat +212 -0
  117. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests1.dat +1952 -0
  118. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests10.dat +799 -0
  119. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests11.dat +482 -0
  120. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests12.dat +62 -0
  121. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests14.dat +74 -0
  122. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests15.dat +208 -0
  123. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests16.dat +2299 -0
  124. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests17.dat +153 -0
  125. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests18.dat +269 -0
  126. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests19.dat +1237 -0
  127. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests2.dat +763 -0
  128. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests20.dat +455 -0
  129. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests21.dat +221 -0
  130. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests22.dat +157 -0
  131. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests23.dat +155 -0
  132. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests24.dat +79 -0
  133. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests25.dat +219 -0
  134. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests26.dat +313 -0
  135. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests3.dat +305 -0
  136. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests4.dat +59 -0
  137. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests5.dat +191 -0
  138. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests6.dat +663 -0
  139. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests7.dat +390 -0
  140. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests8.dat +148 -0
  141. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests9.dat +457 -0
  142. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tests_innerHTML_1.dat +741 -0
  143. data/ext/vendor/golang.org/x/net/html/testdata/webkit/tricky01.dat +261 -0
  144. data/ext/vendor/golang.org/x/net/html/testdata/webkit/webkit01.dat +610 -0
  145. data/ext/vendor/golang.org/x/net/html/testdata/webkit/webkit02.dat +159 -0
  146. data/ext/vendor/golang.org/x/net/html/token.go +1219 -0
  147. data/ext/vendor/golang.org/x/net/html/token_test.go +748 -0
  148. data/ext/vendor/golang.org/x/net/http2/Dockerfile +51 -0
  149. data/ext/vendor/golang.org/x/net/http2/Makefile +3 -0
  150. data/ext/vendor/golang.org/x/net/http2/README +20 -0
  151. data/ext/vendor/golang.org/x/net/http2/ciphers.go +641 -0
  152. data/ext/vendor/golang.org/x/net/http2/ciphers_test.go +309 -0
  153. data/ext/vendor/golang.org/x/net/http2/client_conn_pool.go +256 -0
  154. data/ext/vendor/golang.org/x/net/http2/configure_transport.go +80 -0
  155. data/ext/vendor/golang.org/x/net/http2/databuffer.go +146 -0
  156. data/ext/vendor/golang.org/x/net/http2/databuffer_test.go +157 -0
  157. data/ext/vendor/golang.org/x/net/http2/errors.go +133 -0
  158. data/ext/vendor/golang.org/x/net/http2/errors_test.go +24 -0
  159. data/ext/vendor/golang.org/x/net/http2/flow.go +50 -0
  160. data/ext/vendor/golang.org/x/net/http2/flow_test.go +53 -0
  161. data/ext/vendor/golang.org/x/net/http2/frame.go +1579 -0
  162. data/ext/vendor/golang.org/x/net/http2/frame_test.go +1191 -0
  163. data/ext/vendor/golang.org/x/net/http2/go16.go +16 -0
  164. data/ext/vendor/golang.org/x/net/http2/go17.go +106 -0
  165. data/ext/vendor/golang.org/x/net/http2/go17_not18.go +36 -0
  166. data/ext/vendor/golang.org/x/net/http2/go18.go +56 -0
  167. data/ext/vendor/golang.org/x/net/http2/go18_test.go +79 -0
  168. data/ext/vendor/golang.org/x/net/http2/go19.go +16 -0
  169. data/ext/vendor/golang.org/x/net/http2/go19_test.go +60 -0
  170. data/ext/vendor/golang.org/x/net/http2/gotrack.go +170 -0
  171. data/ext/vendor/golang.org/x/net/http2/gotrack_test.go +33 -0
  172. data/ext/vendor/golang.org/x/net/http2/h2demo/Makefile +8 -0
  173. data/ext/vendor/golang.org/x/net/http2/h2demo/README +16 -0
  174. data/ext/vendor/golang.org/x/net/http2/h2demo/h2demo.go +538 -0
  175. data/ext/vendor/golang.org/x/net/http2/h2demo/launch.go +302 -0
  176. data/ext/vendor/golang.org/x/net/http2/h2demo/rootCA.key +27 -0
  177. data/ext/vendor/golang.org/x/net/http2/h2demo/rootCA.pem +26 -0
  178. data/ext/vendor/golang.org/x/net/http2/h2demo/rootCA.srl +1 -0
  179. data/ext/vendor/golang.org/x/net/http2/h2demo/server.crt +20 -0
  180. data/ext/vendor/golang.org/x/net/http2/h2demo/server.key +27 -0
  181. data/ext/vendor/golang.org/x/net/http2/h2demo/tmpl.go +1991 -0
  182. data/ext/vendor/golang.org/x/net/http2/h2i/README.md +97 -0
  183. data/ext/vendor/golang.org/x/net/http2/h2i/h2i.go +522 -0
  184. data/ext/vendor/golang.org/x/net/http2/headermap.go +78 -0
  185. data/ext/vendor/golang.org/x/net/http2/hpack/encode.go +240 -0
  186. data/ext/vendor/golang.org/x/net/http2/hpack/encode_test.go +386 -0
  187. data/ext/vendor/golang.org/x/net/http2/hpack/hpack.go +490 -0
  188. data/ext/vendor/golang.org/x/net/http2/hpack/hpack_test.go +722 -0
  189. data/ext/vendor/golang.org/x/net/http2/hpack/huffman.go +212 -0
  190. data/ext/vendor/golang.org/x/net/http2/hpack/tables.go +479 -0
  191. data/ext/vendor/golang.org/x/net/http2/hpack/tables_test.go +214 -0
  192. data/ext/vendor/golang.org/x/net/http2/http2.go +391 -0
  193. data/ext/vendor/golang.org/x/net/http2/http2_test.go +199 -0
  194. data/ext/vendor/golang.org/x/net/http2/not_go16.go +21 -0
  195. data/ext/vendor/golang.org/x/net/http2/not_go17.go +87 -0
  196. data/ext/vendor/golang.org/x/net/http2/not_go18.go +29 -0
  197. data/ext/vendor/golang.org/x/net/http2/not_go19.go +16 -0
  198. data/ext/vendor/golang.org/x/net/http2/pipe.go +163 -0
  199. data/ext/vendor/golang.org/x/net/http2/pipe_test.go +130 -0
  200. data/ext/vendor/golang.org/x/net/http2/server.go +2857 -0
  201. data/ext/vendor/golang.org/x/net/http2/server_push_test.go +521 -0
  202. data/ext/vendor/golang.org/x/net/http2/server_test.go +3721 -0
  203. data/ext/vendor/golang.org/x/net/http2/testdata/draft-ietf-httpbis-http2.xml +5021 -0
  204. data/ext/vendor/golang.org/x/net/http2/transport.go +2285 -0
  205. data/ext/vendor/golang.org/x/net/http2/transport_test.go +3714 -0
  206. data/ext/vendor/golang.org/x/net/http2/write.go +370 -0
  207. data/ext/vendor/golang.org/x/net/http2/writesched.go +242 -0
  208. data/ext/vendor/golang.org/x/net/http2/writesched_priority.go +452 -0
  209. data/ext/vendor/golang.org/x/net/http2/writesched_priority_test.go +541 -0
  210. data/ext/vendor/golang.org/x/net/http2/writesched_random.go +72 -0
  211. data/ext/vendor/golang.org/x/net/http2/writesched_random_test.go +44 -0
  212. data/ext/vendor/golang.org/x/net/http2/writesched_test.go +125 -0
  213. data/ext/vendor/golang.org/x/net/http2/z_spec_test.go +356 -0
  214. data/ext/vendor/golang.org/x/net/icmp/dstunreach.go +41 -0
  215. data/ext/vendor/golang.org/x/net/icmp/echo.go +45 -0
  216. data/ext/vendor/golang.org/x/net/icmp/endpoint.go +113 -0
  217. data/ext/vendor/golang.org/x/net/icmp/example_test.go +63 -0
  218. data/ext/vendor/golang.org/x/net/icmp/extension.go +89 -0
  219. data/ext/vendor/golang.org/x/net/icmp/extension_test.go +259 -0
  220. data/ext/vendor/golang.org/x/net/icmp/helper_posix.go +75 -0
  221. data/ext/vendor/golang.org/x/net/icmp/interface.go +236 -0
  222. data/ext/vendor/golang.org/x/net/icmp/ipv4.go +61 -0
  223. data/ext/vendor/golang.org/x/net/icmp/ipv4_test.go +83 -0
  224. data/ext/vendor/golang.org/x/net/icmp/ipv6.go +23 -0
  225. data/ext/vendor/golang.org/x/net/icmp/listen_posix.go +100 -0
  226. data/ext/vendor/golang.org/x/net/icmp/listen_stub.go +33 -0
  227. data/ext/vendor/golang.org/x/net/icmp/message.go +152 -0
  228. data/ext/vendor/golang.org/x/net/icmp/message_test.go +134 -0
  229. data/ext/vendor/golang.org/x/net/icmp/messagebody.go +41 -0
  230. data/ext/vendor/golang.org/x/net/icmp/mpls.go +77 -0
  231. data/ext/vendor/golang.org/x/net/icmp/multipart.go +109 -0
  232. data/ext/vendor/golang.org/x/net/icmp/multipart_test.go +442 -0
  233. data/ext/vendor/golang.org/x/net/icmp/packettoobig.go +43 -0
  234. data/ext/vendor/golang.org/x/net/icmp/paramprob.go +63 -0
  235. data/ext/vendor/golang.org/x/net/icmp/ping_test.go +200 -0
  236. data/ext/vendor/golang.org/x/net/icmp/sys_freebsd.go +11 -0
  237. data/ext/vendor/golang.org/x/net/icmp/timeexceeded.go +39 -0
  238. data/ext/vendor/golang.org/x/net/idna/example_test.go +70 -0
  239. data/ext/vendor/golang.org/x/net/idna/idna.go +680 -0
  240. data/ext/vendor/golang.org/x/net/idna/idna_test.go +108 -0
  241. data/ext/vendor/golang.org/x/net/idna/punycode.go +203 -0
  242. data/ext/vendor/golang.org/x/net/idna/punycode_test.go +198 -0
  243. data/ext/vendor/golang.org/x/net/idna/tables.go +4477 -0
  244. data/ext/vendor/golang.org/x/net/idna/trie.go +72 -0
  245. data/ext/vendor/golang.org/x/net/idna/trieval.go +114 -0
  246. data/ext/vendor/golang.org/x/net/internal/iana/const.go +180 -0
  247. data/ext/vendor/golang.org/x/net/internal/iana/gen.go +293 -0
  248. data/ext/vendor/golang.org/x/net/internal/nettest/helper_bsd.go +53 -0
  249. data/ext/vendor/golang.org/x/net/internal/nettest/helper_nobsd.go +15 -0
  250. data/ext/vendor/golang.org/x/net/internal/nettest/helper_posix.go +31 -0
  251. data/ext/vendor/golang.org/x/net/internal/nettest/helper_stub.go +32 -0
  252. data/ext/vendor/golang.org/x/net/internal/nettest/helper_unix.go +29 -0
  253. data/ext/vendor/golang.org/x/net/internal/nettest/helper_windows.go +42 -0
  254. data/ext/vendor/golang.org/x/net/internal/nettest/interface.go +94 -0
  255. data/ext/vendor/golang.org/x/net/internal/nettest/rlimit.go +11 -0
  256. data/ext/vendor/golang.org/x/net/internal/nettest/stack.go +147 -0
  257. data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr.go +11 -0
  258. data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_bsd.go +13 -0
  259. data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_32bit.go +14 -0
  260. data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_linux_64bit.go +14 -0
  261. data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_solaris_64bit.go +14 -0
  262. data/ext/vendor/golang.org/x/net/internal/socket/cmsghdr_stub.go +17 -0
  263. data/ext/vendor/golang.org/x/net/internal/socket/defs_darwin.go +44 -0
  264. data/ext/vendor/golang.org/x/net/internal/socket/defs_dragonfly.go +44 -0
  265. data/ext/vendor/golang.org/x/net/internal/socket/defs_freebsd.go +44 -0
  266. data/ext/vendor/golang.org/x/net/internal/socket/defs_linux.go +49 -0
  267. data/ext/vendor/golang.org/x/net/internal/socket/defs_netbsd.go +47 -0
  268. data/ext/vendor/golang.org/x/net/internal/socket/defs_openbsd.go +44 -0
  269. data/ext/vendor/golang.org/x/net/internal/socket/defs_solaris.go +44 -0
  270. data/ext/vendor/golang.org/x/net/internal/socket/error_unix.go +31 -0
  271. data/ext/vendor/golang.org/x/net/internal/socket/error_windows.go +26 -0
  272. data/ext/vendor/golang.org/x/net/internal/socket/iovec_32bit.go +19 -0
  273. data/ext/vendor/golang.org/x/net/internal/socket/iovec_64bit.go +19 -0
  274. data/ext/vendor/golang.org/x/net/internal/socket/iovec_solaris_64bit.go +19 -0
  275. data/ext/vendor/golang.org/x/net/internal/socket/iovec_stub.go +11 -0
  276. data/ext/vendor/golang.org/x/net/internal/socket/mmsghdr_stub.go +21 -0
  277. data/ext/vendor/golang.org/x/net/internal/socket/mmsghdr_unix.go +42 -0
  278. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_bsd.go +39 -0
  279. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_bsdvar.go +16 -0
  280. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_linux.go +36 -0
  281. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_linux_32bit.go +24 -0
  282. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_linux_64bit.go +24 -0
  283. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_openbsd.go +14 -0
  284. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_solaris_64bit.go +36 -0
  285. data/ext/vendor/golang.org/x/net/internal/socket/msghdr_stub.go +14 -0
  286. data/ext/vendor/golang.org/x/net/internal/socket/rawconn.go +66 -0
  287. data/ext/vendor/golang.org/x/net/internal/socket/rawconn_mmsg.go +74 -0
  288. data/ext/vendor/golang.org/x/net/internal/socket/rawconn_msg.go +77 -0
  289. data/ext/vendor/golang.org/x/net/internal/socket/rawconn_nommsg.go +18 -0
  290. data/ext/vendor/golang.org/x/net/internal/socket/rawconn_nomsg.go +18 -0
  291. data/ext/vendor/golang.org/x/net/internal/socket/rawconn_stub.go +25 -0
  292. data/ext/vendor/golang.org/x/net/internal/socket/reflect.go +62 -0
  293. data/ext/vendor/golang.org/x/net/internal/socket/socket.go +285 -0
  294. data/ext/vendor/golang.org/x/net/internal/socket/socket_go1_9_test.go +259 -0
  295. data/ext/vendor/golang.org/x/net/internal/socket/socket_test.go +46 -0
  296. data/ext/vendor/golang.org/x/net/internal/socket/sys.go +33 -0
  297. data/ext/vendor/golang.org/x/net/internal/socket/sys_bsd.go +17 -0
  298. data/ext/vendor/golang.org/x/net/internal/socket/sys_bsdvar.go +14 -0
  299. data/ext/vendor/golang.org/x/net/internal/socket/sys_darwin.go +7 -0
  300. data/ext/vendor/golang.org/x/net/internal/socket/sys_dragonfly.go +7 -0
  301. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux.go +27 -0
  302. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_386.go +55 -0
  303. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_386.s +11 -0
  304. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_amd64.go +10 -0
  305. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_arm.go +10 -0
  306. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_arm64.go +10 -0
  307. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mips.go +10 -0
  308. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mips64.go +10 -0
  309. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mips64le.go +10 -0
  310. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_mipsle.go +10 -0
  311. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64.go +10 -0
  312. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_ppc64le.go +10 -0
  313. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.go +55 -0
  314. data/ext/vendor/golang.org/x/net/internal/socket/sys_linux_s390x.s +11 -0
  315. data/ext/vendor/golang.org/x/net/internal/socket/sys_netbsd.go +25 -0
  316. data/ext/vendor/golang.org/x/net/internal/socket/sys_posix.go +168 -0
  317. data/ext/vendor/golang.org/x/net/internal/socket/sys_solaris.go +71 -0
  318. data/ext/vendor/golang.org/x/net/internal/socket/sys_solaris_amd64.s +11 -0
  319. data/ext/vendor/golang.org/x/net/internal/socket/sys_stub.go +64 -0
  320. data/ext/vendor/golang.org/x/net/internal/socket/sys_unix.go +33 -0
  321. data/ext/vendor/golang.org/x/net/internal/socket/sys_windows.go +70 -0
  322. data/ext/vendor/golang.org/x/net/internal/socket/zsys_darwin_386.go +59 -0
  323. data/ext/vendor/golang.org/x/net/internal/socket/zsys_darwin_amd64.go +61 -0
  324. data/ext/vendor/golang.org/x/net/internal/socket/zsys_darwin_arm.go +59 -0
  325. data/ext/vendor/golang.org/x/net/internal/socket/zsys_dragonfly_amd64.go +61 -0
  326. data/ext/vendor/golang.org/x/net/internal/socket/zsys_freebsd_386.go +59 -0
  327. data/ext/vendor/golang.org/x/net/internal/socket/zsys_freebsd_amd64.go +61 -0
  328. data/ext/vendor/golang.org/x/net/internal/socket/zsys_freebsd_arm.go +59 -0
  329. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_386.go +63 -0
  330. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_amd64.go +66 -0
  331. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_arm.go +63 -0
  332. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_arm64.go +66 -0
  333. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mips.go +63 -0
  334. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64.go +66 -0
  335. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mips64le.go +66 -0
  336. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_mipsle.go +63 -0
  337. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64.go +66 -0
  338. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_ppc64le.go +66 -0
  339. data/ext/vendor/golang.org/x/net/internal/socket/zsys_linux_s390x.go +66 -0
  340. data/ext/vendor/golang.org/x/net/internal/socket/zsys_netbsd_386.go +65 -0
  341. data/ext/vendor/golang.org/x/net/internal/socket/zsys_netbsd_amd64.go +68 -0
  342. data/ext/vendor/golang.org/x/net/internal/socket/zsys_netbsd_arm.go +59 -0
  343. data/ext/vendor/golang.org/x/net/internal/socket/zsys_openbsd_386.go +59 -0
  344. data/ext/vendor/golang.org/x/net/internal/socket/zsys_openbsd_amd64.go +61 -0
  345. data/ext/vendor/golang.org/x/net/internal/socket/zsys_openbsd_arm.go +59 -0
  346. data/ext/vendor/golang.org/x/net/internal/socket/zsys_solaris_amd64.go +60 -0
  347. data/ext/vendor/golang.org/x/net/internal/timeseries/timeseries.go +525 -0
  348. data/ext/vendor/golang.org/x/net/internal/timeseries/timeseries_test.go +170 -0
  349. data/ext/vendor/golang.org/x/net/ipv4/batch.go +191 -0
  350. data/ext/vendor/golang.org/x/net/ipv4/bpf_test.go +93 -0
  351. data/ext/vendor/golang.org/x/net/ipv4/control.go +144 -0
  352. data/ext/vendor/golang.org/x/net/ipv4/control_bsd.go +40 -0
  353. data/ext/vendor/golang.org/x/net/ipv4/control_pktinfo.go +39 -0
  354. data/ext/vendor/golang.org/x/net/ipv4/control_stub.go +13 -0
  355. data/ext/vendor/golang.org/x/net/ipv4/control_test.go +21 -0
  356. data/ext/vendor/golang.org/x/net/ipv4/control_unix.go +73 -0
  357. data/ext/vendor/golang.org/x/net/ipv4/control_windows.go +16 -0
  358. data/ext/vendor/golang.org/x/net/ipv4/defs_darwin.go +77 -0
  359. data/ext/vendor/golang.org/x/net/ipv4/defs_dragonfly.go +38 -0
  360. data/ext/vendor/golang.org/x/net/ipv4/defs_freebsd.go +75 -0
  361. data/ext/vendor/golang.org/x/net/ipv4/defs_linux.go +122 -0
  362. data/ext/vendor/golang.org/x/net/ipv4/defs_netbsd.go +37 -0
  363. data/ext/vendor/golang.org/x/net/ipv4/defs_openbsd.go +37 -0
  364. data/ext/vendor/golang.org/x/net/ipv4/defs_solaris.go +84 -0
  365. data/ext/vendor/golang.org/x/net/ipv4/dgramopt.go +265 -0
  366. data/ext/vendor/golang.org/x/net/ipv4/doc.go +244 -0
  367. data/ext/vendor/golang.org/x/net/ipv4/endpoint.go +187 -0
  368. data/ext/vendor/golang.org/x/net/ipv4/example_test.go +224 -0
  369. data/ext/vendor/golang.org/x/net/ipv4/gen.go +199 -0
  370. data/ext/vendor/golang.org/x/net/ipv4/genericopt.go +57 -0
  371. data/ext/vendor/golang.org/x/net/ipv4/header.go +159 -0
  372. data/ext/vendor/golang.org/x/net/ipv4/header_test.go +228 -0
  373. data/ext/vendor/golang.org/x/net/ipv4/helper.go +63 -0
  374. data/ext/vendor/golang.org/x/net/ipv4/iana.go +34 -0
  375. data/ext/vendor/golang.org/x/net/ipv4/icmp.go +57 -0
  376. data/ext/vendor/golang.org/x/net/ipv4/icmp_linux.go +25 -0
  377. data/ext/vendor/golang.org/x/net/ipv4/icmp_stub.go +25 -0
  378. data/ext/vendor/golang.org/x/net/ipv4/icmp_test.go +95 -0
  379. data/ext/vendor/golang.org/x/net/ipv4/multicast_test.go +334 -0
  380. data/ext/vendor/golang.org/x/net/ipv4/multicastlistener_test.go +265 -0
  381. data/ext/vendor/golang.org/x/net/ipv4/multicastsockopt_test.go +195 -0
  382. data/ext/vendor/golang.org/x/net/ipv4/packet.go +69 -0
  383. data/ext/vendor/golang.org/x/net/ipv4/packet_go1_8.go +56 -0
  384. data/ext/vendor/golang.org/x/net/ipv4/packet_go1_9.go +67 -0
  385. data/ext/vendor/golang.org/x/net/ipv4/payload.go +23 -0
  386. data/ext/vendor/golang.org/x/net/ipv4/payload_cmsg.go +36 -0
  387. data/ext/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_8.go +59 -0
  388. data/ext/vendor/golang.org/x/net/ipv4/payload_cmsg_go1_9.go +67 -0
  389. data/ext/vendor/golang.org/x/net/ipv4/payload_nocmsg.go +42 -0
  390. data/ext/vendor/golang.org/x/net/ipv4/readwrite_go1_8_test.go +248 -0
  391. data/ext/vendor/golang.org/x/net/ipv4/readwrite_go1_9_test.go +388 -0
  392. data/ext/vendor/golang.org/x/net/ipv4/readwrite_test.go +140 -0
  393. data/ext/vendor/golang.org/x/net/ipv4/sockopt.go +44 -0
  394. data/ext/vendor/golang.org/x/net/ipv4/sockopt_posix.go +71 -0
  395. data/ext/vendor/golang.org/x/net/ipv4/sockopt_stub.go +42 -0
  396. data/ext/vendor/golang.org/x/net/ipv4/sys_asmreq.go +119 -0
  397. data/ext/vendor/golang.org/x/net/ipv4/sys_asmreq_stub.go +25 -0
  398. data/ext/vendor/golang.org/x/net/ipv4/sys_asmreqn.go +42 -0
  399. data/ext/vendor/golang.org/x/net/ipv4/sys_asmreqn_stub.go +21 -0
  400. data/ext/vendor/golang.org/x/net/ipv4/sys_bpf.go +23 -0
  401. data/ext/vendor/golang.org/x/net/ipv4/sys_bpf_stub.go +16 -0
  402. data/ext/vendor/golang.org/x/net/ipv4/sys_bsd.go +37 -0
  403. data/ext/vendor/golang.org/x/net/ipv4/sys_darwin.go +93 -0
  404. data/ext/vendor/golang.org/x/net/ipv4/sys_dragonfly.go +35 -0
  405. data/ext/vendor/golang.org/x/net/ipv4/sys_freebsd.go +76 -0
  406. data/ext/vendor/golang.org/x/net/ipv4/sys_linux.go +59 -0
  407. data/ext/vendor/golang.org/x/net/ipv4/sys_solaris.go +57 -0
  408. data/ext/vendor/golang.org/x/net/ipv4/sys_ssmreq.go +54 -0
  409. data/ext/vendor/golang.org/x/net/ipv4/sys_ssmreq_stub.go +21 -0
  410. data/ext/vendor/golang.org/x/net/ipv4/sys_stub.go +13 -0
  411. data/ext/vendor/golang.org/x/net/ipv4/sys_windows.go +67 -0
  412. data/ext/vendor/golang.org/x/net/ipv4/unicast_test.go +247 -0
  413. data/ext/vendor/golang.org/x/net/ipv4/unicastsockopt_test.go +148 -0
  414. data/ext/vendor/golang.org/x/net/ipv4/zsys_darwin.go +99 -0
  415. data/ext/vendor/golang.org/x/net/ipv4/zsys_dragonfly.go +31 -0
  416. data/ext/vendor/golang.org/x/net/ipv4/zsys_freebsd_386.go +93 -0
  417. data/ext/vendor/golang.org/x/net/ipv4/zsys_freebsd_amd64.go +95 -0
  418. data/ext/vendor/golang.org/x/net/ipv4/zsys_freebsd_arm.go +95 -0
  419. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_386.go +148 -0
  420. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_amd64.go +150 -0
  421. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_arm.go +148 -0
  422. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_arm64.go +150 -0
  423. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mips.go +148 -0
  424. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mips64.go +150 -0
  425. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mips64le.go +150 -0
  426. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_mipsle.go +148 -0
  427. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_ppc.go +148 -0
  428. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64.go +150 -0
  429. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_ppc64le.go +150 -0
  430. data/ext/vendor/golang.org/x/net/ipv4/zsys_linux_s390x.go +150 -0
  431. data/ext/vendor/golang.org/x/net/ipv4/zsys_netbsd.go +30 -0
  432. data/ext/vendor/golang.org/x/net/ipv4/zsys_openbsd.go +30 -0
  433. data/ext/vendor/golang.org/x/net/ipv4/zsys_solaris.go +100 -0
  434. data/ext/vendor/golang.org/x/net/ipv6/batch.go +119 -0
  435. data/ext/vendor/golang.org/x/net/ipv6/bpf_test.go +96 -0
  436. data/ext/vendor/golang.org/x/net/ipv6/control.go +187 -0
  437. data/ext/vendor/golang.org/x/net/ipv6/control_rfc2292_unix.go +48 -0
  438. data/ext/vendor/golang.org/x/net/ipv6/control_rfc3542_unix.go +94 -0
  439. data/ext/vendor/golang.org/x/net/ipv6/control_stub.go +13 -0
  440. data/ext/vendor/golang.org/x/net/ipv6/control_test.go +21 -0
  441. data/ext/vendor/golang.org/x/net/ipv6/control_unix.go +55 -0
  442. data/ext/vendor/golang.org/x/net/ipv6/control_windows.go +16 -0
  443. data/ext/vendor/golang.org/x/net/ipv6/defs_darwin.go +112 -0
  444. data/ext/vendor/golang.org/x/net/ipv6/defs_dragonfly.go +84 -0
  445. data/ext/vendor/golang.org/x/net/ipv6/defs_freebsd.go +105 -0
  446. data/ext/vendor/golang.org/x/net/ipv6/defs_linux.go +147 -0
  447. data/ext/vendor/golang.org/x/net/ipv6/defs_netbsd.go +80 -0
  448. data/ext/vendor/golang.org/x/net/ipv6/defs_openbsd.go +89 -0
  449. data/ext/vendor/golang.org/x/net/ipv6/defs_solaris.go +114 -0
  450. data/ext/vendor/golang.org/x/net/ipv6/dgramopt.go +302 -0
  451. data/ext/vendor/golang.org/x/net/ipv6/doc.go +243 -0
  452. data/ext/vendor/golang.org/x/net/ipv6/endpoint.go +128 -0
  453. data/ext/vendor/golang.org/x/net/ipv6/example_test.go +216 -0
  454. data/ext/vendor/golang.org/x/net/ipv6/gen.go +199 -0
  455. data/ext/vendor/golang.org/x/net/ipv6/genericopt.go +58 -0
  456. data/ext/vendor/golang.org/x/net/ipv6/header.go +55 -0
  457. data/ext/vendor/golang.org/x/net/ipv6/header_test.go +55 -0
  458. data/ext/vendor/golang.org/x/net/ipv6/helper.go +57 -0
  459. data/ext/vendor/golang.org/x/net/ipv6/iana.go +82 -0
  460. data/ext/vendor/golang.org/x/net/ipv6/icmp.go +60 -0
  461. data/ext/vendor/golang.org/x/net/ipv6/icmp_bsd.go +29 -0
  462. data/ext/vendor/golang.org/x/net/ipv6/icmp_linux.go +27 -0
  463. data/ext/vendor/golang.org/x/net/ipv6/icmp_solaris.go +27 -0
  464. data/ext/vendor/golang.org/x/net/ipv6/icmp_stub.go +23 -0
  465. data/ext/vendor/golang.org/x/net/ipv6/icmp_test.go +96 -0
  466. data/ext/vendor/golang.org/x/net/ipv6/icmp_windows.go +22 -0
  467. data/ext/vendor/golang.org/x/net/ipv6/mocktransponder_test.go +32 -0
  468. data/ext/vendor/golang.org/x/net/ipv6/multicast_test.go +264 -0
  469. data/ext/vendor/golang.org/x/net/ipv6/multicastlistener_test.go +261 -0
  470. data/ext/vendor/golang.org/x/net/ipv6/multicastsockopt_test.go +157 -0
  471. data/ext/vendor/golang.org/x/net/ipv6/payload.go +23 -0
  472. data/ext/vendor/golang.org/x/net/ipv6/payload_cmsg.go +35 -0
  473. data/ext/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_8.go +55 -0
  474. data/ext/vendor/golang.org/x/net/ipv6/payload_cmsg_go1_9.go +57 -0
  475. data/ext/vendor/golang.org/x/net/ipv6/payload_nocmsg.go +41 -0
  476. data/ext/vendor/golang.org/x/net/ipv6/readwrite_go1_8_test.go +242 -0
  477. data/ext/vendor/golang.org/x/net/ipv6/readwrite_go1_9_test.go +373 -0
  478. data/ext/vendor/golang.org/x/net/ipv6/readwrite_test.go +148 -0
  479. data/ext/vendor/golang.org/x/net/ipv6/sockopt.go +43 -0
  480. data/ext/vendor/golang.org/x/net/ipv6/sockopt_posix.go +87 -0
  481. data/ext/vendor/golang.org/x/net/ipv6/sockopt_stub.go +46 -0
  482. data/ext/vendor/golang.org/x/net/ipv6/sockopt_test.go +133 -0
  483. data/ext/vendor/golang.org/x/net/ipv6/sys_asmreq.go +24 -0
  484. data/ext/vendor/golang.org/x/net/ipv6/sys_asmreq_stub.go +17 -0
  485. data/ext/vendor/golang.org/x/net/ipv6/sys_bpf.go +23 -0
  486. data/ext/vendor/golang.org/x/net/ipv6/sys_bpf_stub.go +16 -0
  487. data/ext/vendor/golang.org/x/net/ipv6/sys_bsd.go +57 -0
  488. data/ext/vendor/golang.org/x/net/ipv6/sys_darwin.go +106 -0
  489. data/ext/vendor/golang.org/x/net/ipv6/sys_freebsd.go +92 -0
  490. data/ext/vendor/golang.org/x/net/ipv6/sys_linux.go +74 -0
  491. data/ext/vendor/golang.org/x/net/ipv6/sys_solaris.go +74 -0
  492. data/ext/vendor/golang.org/x/net/ipv6/sys_ssmreq.go +54 -0
  493. data/ext/vendor/golang.org/x/net/ipv6/sys_ssmreq_stub.go +21 -0
  494. data/ext/vendor/golang.org/x/net/ipv6/sys_stub.go +13 -0
  495. data/ext/vendor/golang.org/x/net/ipv6/sys_windows.go +75 -0
  496. data/ext/vendor/golang.org/x/net/ipv6/unicast_test.go +184 -0
  497. data/ext/vendor/golang.org/x/net/ipv6/unicastsockopt_test.go +120 -0
  498. data/ext/vendor/golang.org/x/net/ipv6/zsys_darwin.go +131 -0
  499. data/ext/vendor/golang.org/x/net/ipv6/zsys_dragonfly.go +88 -0
  500. data/ext/vendor/golang.org/x/net/ipv6/zsys_freebsd_386.go +122 -0
  501. data/ext/vendor/golang.org/x/net/ipv6/zsys_freebsd_amd64.go +124 -0
  502. data/ext/vendor/golang.org/x/net/ipv6/zsys_freebsd_arm.go +124 -0
  503. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_386.go +170 -0
  504. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_amd64.go +172 -0
  505. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_arm.go +170 -0
  506. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_arm64.go +172 -0
  507. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mips.go +170 -0
  508. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mips64.go +172 -0
  509. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mips64le.go +172 -0
  510. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_mipsle.go +170 -0
  511. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_ppc.go +170 -0
  512. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64.go +172 -0
  513. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_ppc64le.go +172 -0
  514. data/ext/vendor/golang.org/x/net/ipv6/zsys_linux_s390x.go +172 -0
  515. data/ext/vendor/golang.org/x/net/ipv6/zsys_netbsd.go +84 -0
  516. data/ext/vendor/golang.org/x/net/ipv6/zsys_openbsd.go +93 -0
  517. data/ext/vendor/golang.org/x/net/ipv6/zsys_solaris.go +131 -0
  518. data/ext/vendor/golang.org/x/net/lex/httplex/httplex.go +351 -0
  519. data/ext/vendor/golang.org/x/net/lex/httplex/httplex_test.go +119 -0
  520. data/ext/vendor/golang.org/x/net/lif/address.go +105 -0
  521. data/ext/vendor/golang.org/x/net/lif/address_test.go +123 -0
  522. data/ext/vendor/golang.org/x/net/lif/binary.go +115 -0
  523. data/ext/vendor/golang.org/x/net/lif/defs_solaris.go +90 -0
  524. data/ext/vendor/golang.org/x/net/lif/lif.go +43 -0
  525. data/ext/vendor/golang.org/x/net/lif/link.go +126 -0
  526. data/ext/vendor/golang.org/x/net/lif/link_test.go +63 -0
  527. data/ext/vendor/golang.org/x/net/lif/sys.go +21 -0
  528. data/ext/vendor/golang.org/x/net/lif/sys_solaris_amd64.s +8 -0
  529. data/ext/vendor/golang.org/x/net/lif/syscall.go +28 -0
  530. data/ext/vendor/golang.org/x/net/lif/zsys_solaris_amd64.go +103 -0
  531. data/ext/vendor/golang.org/x/net/nettest/conntest.go +456 -0
  532. data/ext/vendor/golang.org/x/net/nettest/conntest_go16.go +24 -0
  533. data/ext/vendor/golang.org/x/net/nettest/conntest_go17.go +24 -0
  534. data/ext/vendor/golang.org/x/net/nettest/conntest_test.go +76 -0
  535. data/ext/vendor/golang.org/x/net/netutil/listen.go +48 -0
  536. data/ext/vendor/golang.org/x/net/netutil/listen_test.go +101 -0
  537. data/ext/vendor/golang.org/x/net/proxy/direct.go +18 -0
  538. data/ext/vendor/golang.org/x/net/proxy/per_host.go +140 -0
  539. data/ext/vendor/golang.org/x/net/proxy/per_host_test.go +55 -0
  540. data/ext/vendor/golang.org/x/net/proxy/proxy.go +134 -0
  541. data/ext/vendor/golang.org/x/net/proxy/proxy_test.go +215 -0
  542. data/ext/vendor/golang.org/x/net/proxy/socks5.go +214 -0
  543. data/ext/vendor/golang.org/x/net/publicsuffix/gen.go +713 -0
  544. data/ext/vendor/golang.org/x/net/publicsuffix/list.go +135 -0
  545. data/ext/vendor/golang.org/x/net/publicsuffix/list_test.go +416 -0
  546. data/ext/vendor/golang.org/x/net/publicsuffix/table.go +9419 -0
  547. data/ext/vendor/golang.org/x/net/publicsuffix/table_test.go +16756 -0
  548. data/ext/vendor/golang.org/x/net/route/address.go +425 -0
  549. data/ext/vendor/golang.org/x/net/route/address_darwin_test.go +63 -0
  550. data/ext/vendor/golang.org/x/net/route/address_test.go +103 -0
  551. data/ext/vendor/golang.org/x/net/route/binary.go +90 -0
  552. data/ext/vendor/golang.org/x/net/route/defs_darwin.go +114 -0
  553. data/ext/vendor/golang.org/x/net/route/defs_dragonfly.go +113 -0
  554. data/ext/vendor/golang.org/x/net/route/defs_freebsd.go +337 -0
  555. data/ext/vendor/golang.org/x/net/route/defs_netbsd.go +112 -0
  556. data/ext/vendor/golang.org/x/net/route/defs_openbsd.go +116 -0
  557. data/ext/vendor/golang.org/x/net/route/interface.go +64 -0
  558. data/ext/vendor/golang.org/x/net/route/interface_announce.go +32 -0
  559. data/ext/vendor/golang.org/x/net/route/interface_classic.go +66 -0
  560. data/ext/vendor/golang.org/x/net/route/interface_freebsd.go +78 -0
  561. data/ext/vendor/golang.org/x/net/route/interface_multicast.go +30 -0
  562. data/ext/vendor/golang.org/x/net/route/interface_openbsd.go +90 -0
  563. data/ext/vendor/golang.org/x/net/route/message.go +72 -0
  564. data/ext/vendor/golang.org/x/net/route/message_darwin_test.go +34 -0
  565. data/ext/vendor/golang.org/x/net/route/message_freebsd_test.go +92 -0
  566. data/ext/vendor/golang.org/x/net/route/message_test.go +239 -0
  567. data/ext/vendor/golang.org/x/net/route/route.go +123 -0
  568. data/ext/vendor/golang.org/x/net/route/route_classic.go +67 -0
  569. data/ext/vendor/golang.org/x/net/route/route_openbsd.go +65 -0
  570. data/ext/vendor/golang.org/x/net/route/route_test.go +390 -0
  571. data/ext/vendor/golang.org/x/net/route/sys.go +39 -0
  572. data/ext/vendor/golang.org/x/net/route/sys_darwin.go +87 -0
  573. data/ext/vendor/golang.org/x/net/route/sys_dragonfly.go +76 -0
  574. data/ext/vendor/golang.org/x/net/route/sys_freebsd.go +155 -0
  575. data/ext/vendor/golang.org/x/net/route/sys_netbsd.go +71 -0
  576. data/ext/vendor/golang.org/x/net/route/sys_openbsd.go +80 -0
  577. data/ext/vendor/golang.org/x/net/route/syscall.go +28 -0
  578. data/ext/vendor/golang.org/x/net/route/zsys_darwin.go +99 -0
  579. data/ext/vendor/golang.org/x/net/route/zsys_dragonfly.go +98 -0
  580. data/ext/vendor/golang.org/x/net/route/zsys_freebsd_386.go +126 -0
  581. data/ext/vendor/golang.org/x/net/route/zsys_freebsd_amd64.go +123 -0
  582. data/ext/vendor/golang.org/x/net/route/zsys_freebsd_arm.go +123 -0
  583. data/ext/vendor/golang.org/x/net/route/zsys_netbsd.go +97 -0
  584. data/ext/vendor/golang.org/x/net/route/zsys_openbsd.go +101 -0
  585. data/ext/vendor/golang.org/x/net/trace/events.go +532 -0
  586. data/ext/vendor/golang.org/x/net/trace/histogram.go +365 -0
  587. data/ext/vendor/golang.org/x/net/trace/histogram_test.go +325 -0
  588. data/ext/vendor/golang.org/x/net/trace/trace.go +1082 -0
  589. data/ext/vendor/golang.org/x/net/trace/trace_go16.go +21 -0
  590. data/ext/vendor/golang.org/x/net/trace/trace_go17.go +21 -0
  591. data/ext/vendor/golang.org/x/net/trace/trace_test.go +178 -0
  592. data/ext/vendor/golang.org/x/net/webdav/file.go +796 -0
  593. data/ext/vendor/golang.org/x/net/webdav/file_go1.6.go +17 -0
  594. data/ext/vendor/golang.org/x/net/webdav/file_go1.7.go +16 -0
  595. data/ext/vendor/golang.org/x/net/webdav/file_test.go +1184 -0
  596. data/ext/vendor/golang.org/x/net/webdav/if.go +173 -0
  597. data/ext/vendor/golang.org/x/net/webdav/if_test.go +322 -0
  598. data/ext/vendor/golang.org/x/net/webdav/internal/xml/README +11 -0
  599. data/ext/vendor/golang.org/x/net/webdav/internal/xml/atom_test.go +56 -0
  600. data/ext/vendor/golang.org/x/net/webdav/internal/xml/example_test.go +151 -0
  601. data/ext/vendor/golang.org/x/net/webdav/internal/xml/marshal.go +1223 -0
  602. data/ext/vendor/golang.org/x/net/webdav/internal/xml/marshal_test.go +1939 -0
  603. data/ext/vendor/golang.org/x/net/webdav/internal/xml/read.go +692 -0
  604. data/ext/vendor/golang.org/x/net/webdav/internal/xml/read_test.go +744 -0
  605. data/ext/vendor/golang.org/x/net/webdav/internal/xml/typeinfo.go +371 -0
  606. data/ext/vendor/golang.org/x/net/webdav/internal/xml/xml.go +1998 -0
  607. data/ext/vendor/golang.org/x/net/webdav/internal/xml/xml_test.go +752 -0
  608. data/ext/vendor/golang.org/x/net/webdav/litmus_test_server.go +94 -0
  609. data/ext/vendor/golang.org/x/net/webdav/lock.go +445 -0
  610. data/ext/vendor/golang.org/x/net/webdav/lock_test.go +731 -0
  611. data/ext/vendor/golang.org/x/net/webdav/prop.go +418 -0
  612. data/ext/vendor/golang.org/x/net/webdav/prop_test.go +613 -0
  613. data/ext/vendor/golang.org/x/net/webdav/webdav.go +702 -0
  614. data/ext/vendor/golang.org/x/net/webdav/webdav_test.go +344 -0
  615. data/ext/vendor/golang.org/x/net/webdav/xml.go +519 -0
  616. data/ext/vendor/golang.org/x/net/webdav/xml_test.go +906 -0
  617. data/ext/vendor/golang.org/x/net/websocket/client.go +106 -0
  618. data/ext/vendor/golang.org/x/net/websocket/dial.go +24 -0
  619. data/ext/vendor/golang.org/x/net/websocket/dial_test.go +43 -0
  620. data/ext/vendor/golang.org/x/net/websocket/exampledial_test.go +31 -0
  621. data/ext/vendor/golang.org/x/net/websocket/examplehandler_test.go +26 -0
  622. data/ext/vendor/golang.org/x/net/websocket/hybi.go +583 -0
  623. data/ext/vendor/golang.org/x/net/websocket/hybi_test.go +608 -0
  624. data/ext/vendor/golang.org/x/net/websocket/server.go +113 -0
  625. data/ext/vendor/golang.org/x/net/websocket/websocket.go +448 -0
  626. data/ext/vendor/golang.org/x/net/websocket/websocket_test.go +665 -0
  627. data/ext/vendor/golang.org/x/net/xsrftoken/xsrf.go +94 -0
  628. data/ext/vendor/golang.org/x/net/xsrftoken/xsrf_test.go +83 -0
  629. data/ext/vendor/golang.org/x/text/AUTHORS +3 -0
  630. data/ext/vendor/golang.org/x/text/CONTRIBUTING.md +31 -0
  631. data/ext/vendor/golang.org/x/text/CONTRIBUTORS +3 -0
  632. data/ext/vendor/golang.org/x/text/LICENSE +27 -0
  633. data/ext/vendor/golang.org/x/text/PATENTS +22 -0
  634. data/ext/vendor/golang.org/x/text/README.md +91 -0
  635. data/ext/vendor/golang.org/x/text/cases/cases.go +162 -0
  636. data/ext/vendor/golang.org/x/text/cases/context.go +376 -0
  637. data/ext/vendor/golang.org/x/text/cases/context_test.go +438 -0
  638. data/ext/vendor/golang.org/x/text/cases/example_test.go +53 -0
  639. data/ext/vendor/golang.org/x/text/cases/fold.go +34 -0
  640. data/ext/vendor/golang.org/x/text/cases/fold_test.go +51 -0
  641. data/ext/vendor/golang.org/x/text/cases/gen.go +839 -0
  642. data/ext/vendor/golang.org/x/text/cases/gen_trieval.go +219 -0
  643. data/ext/vendor/golang.org/x/text/cases/icu.go +61 -0
  644. data/ext/vendor/golang.org/x/text/cases/icu_test.go +210 -0
  645. data/ext/vendor/golang.org/x/text/cases/info.go +82 -0
  646. data/ext/vendor/golang.org/x/text/cases/map.go +816 -0
  647. data/ext/vendor/golang.org/x/text/cases/map_test.go +950 -0
  648. data/ext/vendor/golang.org/x/text/cases/tables.go +2251 -0
  649. data/ext/vendor/golang.org/x/text/cases/tables_test.go +1158 -0
  650. data/ext/vendor/golang.org/x/text/cases/trieval.go +215 -0
  651. data/ext/vendor/golang.org/x/text/cmd/gotext/doc.go +35 -0
  652. data/ext/vendor/golang.org/x/text/cmd/gotext/extract.go +195 -0
  653. data/ext/vendor/golang.org/x/text/cmd/gotext/main.go +356 -0
  654. data/ext/vendor/golang.org/x/text/cmd/gotext/message.go +127 -0
  655. data/ext/vendor/golang.org/x/text/codereview.cfg +1 -0
  656. data/ext/vendor/golang.org/x/text/collate/build/builder.go +702 -0
  657. data/ext/vendor/golang.org/x/text/collate/build/builder_test.go +290 -0
  658. data/ext/vendor/golang.org/x/text/collate/build/colelem.go +294 -0
  659. data/ext/vendor/golang.org/x/text/collate/build/colelem_test.go +215 -0
  660. data/ext/vendor/golang.org/x/text/collate/build/contract.go +309 -0
  661. data/ext/vendor/golang.org/x/text/collate/build/contract_test.go +266 -0
  662. data/ext/vendor/golang.org/x/text/collate/build/order.go +393 -0
  663. data/ext/vendor/golang.org/x/text/collate/build/order_test.go +229 -0
  664. data/ext/vendor/golang.org/x/text/collate/build/table.go +81 -0
  665. data/ext/vendor/golang.org/x/text/collate/build/trie.go +290 -0
  666. data/ext/vendor/golang.org/x/text/collate/build/trie_test.go +107 -0
  667. data/ext/vendor/golang.org/x/text/collate/collate.go +403 -0
  668. data/ext/vendor/golang.org/x/text/collate/collate_test.go +482 -0
  669. data/ext/vendor/golang.org/x/text/collate/export_test.go +51 -0
  670. data/ext/vendor/golang.org/x/text/collate/index.go +32 -0
  671. data/ext/vendor/golang.org/x/text/collate/maketables.go +553 -0
  672. data/ext/vendor/golang.org/x/text/collate/option.go +239 -0
  673. data/ext/vendor/golang.org/x/text/collate/option_test.go +209 -0
  674. data/ext/vendor/golang.org/x/text/collate/reg_test.go +230 -0
  675. data/ext/vendor/golang.org/x/text/collate/sort.go +81 -0
  676. data/ext/vendor/golang.org/x/text/collate/sort_test.go +55 -0
  677. data/ext/vendor/golang.org/x/text/collate/table_test.go +291 -0
  678. data/ext/vendor/golang.org/x/text/collate/tables.go +73789 -0
  679. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/Makefile +7 -0
  680. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/chars.go +1156 -0
  681. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/col.go +97 -0
  682. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/colcmp.go +529 -0
  683. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/darwin.go +111 -0
  684. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/gen.go +183 -0
  685. data/ext/vendor/golang.org/x/text/collate/tools/colcmp/icu.go +209 -0
  686. data/ext/vendor/golang.org/x/text/currency/common.go +66 -0
  687. data/ext/vendor/golang.org/x/text/currency/currency.go +185 -0
  688. data/ext/vendor/golang.org/x/text/currency/currency_test.go +171 -0
  689. data/ext/vendor/golang.org/x/text/currency/example_test.go +27 -0
  690. data/ext/vendor/golang.org/x/text/currency/format.go +215 -0
  691. data/ext/vendor/golang.org/x/text/currency/format_test.go +70 -0
  692. data/ext/vendor/golang.org/x/text/currency/gen.go +400 -0
  693. data/ext/vendor/golang.org/x/text/currency/gen_common.go +70 -0
  694. data/ext/vendor/golang.org/x/text/currency/query.go +152 -0
  695. data/ext/vendor/golang.org/x/text/currency/query_test.go +107 -0
  696. data/ext/vendor/golang.org/x/text/currency/tables.go +2574 -0
  697. data/ext/vendor/golang.org/x/text/currency/tables_test.go +93 -0
  698. data/ext/vendor/golang.org/x/text/doc.go +13 -0
  699. data/ext/vendor/golang.org/x/text/encoding/charmap/charmap.go +249 -0
  700. data/ext/vendor/golang.org/x/text/encoding/charmap/charmap_test.go +258 -0
  701. data/ext/vendor/golang.org/x/text/encoding/charmap/maketables.go +556 -0
  702. data/ext/vendor/golang.org/x/text/encoding/charmap/tables.go +7410 -0
  703. data/ext/vendor/golang.org/x/text/encoding/encoding.go +335 -0
  704. data/ext/vendor/golang.org/x/text/encoding/encoding_test.go +290 -0
  705. data/ext/vendor/golang.org/x/text/encoding/example_test.go +42 -0
  706. data/ext/vendor/golang.org/x/text/encoding/htmlindex/gen.go +173 -0
  707. data/ext/vendor/golang.org/x/text/encoding/htmlindex/htmlindex.go +86 -0
  708. data/ext/vendor/golang.org/x/text/encoding/htmlindex/htmlindex_test.go +144 -0
  709. data/ext/vendor/golang.org/x/text/encoding/htmlindex/map.go +105 -0
  710. data/ext/vendor/golang.org/x/text/encoding/htmlindex/tables.go +352 -0
  711. data/ext/vendor/golang.org/x/text/encoding/ianaindex/example_test.go +27 -0
  712. data/ext/vendor/golang.org/x/text/encoding/ianaindex/gen.go +192 -0
  713. data/ext/vendor/golang.org/x/text/encoding/ianaindex/ianaindex.go +209 -0
  714. data/ext/vendor/golang.org/x/text/encoding/ianaindex/ianaindex_test.go +192 -0
  715. data/ext/vendor/golang.org/x/text/encoding/ianaindex/tables.go +2348 -0
  716. data/ext/vendor/golang.org/x/text/encoding/internal/enctest/enctest.go +180 -0
  717. data/ext/vendor/golang.org/x/text/encoding/internal/identifier/gen.go +137 -0
  718. data/ext/vendor/golang.org/x/text/encoding/internal/identifier/identifier.go +81 -0
  719. data/ext/vendor/golang.org/x/text/encoding/internal/identifier/mib.go +1621 -0
  720. data/ext/vendor/golang.org/x/text/encoding/internal/internal.go +75 -0
  721. data/ext/vendor/golang.org/x/text/encoding/japanese/all.go +12 -0
  722. data/ext/vendor/golang.org/x/text/encoding/japanese/all_test.go +248 -0
  723. data/ext/vendor/golang.org/x/text/encoding/japanese/eucjp.go +225 -0
  724. data/ext/vendor/golang.org/x/text/encoding/japanese/iso2022jp.go +299 -0
  725. data/ext/vendor/golang.org/x/text/encoding/japanese/maketables.go +161 -0
  726. data/ext/vendor/golang.org/x/text/encoding/japanese/shiftjis.go +189 -0
  727. data/ext/vendor/golang.org/x/text/encoding/japanese/tables.go +26971 -0
  728. data/ext/vendor/golang.org/x/text/encoding/korean/all_test.go +94 -0
  729. data/ext/vendor/golang.org/x/text/encoding/korean/euckr.go +177 -0
  730. data/ext/vendor/golang.org/x/text/encoding/korean/maketables.go +143 -0
  731. data/ext/vendor/golang.org/x/text/encoding/korean/tables.go +34152 -0
  732. data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/all.go +12 -0
  733. data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/all_test.go +143 -0
  734. data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/gbk.go +269 -0
  735. data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/hzgb2312.go +245 -0
  736. data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/maketables.go +161 -0
  737. data/ext/vendor/golang.org/x/text/encoding/simplifiedchinese/tables.go +43999 -0
  738. data/ext/vendor/golang.org/x/text/encoding/testdata/candide-gb18030.txt +510 -0
  739. data/ext/vendor/golang.org/x/text/encoding/testdata/candide-utf-16le.txt +0 -0
  740. data/ext/vendor/golang.org/x/text/encoding/testdata/candide-utf-32be.txt +0 -0
  741. data/ext/vendor/golang.org/x/text/encoding/testdata/candide-utf-8.txt +510 -0
  742. data/ext/vendor/golang.org/x/text/encoding/testdata/candide-windows-1252.txt +510 -0
  743. data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-euc-jp.txt +178 -0
  744. data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-iso-2022-jp.txt +178 -0
  745. data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-shift-jis.txt +178 -0
  746. data/ext/vendor/golang.org/x/text/encoding/testdata/rashomon-utf-8.txt +178 -0
  747. data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-gb-levels-1-and-2-hz-gb2312.txt +107 -0
  748. data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-gb-levels-1-and-2-utf-8.txt +107 -0
  749. data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-simplified-gbk.txt +107 -0
  750. data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-simplified-utf-8.txt +107 -0
  751. data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-traditional-big5.txt +106 -0
  752. data/ext/vendor/golang.org/x/text/encoding/testdata/sunzi-bingfa-traditional-utf-8.txt +106 -0
  753. data/ext/vendor/golang.org/x/text/encoding/testdata/unsu-joh-eun-nal-euc-kr.txt +175 -0
  754. data/ext/vendor/golang.org/x/text/encoding/testdata/unsu-joh-eun-nal-utf-8.txt +175 -0
  755. data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/all_test.go +114 -0
  756. data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/big5.go +199 -0
  757. data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/maketables.go +140 -0
  758. data/ext/vendor/golang.org/x/text/encoding/traditionalchinese/tables.go +37142 -0
  759. data/ext/vendor/golang.org/x/text/encoding/unicode/override.go +82 -0
  760. data/ext/vendor/golang.org/x/text/encoding/unicode/unicode.go +434 -0
  761. data/ext/vendor/golang.org/x/text/encoding/unicode/unicode_test.go +499 -0
  762. data/ext/vendor/golang.org/x/text/encoding/unicode/utf32/utf32.go +296 -0
  763. data/ext/vendor/golang.org/x/text/encoding/unicode/utf32/utf32_test.go +248 -0
  764. data/ext/vendor/golang.org/x/text/feature/plural/common.go +70 -0
  765. data/ext/vendor/golang.org/x/text/feature/plural/data_test.go +190 -0
  766. data/ext/vendor/golang.org/x/text/feature/plural/example_test.go +46 -0
  767. data/ext/vendor/golang.org/x/text/feature/plural/gen.go +513 -0
  768. data/ext/vendor/golang.org/x/text/feature/plural/gen_common.go +74 -0
  769. data/ext/vendor/golang.org/x/text/feature/plural/message.go +244 -0
  770. data/ext/vendor/golang.org/x/text/feature/plural/message_test.go +197 -0
  771. data/ext/vendor/golang.org/x/text/feature/plural/plural.go +258 -0
  772. data/ext/vendor/golang.org/x/text/feature/plural/plural_test.go +216 -0
  773. data/ext/vendor/golang.org/x/text/feature/plural/tables.go +540 -0
  774. data/ext/vendor/golang.org/x/text/gen.go +318 -0
  775. data/ext/vendor/golang.org/x/text/internal/catmsg/catmsg.go +366 -0
  776. data/ext/vendor/golang.org/x/text/internal/catmsg/catmsg_test.go +316 -0
  777. data/ext/vendor/golang.org/x/text/internal/catmsg/codec.go +407 -0
  778. data/ext/vendor/golang.org/x/text/internal/catmsg/varint.go +62 -0
  779. data/ext/vendor/golang.org/x/text/internal/catmsg/varint_test.go +123 -0
  780. data/ext/vendor/golang.org/x/text/internal/colltab/collate_test.go +121 -0
  781. data/ext/vendor/golang.org/x/text/internal/colltab/collelem.go +371 -0
  782. data/ext/vendor/golang.org/x/text/internal/colltab/collelem_test.go +183 -0
  783. data/ext/vendor/golang.org/x/text/internal/colltab/colltab.go +105 -0
  784. data/ext/vendor/golang.org/x/text/internal/colltab/colltab_test.go +64 -0
  785. data/ext/vendor/golang.org/x/text/internal/colltab/contract.go +145 -0
  786. data/ext/vendor/golang.org/x/text/internal/colltab/contract_test.go +131 -0
  787. data/ext/vendor/golang.org/x/text/internal/colltab/iter.go +178 -0
  788. data/ext/vendor/golang.org/x/text/internal/colltab/iter_test.go +63 -0
  789. data/ext/vendor/golang.org/x/text/internal/colltab/numeric.go +236 -0
  790. data/ext/vendor/golang.org/x/text/internal/colltab/numeric_test.go +159 -0
  791. data/ext/vendor/golang.org/x/text/internal/colltab/table.go +275 -0
  792. data/ext/vendor/golang.org/x/text/internal/colltab/trie.go +159 -0
  793. data/ext/vendor/golang.org/x/text/internal/colltab/trie_test.go +106 -0
  794. data/ext/vendor/golang.org/x/text/internal/colltab/weighter.go +31 -0
  795. data/ext/vendor/golang.org/x/text/internal/colltab/weighter_test.go +42 -0
  796. data/ext/vendor/golang.org/x/text/internal/export/README +4 -0
  797. data/ext/vendor/golang.org/x/text/internal/export/idna/common_test.go +55 -0
  798. data/ext/vendor/golang.org/x/text/internal/export/idna/example_test.go +68 -0
  799. data/ext/vendor/golang.org/x/text/internal/export/idna/gen.go +276 -0
  800. data/ext/vendor/golang.org/x/text/internal/export/idna/gen_common.go +59 -0
  801. data/ext/vendor/golang.org/x/text/internal/export/idna/gen_test.go +91 -0
  802. data/ext/vendor/golang.org/x/text/internal/export/idna/gen_trieval.go +123 -0
  803. data/ext/vendor/golang.org/x/text/internal/export/idna/idna.go +717 -0
  804. data/ext/vendor/golang.org/x/text/internal/export/idna/idna_test.go +308 -0
  805. data/ext/vendor/golang.org/x/text/internal/export/idna/punycode.go +201 -0
  806. data/ext/vendor/golang.org/x/text/internal/export/idna/punycode_test.go +198 -0
  807. data/ext/vendor/golang.org/x/text/internal/export/idna/tables.go +4557 -0
  808. data/ext/vendor/golang.org/x/text/internal/export/idna/trie.go +70 -0
  809. data/ext/vendor/golang.org/x/text/internal/export/idna/trieval.go +119 -0
  810. data/ext/vendor/golang.org/x/text/internal/format/format.go +41 -0
  811. data/ext/vendor/golang.org/x/text/internal/gen.go +52 -0
  812. data/ext/vendor/golang.org/x/text/internal/gen/code.go +351 -0
  813. data/ext/vendor/golang.org/x/text/internal/gen/gen.go +281 -0
  814. data/ext/vendor/golang.org/x/text/internal/gen_test.go +38 -0
  815. data/ext/vendor/golang.org/x/text/internal/internal.go +51 -0
  816. data/ext/vendor/golang.org/x/text/internal/internal_test.go +38 -0
  817. data/ext/vendor/golang.org/x/text/internal/match.go +67 -0
  818. data/ext/vendor/golang.org/x/text/internal/match_test.go +56 -0
  819. data/ext/vendor/golang.org/x/text/internal/number/common.go +40 -0
  820. data/ext/vendor/golang.org/x/text/internal/number/decimal.go +498 -0
  821. data/ext/vendor/golang.org/x/text/internal/number/decimal_test.go +329 -0
  822. data/ext/vendor/golang.org/x/text/internal/number/format.go +540 -0
  823. data/ext/vendor/golang.org/x/text/internal/number/format_test.go +522 -0
  824. data/ext/vendor/golang.org/x/text/internal/number/gen.go +458 -0
  825. data/ext/vendor/golang.org/x/text/internal/number/gen_common.go +44 -0
  826. data/ext/vendor/golang.org/x/text/internal/number/number.go +154 -0
  827. data/ext/vendor/golang.org/x/text/internal/number/number_test.go +100 -0
  828. data/ext/vendor/golang.org/x/text/internal/number/pattern.go +485 -0
  829. data/ext/vendor/golang.org/x/text/internal/number/pattern_test.go +438 -0
  830. data/ext/vendor/golang.org/x/text/internal/number/roundingmode_string.go +16 -0
  831. data/ext/vendor/golang.org/x/text/internal/number/tables.go +1154 -0
  832. data/ext/vendor/golang.org/x/text/internal/number/tables_test.go +125 -0
  833. data/ext/vendor/golang.org/x/text/internal/stringset/set.go +86 -0
  834. data/ext/vendor/golang.org/x/text/internal/stringset/set_test.go +53 -0
  835. data/ext/vendor/golang.org/x/text/internal/tables.go +117 -0
  836. data/ext/vendor/golang.org/x/text/internal/tag/tag.go +100 -0
  837. data/ext/vendor/golang.org/x/text/internal/tag/tag_test.go +67 -0
  838. data/ext/vendor/golang.org/x/text/internal/testtext/codesize.go +53 -0
  839. data/ext/vendor/golang.org/x/text/internal/testtext/flag.go +22 -0
  840. data/ext/vendor/golang.org/x/text/internal/testtext/gc.go +14 -0
  841. data/ext/vendor/golang.org/x/text/internal/testtext/gccgo.go +11 -0
  842. data/ext/vendor/golang.org/x/text/internal/testtext/go1_6.go +23 -0
  843. data/ext/vendor/golang.org/x/text/internal/testtext/go1_7.go +17 -0
  844. data/ext/vendor/golang.org/x/text/internal/testtext/text.go +105 -0
  845. data/ext/vendor/golang.org/x/text/internal/triegen/compact.go +58 -0
  846. data/ext/vendor/golang.org/x/text/internal/triegen/data_test.go +875 -0
  847. data/ext/vendor/golang.org/x/text/internal/triegen/example_compact_test.go +71 -0
  848. data/ext/vendor/golang.org/x/text/internal/triegen/example_test.go +148 -0
  849. data/ext/vendor/golang.org/x/text/internal/triegen/gen_test.go +68 -0
  850. data/ext/vendor/golang.org/x/text/internal/triegen/print.go +251 -0
  851. data/ext/vendor/golang.org/x/text/internal/triegen/triegen.go +494 -0
  852. data/ext/vendor/golang.org/x/text/internal/ucd/example_test.go +81 -0
  853. data/ext/vendor/golang.org/x/text/internal/ucd/ucd.go +371 -0
  854. data/ext/vendor/golang.org/x/text/internal/ucd/ucd_test.go +105 -0
  855. data/ext/vendor/golang.org/x/text/internal/utf8internal/utf8internal.go +87 -0
  856. data/ext/vendor/golang.org/x/text/language/Makefile +16 -0
  857. data/ext/vendor/golang.org/x/text/language/common.go +16 -0
  858. data/ext/vendor/golang.org/x/text/language/coverage.go +197 -0
  859. data/ext/vendor/golang.org/x/text/language/coverage_test.go +154 -0
  860. data/ext/vendor/golang.org/x/text/language/display/dict.go +92 -0
  861. data/ext/vendor/golang.org/x/text/language/display/dict_test.go +39 -0
  862. data/ext/vendor/golang.org/x/text/language/display/display.go +420 -0
  863. data/ext/vendor/golang.org/x/text/language/display/display_test.go +705 -0
  864. data/ext/vendor/golang.org/x/text/language/display/examples_test.go +116 -0
  865. data/ext/vendor/golang.org/x/text/language/display/lookup.go +251 -0
  866. data/ext/vendor/golang.org/x/text/language/display/maketables.go +602 -0
  867. data/ext/vendor/golang.org/x/text/language/display/tables.go +50344 -0
  868. data/ext/vendor/golang.org/x/text/language/doc.go +102 -0
  869. data/ext/vendor/golang.org/x/text/language/examples_test.go +413 -0
  870. data/ext/vendor/golang.org/x/text/language/gen.go +1706 -0
  871. data/ext/vendor/golang.org/x/text/language/gen_common.go +20 -0
  872. data/ext/vendor/golang.org/x/text/language/gen_index.go +162 -0
  873. data/ext/vendor/golang.org/x/text/language/go1_1.go +38 -0
  874. data/ext/vendor/golang.org/x/text/language/go1_2.go +11 -0
  875. data/ext/vendor/golang.org/x/text/language/httpexample_test.go +48 -0
  876. data/ext/vendor/golang.org/x/text/language/index.go +769 -0
  877. data/ext/vendor/golang.org/x/text/language/language.go +887 -0
  878. data/ext/vendor/golang.org/x/text/language/language_test.go +878 -0
  879. data/ext/vendor/golang.org/x/text/language/lookup.go +396 -0
  880. data/ext/vendor/golang.org/x/text/language/lookup_test.go +457 -0
  881. data/ext/vendor/golang.org/x/text/language/match.go +933 -0
  882. data/ext/vendor/golang.org/x/text/language/match_test.go +505 -0
  883. data/ext/vendor/golang.org/x/text/language/parse.go +859 -0
  884. data/ext/vendor/golang.org/x/text/language/parse_test.go +517 -0
  885. data/ext/vendor/golang.org/x/text/language/tables.go +3675 -0
  886. data/ext/vendor/golang.org/x/text/language/tags.go +143 -0
  887. data/ext/vendor/golang.org/x/text/language/testdata/CLDRLocaleMatcherTest.txt +389 -0
  888. data/ext/vendor/golang.org/x/text/language/testdata/GoLocaleMatcherTest.txt +226 -0
  889. data/ext/vendor/golang.org/x/text/message/catalog.go +28 -0
  890. data/ext/vendor/golang.org/x/text/message/catalog/catalog.go +292 -0
  891. data/ext/vendor/golang.org/x/text/message/catalog/catalog_test.go +194 -0
  892. data/ext/vendor/golang.org/x/text/message/catalog/dict.go +90 -0
  893. data/ext/vendor/golang.org/x/text/message/doc.go +100 -0
  894. data/ext/vendor/golang.org/x/text/message/examples_test.go +42 -0
  895. data/ext/vendor/golang.org/x/text/message/fmt_test.go +1889 -0
  896. data/ext/vendor/golang.org/x/text/message/format.go +532 -0
  897. data/ext/vendor/golang.org/x/text/message/message.go +169 -0
  898. data/ext/vendor/golang.org/x/text/message/message_test.go +181 -0
  899. data/ext/vendor/golang.org/x/text/message/print.go +1194 -0
  900. data/ext/vendor/golang.org/x/text/number/doc.go +28 -0
  901. data/ext/vendor/golang.org/x/text/number/examples_test.go +28 -0
  902. data/ext/vendor/golang.org/x/text/number/format.go +122 -0
  903. data/ext/vendor/golang.org/x/text/number/format_test.go +107 -0
  904. data/ext/vendor/golang.org/x/text/number/number.go +77 -0
  905. data/ext/vendor/golang.org/x/text/number/number_test.go +190 -0
  906. data/ext/vendor/golang.org/x/text/number/option.go +177 -0
  907. data/ext/vendor/golang.org/x/text/runes/cond.go +187 -0
  908. data/ext/vendor/golang.org/x/text/runes/cond_test.go +282 -0
  909. data/ext/vendor/golang.org/x/text/runes/example_test.go +60 -0
  910. data/ext/vendor/golang.org/x/text/runes/runes.go +355 -0
  911. data/ext/vendor/golang.org/x/text/runes/runes_test.go +664 -0
  912. data/ext/vendor/golang.org/x/text/search/index.go +35 -0
  913. data/ext/vendor/golang.org/x/text/search/pattern.go +155 -0
  914. data/ext/vendor/golang.org/x/text/search/pattern_test.go +357 -0
  915. data/ext/vendor/golang.org/x/text/search/search.go +237 -0
  916. data/ext/vendor/golang.org/x/text/search/tables.go +12448 -0
  917. data/ext/vendor/golang.org/x/text/secure/bidirule/bench_test.go +54 -0
  918. data/ext/vendor/golang.org/x/text/secure/bidirule/bidirule.go +340 -0
  919. data/ext/vendor/golang.org/x/text/secure/bidirule/bidirule_test.go +851 -0
  920. data/ext/vendor/golang.org/x/text/secure/doc.go +6 -0
  921. data/ext/vendor/golang.org/x/text/secure/precis/benchmark_test.go +82 -0
  922. data/ext/vendor/golang.org/x/text/secure/precis/class.go +36 -0
  923. data/ext/vendor/golang.org/x/text/secure/precis/class_test.go +50 -0
  924. data/ext/vendor/golang.org/x/text/secure/precis/context.go +139 -0
  925. data/ext/vendor/golang.org/x/text/secure/precis/doc.go +14 -0
  926. data/ext/vendor/golang.org/x/text/secure/precis/enforce_test.go +396 -0
  927. data/ext/vendor/golang.org/x/text/secure/precis/gen.go +310 -0
  928. data/ext/vendor/golang.org/x/text/secure/precis/gen_trieval.go +68 -0
  929. data/ext/vendor/golang.org/x/text/secure/precis/nickname.go +72 -0
  930. data/ext/vendor/golang.org/x/text/secure/precis/options.go +157 -0
  931. data/ext/vendor/golang.org/x/text/secure/precis/profile.go +402 -0
  932. data/ext/vendor/golang.org/x/text/secure/precis/profile_test.go +149 -0
  933. data/ext/vendor/golang.org/x/text/secure/precis/profiles.go +78 -0
  934. data/ext/vendor/golang.org/x/text/secure/precis/tables.go +3887 -0
  935. data/ext/vendor/golang.org/x/text/secure/precis/tables_test.go +69 -0
  936. data/ext/vendor/golang.org/x/text/secure/precis/transformer.go +32 -0
  937. data/ext/vendor/golang.org/x/text/secure/precis/trieval.go +64 -0
  938. data/ext/vendor/golang.org/x/text/transform/examples_test.go +37 -0
  939. data/ext/vendor/golang.org/x/text/transform/transform.go +705 -0
  940. data/ext/vendor/golang.org/x/text/transform/transform_test.go +1317 -0
  941. data/ext/vendor/golang.org/x/text/unicode/bidi/bidi.go +198 -0
  942. data/ext/vendor/golang.org/x/text/unicode/bidi/bracket.go +335 -0
  943. data/ext/vendor/golang.org/x/text/unicode/bidi/core.go +1058 -0
  944. data/ext/vendor/golang.org/x/text/unicode/bidi/core_test.go +224 -0
  945. data/ext/vendor/golang.org/x/text/unicode/bidi/gen.go +133 -0
  946. data/ext/vendor/golang.org/x/text/unicode/bidi/gen_ranges.go +57 -0
  947. data/ext/vendor/golang.org/x/text/unicode/bidi/gen_trieval.go +64 -0
  948. data/ext/vendor/golang.org/x/text/unicode/bidi/prop.go +206 -0
  949. data/ext/vendor/golang.org/x/text/unicode/bidi/ranges_test.go +53 -0
  950. data/ext/vendor/golang.org/x/text/unicode/bidi/tables.go +1813 -0
  951. data/ext/vendor/golang.org/x/text/unicode/bidi/tables_test.go +82 -0
  952. data/ext/vendor/golang.org/x/text/unicode/bidi/trieval.go +60 -0
  953. data/ext/vendor/golang.org/x/text/unicode/cldr/base.go +100 -0
  954. data/ext/vendor/golang.org/x/text/unicode/cldr/cldr.go +130 -0
  955. data/ext/vendor/golang.org/x/text/unicode/cldr/cldr_test.go +27 -0
  956. data/ext/vendor/golang.org/x/text/unicode/cldr/collate.go +359 -0
  957. data/ext/vendor/golang.org/x/text/unicode/cldr/collate_test.go +275 -0
  958. data/ext/vendor/golang.org/x/text/unicode/cldr/data_test.go +186 -0
  959. data/ext/vendor/golang.org/x/text/unicode/cldr/decode.go +171 -0
  960. data/ext/vendor/golang.org/x/text/unicode/cldr/examples_test.go +21 -0
  961. data/ext/vendor/golang.org/x/text/unicode/cldr/makexml.go +400 -0
  962. data/ext/vendor/golang.org/x/text/unicode/cldr/resolve.go +602 -0
  963. data/ext/vendor/golang.org/x/text/unicode/cldr/resolve_test.go +368 -0
  964. data/ext/vendor/golang.org/x/text/unicode/cldr/slice.go +144 -0
  965. data/ext/vendor/golang.org/x/text/unicode/cldr/slice_test.go +175 -0
  966. data/ext/vendor/golang.org/x/text/unicode/cldr/xml.go +1487 -0
  967. data/ext/vendor/golang.org/x/text/unicode/doc.go +8 -0
  968. data/ext/vendor/golang.org/x/text/unicode/norm/composition.go +508 -0
  969. data/ext/vendor/golang.org/x/text/unicode/norm/composition_test.go +130 -0
  970. data/ext/vendor/golang.org/x/text/unicode/norm/example_iter_test.go +82 -0
  971. data/ext/vendor/golang.org/x/text/unicode/norm/example_test.go +27 -0
  972. data/ext/vendor/golang.org/x/text/unicode/norm/forminfo.go +259 -0
  973. data/ext/vendor/golang.org/x/text/unicode/norm/forminfo_test.go +54 -0
  974. data/ext/vendor/golang.org/x/text/unicode/norm/input.go +109 -0
  975. data/ext/vendor/golang.org/x/text/unicode/norm/iter.go +457 -0
  976. data/ext/vendor/golang.org/x/text/unicode/norm/iter_test.go +98 -0
  977. data/ext/vendor/golang.org/x/text/unicode/norm/maketables.go +976 -0
  978. data/ext/vendor/golang.org/x/text/unicode/norm/norm_test.go +14 -0
  979. data/ext/vendor/golang.org/x/text/unicode/norm/normalize.go +609 -0
  980. data/ext/vendor/golang.org/x/text/unicode/norm/normalize_test.go +1287 -0
  981. data/ext/vendor/golang.org/x/text/unicode/norm/readwriter.go +125 -0
  982. data/ext/vendor/golang.org/x/text/unicode/norm/readwriter_test.go +56 -0
  983. data/ext/vendor/golang.org/x/text/unicode/norm/tables.go +7651 -0
  984. data/ext/vendor/golang.org/x/text/unicode/norm/transform.go +88 -0
  985. data/ext/vendor/golang.org/x/text/unicode/norm/transform_test.go +101 -0
  986. data/ext/vendor/golang.org/x/text/unicode/norm/trie.go +54 -0
  987. data/ext/vendor/golang.org/x/text/unicode/norm/triegen.go +117 -0
  988. data/ext/vendor/golang.org/x/text/unicode/norm/ucd_test.go +275 -0
  989. data/ext/vendor/golang.org/x/text/unicode/rangetable/gen.go +115 -0
  990. data/ext/vendor/golang.org/x/text/unicode/rangetable/merge.go +260 -0
  991. data/ext/vendor/golang.org/x/text/unicode/rangetable/merge_test.go +184 -0
  992. data/ext/vendor/golang.org/x/text/unicode/rangetable/rangetable.go +70 -0
  993. data/ext/vendor/golang.org/x/text/unicode/rangetable/rangetable_test.go +55 -0
  994. data/ext/vendor/golang.org/x/text/unicode/rangetable/tables.go +6376 -0
  995. data/ext/vendor/golang.org/x/text/unicode/runenames/bits.go +59 -0
  996. data/ext/vendor/golang.org/x/text/unicode/runenames/example_test.go +118 -0
  997. data/ext/vendor/golang.org/x/text/unicode/runenames/gen.go +195 -0
  998. data/ext/vendor/golang.org/x/text/unicode/runenames/gen_bits.go +63 -0
  999. data/ext/vendor/golang.org/x/text/unicode/runenames/runenames.go +48 -0
  1000. data/ext/vendor/golang.org/x/text/unicode/runenames/runenames_test.go +46 -0
  1001. data/ext/vendor/golang.org/x/text/unicode/runenames/tables.go +15514 -0
  1002. data/ext/vendor/golang.org/x/text/width/common_test.go +92 -0
  1003. data/ext/vendor/golang.org/x/text/width/example_test.go +52 -0
  1004. data/ext/vendor/golang.org/x/text/width/gen.go +115 -0
  1005. data/ext/vendor/golang.org/x/text/width/gen_common.go +96 -0
  1006. data/ext/vendor/golang.org/x/text/width/gen_trieval.go +34 -0
  1007. data/ext/vendor/golang.org/x/text/width/kind_string.go +16 -0
  1008. data/ext/vendor/golang.org/x/text/width/runes_test.go +461 -0
  1009. data/ext/vendor/golang.org/x/text/width/tables.go +1316 -0
  1010. data/ext/vendor/golang.org/x/text/width/tables_test.go +59 -0
  1011. data/ext/vendor/golang.org/x/text/width/transform.go +239 -0
  1012. data/ext/vendor/golang.org/x/text/width/transform_test.go +701 -0
  1013. data/ext/vendor/golang.org/x/text/width/trieval.go +30 -0
  1014. data/ext/vendor/golang.org/x/text/width/width.go +206 -0
  1015. data/lib/ires/version.rb +1 -1
  1016. data/shared/darwin/ires.so +0 -0
  1017. data/shared/linux/ires.so +0 -0
  1018. metadata +1011 -23
  1019. data/ext/operate/image.go +0 -176
  1020. data/ext/util/uri/uri.go +0 -105
  1021. data/ext/vendor/github.com/satori/go.uuid/README.md +0 -65
  1022. data/ext/vendor/github.com/satori/go.uuid/benchmarks_test.go +0 -121
  1023. data/ext/vendor/github.com/satori/go.uuid/uuid.go +0 -488
  1024. data/ext/vendor/github.com/satori/go.uuid/uuid_test.go +0 -633
@@ -0,0 +1,193 @@
1
+ // Copyright 2011 The Go Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package html
6
+
7
+ import (
8
+ "golang.org/x/net/html/atom"
9
+ )
10
+
11
+ // A NodeType is the type of a Node.
12
+ type NodeType uint32
13
+
14
+ const (
15
+ ErrorNode NodeType = iota
16
+ TextNode
17
+ DocumentNode
18
+ ElementNode
19
+ CommentNode
20
+ DoctypeNode
21
+ scopeMarkerNode
22
+ )
23
+
24
+ // Section 12.2.3.3 says "scope markers are inserted when entering applet
25
+ // elements, buttons, object elements, marquees, table cells, and table
26
+ // captions, and are used to prevent formatting from 'leaking'".
27
+ var scopeMarker = Node{Type: scopeMarkerNode}
28
+
29
+ // A Node consists of a NodeType and some Data (tag name for element nodes,
30
+ // content for text) and are part of a tree of Nodes. Element nodes may also
31
+ // have a Namespace and contain a slice of Attributes. Data is unescaped, so
32
+ // that it looks like "a<b" rather than "a&lt;b". For element nodes, DataAtom
33
+ // is the atom for Data, or zero if Data is not a known tag name.
34
+ //
35
+ // An empty Namespace implies a "http://www.w3.org/1999/xhtml" namespace.
36
+ // Similarly, "math" is short for "http://www.w3.org/1998/Math/MathML", and
37
+ // "svg" is short for "http://www.w3.org/2000/svg".
38
+ type Node struct {
39
+ Parent, FirstChild, LastChild, PrevSibling, NextSibling *Node
40
+
41
+ Type NodeType
42
+ DataAtom atom.Atom
43
+ Data string
44
+ Namespace string
45
+ Attr []Attribute
46
+ }
47
+
48
+ // InsertBefore inserts newChild as a child of n, immediately before oldChild
49
+ // in the sequence of n's children. oldChild may be nil, in which case newChild
50
+ // is appended to the end of n's children.
51
+ //
52
+ // It will panic if newChild already has a parent or siblings.
53
+ func (n *Node) InsertBefore(newChild, oldChild *Node) {
54
+ if newChild.Parent != nil || newChild.PrevSibling != nil || newChild.NextSibling != nil {
55
+ panic("html: InsertBefore called for an attached child Node")
56
+ }
57
+ var prev, next *Node
58
+ if oldChild != nil {
59
+ prev, next = oldChild.PrevSibling, oldChild
60
+ } else {
61
+ prev = n.LastChild
62
+ }
63
+ if prev != nil {
64
+ prev.NextSibling = newChild
65
+ } else {
66
+ n.FirstChild = newChild
67
+ }
68
+ if next != nil {
69
+ next.PrevSibling = newChild
70
+ } else {
71
+ n.LastChild = newChild
72
+ }
73
+ newChild.Parent = n
74
+ newChild.PrevSibling = prev
75
+ newChild.NextSibling = next
76
+ }
77
+
78
+ // AppendChild adds a node c as a child of n.
79
+ //
80
+ // It will panic if c already has a parent or siblings.
81
+ func (n *Node) AppendChild(c *Node) {
82
+ if c.Parent != nil || c.PrevSibling != nil || c.NextSibling != nil {
83
+ panic("html: AppendChild called for an attached child Node")
84
+ }
85
+ last := n.LastChild
86
+ if last != nil {
87
+ last.NextSibling = c
88
+ } else {
89
+ n.FirstChild = c
90
+ }
91
+ n.LastChild = c
92
+ c.Parent = n
93
+ c.PrevSibling = last
94
+ }
95
+
96
+ // RemoveChild removes a node c that is a child of n. Afterwards, c will have
97
+ // no parent and no siblings.
98
+ //
99
+ // It will panic if c's parent is not n.
100
+ func (n *Node) RemoveChild(c *Node) {
101
+ if c.Parent != n {
102
+ panic("html: RemoveChild called for a non-child Node")
103
+ }
104
+ if n.FirstChild == c {
105
+ n.FirstChild = c.NextSibling
106
+ }
107
+ if c.NextSibling != nil {
108
+ c.NextSibling.PrevSibling = c.PrevSibling
109
+ }
110
+ if n.LastChild == c {
111
+ n.LastChild = c.PrevSibling
112
+ }
113
+ if c.PrevSibling != nil {
114
+ c.PrevSibling.NextSibling = c.NextSibling
115
+ }
116
+ c.Parent = nil
117
+ c.PrevSibling = nil
118
+ c.NextSibling = nil
119
+ }
120
+
121
+ // reparentChildren reparents all of src's child nodes to dst.
122
+ func reparentChildren(dst, src *Node) {
123
+ for {
124
+ child := src.FirstChild
125
+ if child == nil {
126
+ break
127
+ }
128
+ src.RemoveChild(child)
129
+ dst.AppendChild(child)
130
+ }
131
+ }
132
+
133
+ // clone returns a new node with the same type, data and attributes.
134
+ // The clone has no parent, no siblings and no children.
135
+ func (n *Node) clone() *Node {
136
+ m := &Node{
137
+ Type: n.Type,
138
+ DataAtom: n.DataAtom,
139
+ Data: n.Data,
140
+ Attr: make([]Attribute, len(n.Attr)),
141
+ }
142
+ copy(m.Attr, n.Attr)
143
+ return m
144
+ }
145
+
146
+ // nodeStack is a stack of nodes.
147
+ type nodeStack []*Node
148
+
149
+ // pop pops the stack. It will panic if s is empty.
150
+ func (s *nodeStack) pop() *Node {
151
+ i := len(*s)
152
+ n := (*s)[i-1]
153
+ *s = (*s)[:i-1]
154
+ return n
155
+ }
156
+
157
+ // top returns the most recently pushed node, or nil if s is empty.
158
+ func (s *nodeStack) top() *Node {
159
+ if i := len(*s); i > 0 {
160
+ return (*s)[i-1]
161
+ }
162
+ return nil
163
+ }
164
+
165
+ // index returns the index of the top-most occurrence of n in the stack, or -1
166
+ // if n is not present.
167
+ func (s *nodeStack) index(n *Node) int {
168
+ for i := len(*s) - 1; i >= 0; i-- {
169
+ if (*s)[i] == n {
170
+ return i
171
+ }
172
+ }
173
+ return -1
174
+ }
175
+
176
+ // insert inserts a node at the given index.
177
+ func (s *nodeStack) insert(i int, n *Node) {
178
+ (*s) = append(*s, nil)
179
+ copy((*s)[i+1:], (*s)[i:])
180
+ (*s)[i] = n
181
+ }
182
+
183
+ // remove removes a node from the stack. It is a no-op if n is not present.
184
+ func (s *nodeStack) remove(n *Node) {
185
+ i := s.index(n)
186
+ if i == -1 {
187
+ return
188
+ }
189
+ copy((*s)[i:], (*s)[i+1:])
190
+ j := len(*s) - 1
191
+ (*s)[j] = nil
192
+ *s = (*s)[:j]
193
+ }
@@ -0,0 +1,146 @@
1
+ // Copyright 2010 The Go Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package html
6
+
7
+ import (
8
+ "fmt"
9
+ )
10
+
11
+ // checkTreeConsistency checks that a node and its descendants are all
12
+ // consistent in their parent/child/sibling relationships.
13
+ func checkTreeConsistency(n *Node) error {
14
+ return checkTreeConsistency1(n, 0)
15
+ }
16
+
17
+ func checkTreeConsistency1(n *Node, depth int) error {
18
+ if depth == 1e4 {
19
+ return fmt.Errorf("html: tree looks like it contains a cycle")
20
+ }
21
+ if err := checkNodeConsistency(n); err != nil {
22
+ return err
23
+ }
24
+ for c := n.FirstChild; c != nil; c = c.NextSibling {
25
+ if err := checkTreeConsistency1(c, depth+1); err != nil {
26
+ return err
27
+ }
28
+ }
29
+ return nil
30
+ }
31
+
32
+ // checkNodeConsistency checks that a node's parent/child/sibling relationships
33
+ // are consistent.
34
+ func checkNodeConsistency(n *Node) error {
35
+ if n == nil {
36
+ return nil
37
+ }
38
+
39
+ nParent := 0
40
+ for p := n.Parent; p != nil; p = p.Parent {
41
+ nParent++
42
+ if nParent == 1e4 {
43
+ return fmt.Errorf("html: parent list looks like an infinite loop")
44
+ }
45
+ }
46
+
47
+ nForward := 0
48
+ for c := n.FirstChild; c != nil; c = c.NextSibling {
49
+ nForward++
50
+ if nForward == 1e6 {
51
+ return fmt.Errorf("html: forward list of children looks like an infinite loop")
52
+ }
53
+ if c.Parent != n {
54
+ return fmt.Errorf("html: inconsistent child/parent relationship")
55
+ }
56
+ }
57
+
58
+ nBackward := 0
59
+ for c := n.LastChild; c != nil; c = c.PrevSibling {
60
+ nBackward++
61
+ if nBackward == 1e6 {
62
+ return fmt.Errorf("html: backward list of children looks like an infinite loop")
63
+ }
64
+ if c.Parent != n {
65
+ return fmt.Errorf("html: inconsistent child/parent relationship")
66
+ }
67
+ }
68
+
69
+ if n.Parent != nil {
70
+ if n.Parent == n {
71
+ return fmt.Errorf("html: inconsistent parent relationship")
72
+ }
73
+ if n.Parent == n.FirstChild {
74
+ return fmt.Errorf("html: inconsistent parent/first relationship")
75
+ }
76
+ if n.Parent == n.LastChild {
77
+ return fmt.Errorf("html: inconsistent parent/last relationship")
78
+ }
79
+ if n.Parent == n.PrevSibling {
80
+ return fmt.Errorf("html: inconsistent parent/prev relationship")
81
+ }
82
+ if n.Parent == n.NextSibling {
83
+ return fmt.Errorf("html: inconsistent parent/next relationship")
84
+ }
85
+
86
+ parentHasNAsAChild := false
87
+ for c := n.Parent.FirstChild; c != nil; c = c.NextSibling {
88
+ if c == n {
89
+ parentHasNAsAChild = true
90
+ break
91
+ }
92
+ }
93
+ if !parentHasNAsAChild {
94
+ return fmt.Errorf("html: inconsistent parent/child relationship")
95
+ }
96
+ }
97
+
98
+ if n.PrevSibling != nil && n.PrevSibling.NextSibling != n {
99
+ return fmt.Errorf("html: inconsistent prev/next relationship")
100
+ }
101
+ if n.NextSibling != nil && n.NextSibling.PrevSibling != n {
102
+ return fmt.Errorf("html: inconsistent next/prev relationship")
103
+ }
104
+
105
+ if (n.FirstChild == nil) != (n.LastChild == nil) {
106
+ return fmt.Errorf("html: inconsistent first/last relationship")
107
+ }
108
+ if n.FirstChild != nil && n.FirstChild == n.LastChild {
109
+ // We have a sole child.
110
+ if n.FirstChild.PrevSibling != nil || n.FirstChild.NextSibling != nil {
111
+ return fmt.Errorf("html: inconsistent sole child's sibling relationship")
112
+ }
113
+ }
114
+
115
+ seen := map[*Node]bool{}
116
+
117
+ var last *Node
118
+ for c := n.FirstChild; c != nil; c = c.NextSibling {
119
+ if seen[c] {
120
+ return fmt.Errorf("html: inconsistent repeated child")
121
+ }
122
+ seen[c] = true
123
+ last = c
124
+ }
125
+ if last != n.LastChild {
126
+ return fmt.Errorf("html: inconsistent last relationship")
127
+ }
128
+
129
+ var first *Node
130
+ for c := n.LastChild; c != nil; c = c.PrevSibling {
131
+ if !seen[c] {
132
+ return fmt.Errorf("html: inconsistent missing child")
133
+ }
134
+ delete(seen, c)
135
+ first = c
136
+ }
137
+ if first != n.FirstChild {
138
+ return fmt.Errorf("html: inconsistent first relationship")
139
+ }
140
+
141
+ if len(seen) != 0 {
142
+ return fmt.Errorf("html: inconsistent forwards/backwards child list")
143
+ }
144
+
145
+ return nil
146
+ }
@@ -0,0 +1,2094 @@
1
+ // Copyright 2010 The Go Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package html
6
+
7
+ import (
8
+ "errors"
9
+ "fmt"
10
+ "io"
11
+ "strings"
12
+
13
+ a "golang.org/x/net/html/atom"
14
+ )
15
+
16
+ // A parser implements the HTML5 parsing algorithm:
17
+ // https://html.spec.whatwg.org/multipage/syntax.html#tree-construction
18
+ type parser struct {
19
+ // tokenizer provides the tokens for the parser.
20
+ tokenizer *Tokenizer
21
+ // tok is the most recently read token.
22
+ tok Token
23
+ // Self-closing tags like <hr/> are treated as start tags, except that
24
+ // hasSelfClosingToken is set while they are being processed.
25
+ hasSelfClosingToken bool
26
+ // doc is the document root element.
27
+ doc *Node
28
+ // The stack of open elements (section 12.2.3.2) and active formatting
29
+ // elements (section 12.2.3.3).
30
+ oe, afe nodeStack
31
+ // Element pointers (section 12.2.3.4).
32
+ head, form *Node
33
+ // Other parsing state flags (section 12.2.3.5).
34
+ scripting, framesetOK bool
35
+ // im is the current insertion mode.
36
+ im insertionMode
37
+ // originalIM is the insertion mode to go back to after completing a text
38
+ // or inTableText insertion mode.
39
+ originalIM insertionMode
40
+ // fosterParenting is whether new elements should be inserted according to
41
+ // the foster parenting rules (section 12.2.5.3).
42
+ fosterParenting bool
43
+ // quirks is whether the parser is operating in "quirks mode."
44
+ quirks bool
45
+ // fragment is whether the parser is parsing an HTML fragment.
46
+ fragment bool
47
+ // context is the context element when parsing an HTML fragment
48
+ // (section 12.4).
49
+ context *Node
50
+ }
51
+
52
+ func (p *parser) top() *Node {
53
+ if n := p.oe.top(); n != nil {
54
+ return n
55
+ }
56
+ return p.doc
57
+ }
58
+
59
+ // Stop tags for use in popUntil. These come from section 12.2.3.2.
60
+ var (
61
+ defaultScopeStopTags = map[string][]a.Atom{
62
+ "": {a.Applet, a.Caption, a.Html, a.Table, a.Td, a.Th, a.Marquee, a.Object, a.Template},
63
+ "math": {a.AnnotationXml, a.Mi, a.Mn, a.Mo, a.Ms, a.Mtext},
64
+ "svg": {a.Desc, a.ForeignObject, a.Title},
65
+ }
66
+ )
67
+
68
+ type scope int
69
+
70
+ const (
71
+ defaultScope scope = iota
72
+ listItemScope
73
+ buttonScope
74
+ tableScope
75
+ tableRowScope
76
+ tableBodyScope
77
+ selectScope
78
+ )
79
+
80
+ // popUntil pops the stack of open elements at the highest element whose tag
81
+ // is in matchTags, provided there is no higher element in the scope's stop
82
+ // tags (as defined in section 12.2.3.2). It returns whether or not there was
83
+ // such an element. If there was not, popUntil leaves the stack unchanged.
84
+ //
85
+ // For example, the set of stop tags for table scope is: "html", "table". If
86
+ // the stack was:
87
+ // ["html", "body", "font", "table", "b", "i", "u"]
88
+ // then popUntil(tableScope, "font") would return false, but
89
+ // popUntil(tableScope, "i") would return true and the stack would become:
90
+ // ["html", "body", "font", "table", "b"]
91
+ //
92
+ // If an element's tag is in both the stop tags and matchTags, then the stack
93
+ // will be popped and the function returns true (provided, of course, there was
94
+ // no higher element in the stack that was also in the stop tags). For example,
95
+ // popUntil(tableScope, "table") returns true and leaves:
96
+ // ["html", "body", "font"]
97
+ func (p *parser) popUntil(s scope, matchTags ...a.Atom) bool {
98
+ if i := p.indexOfElementInScope(s, matchTags...); i != -1 {
99
+ p.oe = p.oe[:i]
100
+ return true
101
+ }
102
+ return false
103
+ }
104
+
105
+ // indexOfElementInScope returns the index in p.oe of the highest element whose
106
+ // tag is in matchTags that is in scope. If no matching element is in scope, it
107
+ // returns -1.
108
+ func (p *parser) indexOfElementInScope(s scope, matchTags ...a.Atom) int {
109
+ for i := len(p.oe) - 1; i >= 0; i-- {
110
+ tagAtom := p.oe[i].DataAtom
111
+ if p.oe[i].Namespace == "" {
112
+ for _, t := range matchTags {
113
+ if t == tagAtom {
114
+ return i
115
+ }
116
+ }
117
+ switch s {
118
+ case defaultScope:
119
+ // No-op.
120
+ case listItemScope:
121
+ if tagAtom == a.Ol || tagAtom == a.Ul {
122
+ return -1
123
+ }
124
+ case buttonScope:
125
+ if tagAtom == a.Button {
126
+ return -1
127
+ }
128
+ case tableScope:
129
+ if tagAtom == a.Html || tagAtom == a.Table {
130
+ return -1
131
+ }
132
+ case selectScope:
133
+ if tagAtom != a.Optgroup && tagAtom != a.Option {
134
+ return -1
135
+ }
136
+ default:
137
+ panic("unreachable")
138
+ }
139
+ }
140
+ switch s {
141
+ case defaultScope, listItemScope, buttonScope:
142
+ for _, t := range defaultScopeStopTags[p.oe[i].Namespace] {
143
+ if t == tagAtom {
144
+ return -1
145
+ }
146
+ }
147
+ }
148
+ }
149
+ return -1
150
+ }
151
+
152
+ // elementInScope is like popUntil, except that it doesn't modify the stack of
153
+ // open elements.
154
+ func (p *parser) elementInScope(s scope, matchTags ...a.Atom) bool {
155
+ return p.indexOfElementInScope(s, matchTags...) != -1
156
+ }
157
+
158
+ // clearStackToContext pops elements off the stack of open elements until a
159
+ // scope-defined element is found.
160
+ func (p *parser) clearStackToContext(s scope) {
161
+ for i := len(p.oe) - 1; i >= 0; i-- {
162
+ tagAtom := p.oe[i].DataAtom
163
+ switch s {
164
+ case tableScope:
165
+ if tagAtom == a.Html || tagAtom == a.Table {
166
+ p.oe = p.oe[:i+1]
167
+ return
168
+ }
169
+ case tableRowScope:
170
+ if tagAtom == a.Html || tagAtom == a.Tr {
171
+ p.oe = p.oe[:i+1]
172
+ return
173
+ }
174
+ case tableBodyScope:
175
+ if tagAtom == a.Html || tagAtom == a.Tbody || tagAtom == a.Tfoot || tagAtom == a.Thead {
176
+ p.oe = p.oe[:i+1]
177
+ return
178
+ }
179
+ default:
180
+ panic("unreachable")
181
+ }
182
+ }
183
+ }
184
+
185
+ // generateImpliedEndTags pops nodes off the stack of open elements as long as
186
+ // the top node has a tag name of dd, dt, li, option, optgroup, p, rp, or rt.
187
+ // If exceptions are specified, nodes with that name will not be popped off.
188
+ func (p *parser) generateImpliedEndTags(exceptions ...string) {
189
+ var i int
190
+ loop:
191
+ for i = len(p.oe) - 1; i >= 0; i-- {
192
+ n := p.oe[i]
193
+ if n.Type == ElementNode {
194
+ switch n.DataAtom {
195
+ case a.Dd, a.Dt, a.Li, a.Option, a.Optgroup, a.P, a.Rp, a.Rt:
196
+ for _, except := range exceptions {
197
+ if n.Data == except {
198
+ break loop
199
+ }
200
+ }
201
+ continue
202
+ }
203
+ }
204
+ break
205
+ }
206
+
207
+ p.oe = p.oe[:i+1]
208
+ }
209
+
210
+ // addChild adds a child node n to the top element, and pushes n onto the stack
211
+ // of open elements if it is an element node.
212
+ func (p *parser) addChild(n *Node) {
213
+ if p.shouldFosterParent() {
214
+ p.fosterParent(n)
215
+ } else {
216
+ p.top().AppendChild(n)
217
+ }
218
+
219
+ if n.Type == ElementNode {
220
+ p.oe = append(p.oe, n)
221
+ }
222
+ }
223
+
224
+ // shouldFosterParent returns whether the next node to be added should be
225
+ // foster parented.
226
+ func (p *parser) shouldFosterParent() bool {
227
+ if p.fosterParenting {
228
+ switch p.top().DataAtom {
229
+ case a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr:
230
+ return true
231
+ }
232
+ }
233
+ return false
234
+ }
235
+
236
+ // fosterParent adds a child node according to the foster parenting rules.
237
+ // Section 12.2.5.3, "foster parenting".
238
+ func (p *parser) fosterParent(n *Node) {
239
+ var table, parent, prev *Node
240
+ var i int
241
+ for i = len(p.oe) - 1; i >= 0; i-- {
242
+ if p.oe[i].DataAtom == a.Table {
243
+ table = p.oe[i]
244
+ break
245
+ }
246
+ }
247
+
248
+ if table == nil {
249
+ // The foster parent is the html element.
250
+ parent = p.oe[0]
251
+ } else {
252
+ parent = table.Parent
253
+ }
254
+ if parent == nil {
255
+ parent = p.oe[i-1]
256
+ }
257
+
258
+ if table != nil {
259
+ prev = table.PrevSibling
260
+ } else {
261
+ prev = parent.LastChild
262
+ }
263
+ if prev != nil && prev.Type == TextNode && n.Type == TextNode {
264
+ prev.Data += n.Data
265
+ return
266
+ }
267
+
268
+ parent.InsertBefore(n, table)
269
+ }
270
+
271
+ // addText adds text to the preceding node if it is a text node, or else it
272
+ // calls addChild with a new text node.
273
+ func (p *parser) addText(text string) {
274
+ if text == "" {
275
+ return
276
+ }
277
+
278
+ if p.shouldFosterParent() {
279
+ p.fosterParent(&Node{
280
+ Type: TextNode,
281
+ Data: text,
282
+ })
283
+ return
284
+ }
285
+
286
+ t := p.top()
287
+ if n := t.LastChild; n != nil && n.Type == TextNode {
288
+ n.Data += text
289
+ return
290
+ }
291
+ p.addChild(&Node{
292
+ Type: TextNode,
293
+ Data: text,
294
+ })
295
+ }
296
+
297
+ // addElement adds a child element based on the current token.
298
+ func (p *parser) addElement() {
299
+ p.addChild(&Node{
300
+ Type: ElementNode,
301
+ DataAtom: p.tok.DataAtom,
302
+ Data: p.tok.Data,
303
+ Attr: p.tok.Attr,
304
+ })
305
+ }
306
+
307
+ // Section 12.2.3.3.
308
+ func (p *parser) addFormattingElement() {
309
+ tagAtom, attr := p.tok.DataAtom, p.tok.Attr
310
+ p.addElement()
311
+
312
+ // Implement the Noah's Ark clause, but with three per family instead of two.
313
+ identicalElements := 0
314
+ findIdenticalElements:
315
+ for i := len(p.afe) - 1; i >= 0; i-- {
316
+ n := p.afe[i]
317
+ if n.Type == scopeMarkerNode {
318
+ break
319
+ }
320
+ if n.Type != ElementNode {
321
+ continue
322
+ }
323
+ if n.Namespace != "" {
324
+ continue
325
+ }
326
+ if n.DataAtom != tagAtom {
327
+ continue
328
+ }
329
+ if len(n.Attr) != len(attr) {
330
+ continue
331
+ }
332
+ compareAttributes:
333
+ for _, t0 := range n.Attr {
334
+ for _, t1 := range attr {
335
+ if t0.Key == t1.Key && t0.Namespace == t1.Namespace && t0.Val == t1.Val {
336
+ // Found a match for this attribute, continue with the next attribute.
337
+ continue compareAttributes
338
+ }
339
+ }
340
+ // If we get here, there is no attribute that matches a.
341
+ // Therefore the element is not identical to the new one.
342
+ continue findIdenticalElements
343
+ }
344
+
345
+ identicalElements++
346
+ if identicalElements >= 3 {
347
+ p.afe.remove(n)
348
+ }
349
+ }
350
+
351
+ p.afe = append(p.afe, p.top())
352
+ }
353
+
354
+ // Section 12.2.3.3.
355
+ func (p *parser) clearActiveFormattingElements() {
356
+ for {
357
+ n := p.afe.pop()
358
+ if len(p.afe) == 0 || n.Type == scopeMarkerNode {
359
+ return
360
+ }
361
+ }
362
+ }
363
+
364
+ // Section 12.2.3.3.
365
+ func (p *parser) reconstructActiveFormattingElements() {
366
+ n := p.afe.top()
367
+ if n == nil {
368
+ return
369
+ }
370
+ if n.Type == scopeMarkerNode || p.oe.index(n) != -1 {
371
+ return
372
+ }
373
+ i := len(p.afe) - 1
374
+ for n.Type != scopeMarkerNode && p.oe.index(n) == -1 {
375
+ if i == 0 {
376
+ i = -1
377
+ break
378
+ }
379
+ i--
380
+ n = p.afe[i]
381
+ }
382
+ for {
383
+ i++
384
+ clone := p.afe[i].clone()
385
+ p.addChild(clone)
386
+ p.afe[i] = clone
387
+ if i == len(p.afe)-1 {
388
+ break
389
+ }
390
+ }
391
+ }
392
+
393
+ // Section 12.2.4.
394
+ func (p *parser) acknowledgeSelfClosingTag() {
395
+ p.hasSelfClosingToken = false
396
+ }
397
+
398
+ // An insertion mode (section 12.2.3.1) is the state transition function from
399
+ // a particular state in the HTML5 parser's state machine. It updates the
400
+ // parser's fields depending on parser.tok (where ErrorToken means EOF).
401
+ // It returns whether the token was consumed.
402
+ type insertionMode func(*parser) bool
403
+
404
+ // setOriginalIM sets the insertion mode to return to after completing a text or
405
+ // inTableText insertion mode.
406
+ // Section 12.2.3.1, "using the rules for".
407
+ func (p *parser) setOriginalIM() {
408
+ if p.originalIM != nil {
409
+ panic("html: bad parser state: originalIM was set twice")
410
+ }
411
+ p.originalIM = p.im
412
+ }
413
+
414
+ // Section 12.2.3.1, "reset the insertion mode".
415
+ func (p *parser) resetInsertionMode() {
416
+ for i := len(p.oe) - 1; i >= 0; i-- {
417
+ n := p.oe[i]
418
+ if i == 0 && p.context != nil {
419
+ n = p.context
420
+ }
421
+
422
+ switch n.DataAtom {
423
+ case a.Select:
424
+ p.im = inSelectIM
425
+ case a.Td, a.Th:
426
+ p.im = inCellIM
427
+ case a.Tr:
428
+ p.im = inRowIM
429
+ case a.Tbody, a.Thead, a.Tfoot:
430
+ p.im = inTableBodyIM
431
+ case a.Caption:
432
+ p.im = inCaptionIM
433
+ case a.Colgroup:
434
+ p.im = inColumnGroupIM
435
+ case a.Table:
436
+ p.im = inTableIM
437
+ case a.Head:
438
+ p.im = inBodyIM
439
+ case a.Body:
440
+ p.im = inBodyIM
441
+ case a.Frameset:
442
+ p.im = inFramesetIM
443
+ case a.Html:
444
+ p.im = beforeHeadIM
445
+ default:
446
+ continue
447
+ }
448
+ return
449
+ }
450
+ p.im = inBodyIM
451
+ }
452
+
453
+ const whitespace = " \t\r\n\f"
454
+
455
+ // Section 12.2.5.4.1.
456
+ func initialIM(p *parser) bool {
457
+ switch p.tok.Type {
458
+ case TextToken:
459
+ p.tok.Data = strings.TrimLeft(p.tok.Data, whitespace)
460
+ if len(p.tok.Data) == 0 {
461
+ // It was all whitespace, so ignore it.
462
+ return true
463
+ }
464
+ case CommentToken:
465
+ p.doc.AppendChild(&Node{
466
+ Type: CommentNode,
467
+ Data: p.tok.Data,
468
+ })
469
+ return true
470
+ case DoctypeToken:
471
+ n, quirks := parseDoctype(p.tok.Data)
472
+ p.doc.AppendChild(n)
473
+ p.quirks = quirks
474
+ p.im = beforeHTMLIM
475
+ return true
476
+ }
477
+ p.quirks = true
478
+ p.im = beforeHTMLIM
479
+ return false
480
+ }
481
+
482
+ // Section 12.2.5.4.2.
483
+ func beforeHTMLIM(p *parser) bool {
484
+ switch p.tok.Type {
485
+ case DoctypeToken:
486
+ // Ignore the token.
487
+ return true
488
+ case TextToken:
489
+ p.tok.Data = strings.TrimLeft(p.tok.Data, whitespace)
490
+ if len(p.tok.Data) == 0 {
491
+ // It was all whitespace, so ignore it.
492
+ return true
493
+ }
494
+ case StartTagToken:
495
+ if p.tok.DataAtom == a.Html {
496
+ p.addElement()
497
+ p.im = beforeHeadIM
498
+ return true
499
+ }
500
+ case EndTagToken:
501
+ switch p.tok.DataAtom {
502
+ case a.Head, a.Body, a.Html, a.Br:
503
+ p.parseImpliedToken(StartTagToken, a.Html, a.Html.String())
504
+ return false
505
+ default:
506
+ // Ignore the token.
507
+ return true
508
+ }
509
+ case CommentToken:
510
+ p.doc.AppendChild(&Node{
511
+ Type: CommentNode,
512
+ Data: p.tok.Data,
513
+ })
514
+ return true
515
+ }
516
+ p.parseImpliedToken(StartTagToken, a.Html, a.Html.String())
517
+ return false
518
+ }
519
+
520
+ // Section 12.2.5.4.3.
521
+ func beforeHeadIM(p *parser) bool {
522
+ switch p.tok.Type {
523
+ case TextToken:
524
+ p.tok.Data = strings.TrimLeft(p.tok.Data, whitespace)
525
+ if len(p.tok.Data) == 0 {
526
+ // It was all whitespace, so ignore it.
527
+ return true
528
+ }
529
+ case StartTagToken:
530
+ switch p.tok.DataAtom {
531
+ case a.Head:
532
+ p.addElement()
533
+ p.head = p.top()
534
+ p.im = inHeadIM
535
+ return true
536
+ case a.Html:
537
+ return inBodyIM(p)
538
+ }
539
+ case EndTagToken:
540
+ switch p.tok.DataAtom {
541
+ case a.Head, a.Body, a.Html, a.Br:
542
+ p.parseImpliedToken(StartTagToken, a.Head, a.Head.String())
543
+ return false
544
+ default:
545
+ // Ignore the token.
546
+ return true
547
+ }
548
+ case CommentToken:
549
+ p.addChild(&Node{
550
+ Type: CommentNode,
551
+ Data: p.tok.Data,
552
+ })
553
+ return true
554
+ case DoctypeToken:
555
+ // Ignore the token.
556
+ return true
557
+ }
558
+
559
+ p.parseImpliedToken(StartTagToken, a.Head, a.Head.String())
560
+ return false
561
+ }
562
+
563
+ // Section 12.2.5.4.4.
564
+ func inHeadIM(p *parser) bool {
565
+ switch p.tok.Type {
566
+ case TextToken:
567
+ s := strings.TrimLeft(p.tok.Data, whitespace)
568
+ if len(s) < len(p.tok.Data) {
569
+ // Add the initial whitespace to the current node.
570
+ p.addText(p.tok.Data[:len(p.tok.Data)-len(s)])
571
+ if s == "" {
572
+ return true
573
+ }
574
+ p.tok.Data = s
575
+ }
576
+ case StartTagToken:
577
+ switch p.tok.DataAtom {
578
+ case a.Html:
579
+ return inBodyIM(p)
580
+ case a.Base, a.Basefont, a.Bgsound, a.Command, a.Link, a.Meta:
581
+ p.addElement()
582
+ p.oe.pop()
583
+ p.acknowledgeSelfClosingTag()
584
+ return true
585
+ case a.Script, a.Title, a.Noscript, a.Noframes, a.Style:
586
+ p.addElement()
587
+ p.setOriginalIM()
588
+ p.im = textIM
589
+ return true
590
+ case a.Head:
591
+ // Ignore the token.
592
+ return true
593
+ }
594
+ case EndTagToken:
595
+ switch p.tok.DataAtom {
596
+ case a.Head:
597
+ n := p.oe.pop()
598
+ if n.DataAtom != a.Head {
599
+ panic("html: bad parser state: <head> element not found, in the in-head insertion mode")
600
+ }
601
+ p.im = afterHeadIM
602
+ return true
603
+ case a.Body, a.Html, a.Br:
604
+ p.parseImpliedToken(EndTagToken, a.Head, a.Head.String())
605
+ return false
606
+ default:
607
+ // Ignore the token.
608
+ return true
609
+ }
610
+ case CommentToken:
611
+ p.addChild(&Node{
612
+ Type: CommentNode,
613
+ Data: p.tok.Data,
614
+ })
615
+ return true
616
+ case DoctypeToken:
617
+ // Ignore the token.
618
+ return true
619
+ }
620
+
621
+ p.parseImpliedToken(EndTagToken, a.Head, a.Head.String())
622
+ return false
623
+ }
624
+
625
+ // Section 12.2.5.4.6.
626
+ func afterHeadIM(p *parser) bool {
627
+ switch p.tok.Type {
628
+ case TextToken:
629
+ s := strings.TrimLeft(p.tok.Data, whitespace)
630
+ if len(s) < len(p.tok.Data) {
631
+ // Add the initial whitespace to the current node.
632
+ p.addText(p.tok.Data[:len(p.tok.Data)-len(s)])
633
+ if s == "" {
634
+ return true
635
+ }
636
+ p.tok.Data = s
637
+ }
638
+ case StartTagToken:
639
+ switch p.tok.DataAtom {
640
+ case a.Html:
641
+ return inBodyIM(p)
642
+ case a.Body:
643
+ p.addElement()
644
+ p.framesetOK = false
645
+ p.im = inBodyIM
646
+ return true
647
+ case a.Frameset:
648
+ p.addElement()
649
+ p.im = inFramesetIM
650
+ return true
651
+ case a.Base, a.Basefont, a.Bgsound, a.Link, a.Meta, a.Noframes, a.Script, a.Style, a.Title:
652
+ p.oe = append(p.oe, p.head)
653
+ defer p.oe.remove(p.head)
654
+ return inHeadIM(p)
655
+ case a.Head:
656
+ // Ignore the token.
657
+ return true
658
+ }
659
+ case EndTagToken:
660
+ switch p.tok.DataAtom {
661
+ case a.Body, a.Html, a.Br:
662
+ // Drop down to creating an implied <body> tag.
663
+ default:
664
+ // Ignore the token.
665
+ return true
666
+ }
667
+ case CommentToken:
668
+ p.addChild(&Node{
669
+ Type: CommentNode,
670
+ Data: p.tok.Data,
671
+ })
672
+ return true
673
+ case DoctypeToken:
674
+ // Ignore the token.
675
+ return true
676
+ }
677
+
678
+ p.parseImpliedToken(StartTagToken, a.Body, a.Body.String())
679
+ p.framesetOK = true
680
+ return false
681
+ }
682
+
683
+ // copyAttributes copies attributes of src not found on dst to dst.
684
+ func copyAttributes(dst *Node, src Token) {
685
+ if len(src.Attr) == 0 {
686
+ return
687
+ }
688
+ attr := map[string]string{}
689
+ for _, t := range dst.Attr {
690
+ attr[t.Key] = t.Val
691
+ }
692
+ for _, t := range src.Attr {
693
+ if _, ok := attr[t.Key]; !ok {
694
+ dst.Attr = append(dst.Attr, t)
695
+ attr[t.Key] = t.Val
696
+ }
697
+ }
698
+ }
699
+
700
+ // Section 12.2.5.4.7.
701
+ func inBodyIM(p *parser) bool {
702
+ switch p.tok.Type {
703
+ case TextToken:
704
+ d := p.tok.Data
705
+ switch n := p.oe.top(); n.DataAtom {
706
+ case a.Pre, a.Listing:
707
+ if n.FirstChild == nil {
708
+ // Ignore a newline at the start of a <pre> block.
709
+ if d != "" && d[0] == '\r' {
710
+ d = d[1:]
711
+ }
712
+ if d != "" && d[0] == '\n' {
713
+ d = d[1:]
714
+ }
715
+ }
716
+ }
717
+ d = strings.Replace(d, "\x00", "", -1)
718
+ if d == "" {
719
+ return true
720
+ }
721
+ p.reconstructActiveFormattingElements()
722
+ p.addText(d)
723
+ if p.framesetOK && strings.TrimLeft(d, whitespace) != "" {
724
+ // There were non-whitespace characters inserted.
725
+ p.framesetOK = false
726
+ }
727
+ case StartTagToken:
728
+ switch p.tok.DataAtom {
729
+ case a.Html:
730
+ copyAttributes(p.oe[0], p.tok)
731
+ case a.Base, a.Basefont, a.Bgsound, a.Command, a.Link, a.Meta, a.Noframes, a.Script, a.Style, a.Title:
732
+ return inHeadIM(p)
733
+ case a.Body:
734
+ if len(p.oe) >= 2 {
735
+ body := p.oe[1]
736
+ if body.Type == ElementNode && body.DataAtom == a.Body {
737
+ p.framesetOK = false
738
+ copyAttributes(body, p.tok)
739
+ }
740
+ }
741
+ case a.Frameset:
742
+ if !p.framesetOK || len(p.oe) < 2 || p.oe[1].DataAtom != a.Body {
743
+ // Ignore the token.
744
+ return true
745
+ }
746
+ body := p.oe[1]
747
+ if body.Parent != nil {
748
+ body.Parent.RemoveChild(body)
749
+ }
750
+ p.oe = p.oe[:1]
751
+ p.addElement()
752
+ p.im = inFramesetIM
753
+ return true
754
+ case a.Address, a.Article, a.Aside, a.Blockquote, a.Center, a.Details, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Menu, a.Nav, a.Ol, a.P, a.Section, a.Summary, a.Ul:
755
+ p.popUntil(buttonScope, a.P)
756
+ p.addElement()
757
+ case a.H1, a.H2, a.H3, a.H4, a.H5, a.H6:
758
+ p.popUntil(buttonScope, a.P)
759
+ switch n := p.top(); n.DataAtom {
760
+ case a.H1, a.H2, a.H3, a.H4, a.H5, a.H6:
761
+ p.oe.pop()
762
+ }
763
+ p.addElement()
764
+ case a.Pre, a.Listing:
765
+ p.popUntil(buttonScope, a.P)
766
+ p.addElement()
767
+ // The newline, if any, will be dealt with by the TextToken case.
768
+ p.framesetOK = false
769
+ case a.Form:
770
+ if p.form == nil {
771
+ p.popUntil(buttonScope, a.P)
772
+ p.addElement()
773
+ p.form = p.top()
774
+ }
775
+ case a.Li:
776
+ p.framesetOK = false
777
+ for i := len(p.oe) - 1; i >= 0; i-- {
778
+ node := p.oe[i]
779
+ switch node.DataAtom {
780
+ case a.Li:
781
+ p.oe = p.oe[:i]
782
+ case a.Address, a.Div, a.P:
783
+ continue
784
+ default:
785
+ if !isSpecialElement(node) {
786
+ continue
787
+ }
788
+ }
789
+ break
790
+ }
791
+ p.popUntil(buttonScope, a.P)
792
+ p.addElement()
793
+ case a.Dd, a.Dt:
794
+ p.framesetOK = false
795
+ for i := len(p.oe) - 1; i >= 0; i-- {
796
+ node := p.oe[i]
797
+ switch node.DataAtom {
798
+ case a.Dd, a.Dt:
799
+ p.oe = p.oe[:i]
800
+ case a.Address, a.Div, a.P:
801
+ continue
802
+ default:
803
+ if !isSpecialElement(node) {
804
+ continue
805
+ }
806
+ }
807
+ break
808
+ }
809
+ p.popUntil(buttonScope, a.P)
810
+ p.addElement()
811
+ case a.Plaintext:
812
+ p.popUntil(buttonScope, a.P)
813
+ p.addElement()
814
+ case a.Button:
815
+ p.popUntil(defaultScope, a.Button)
816
+ p.reconstructActiveFormattingElements()
817
+ p.addElement()
818
+ p.framesetOK = false
819
+ case a.A:
820
+ for i := len(p.afe) - 1; i >= 0 && p.afe[i].Type != scopeMarkerNode; i-- {
821
+ if n := p.afe[i]; n.Type == ElementNode && n.DataAtom == a.A {
822
+ p.inBodyEndTagFormatting(a.A)
823
+ p.oe.remove(n)
824
+ p.afe.remove(n)
825
+ break
826
+ }
827
+ }
828
+ p.reconstructActiveFormattingElements()
829
+ p.addFormattingElement()
830
+ case a.B, a.Big, a.Code, a.Em, a.Font, a.I, a.S, a.Small, a.Strike, a.Strong, a.Tt, a.U:
831
+ p.reconstructActiveFormattingElements()
832
+ p.addFormattingElement()
833
+ case a.Nobr:
834
+ p.reconstructActiveFormattingElements()
835
+ if p.elementInScope(defaultScope, a.Nobr) {
836
+ p.inBodyEndTagFormatting(a.Nobr)
837
+ p.reconstructActiveFormattingElements()
838
+ }
839
+ p.addFormattingElement()
840
+ case a.Applet, a.Marquee, a.Object:
841
+ p.reconstructActiveFormattingElements()
842
+ p.addElement()
843
+ p.afe = append(p.afe, &scopeMarker)
844
+ p.framesetOK = false
845
+ case a.Table:
846
+ if !p.quirks {
847
+ p.popUntil(buttonScope, a.P)
848
+ }
849
+ p.addElement()
850
+ p.framesetOK = false
851
+ p.im = inTableIM
852
+ return true
853
+ case a.Area, a.Br, a.Embed, a.Img, a.Input, a.Keygen, a.Wbr:
854
+ p.reconstructActiveFormattingElements()
855
+ p.addElement()
856
+ p.oe.pop()
857
+ p.acknowledgeSelfClosingTag()
858
+ if p.tok.DataAtom == a.Input {
859
+ for _, t := range p.tok.Attr {
860
+ if t.Key == "type" {
861
+ if strings.ToLower(t.Val) == "hidden" {
862
+ // Skip setting framesetOK = false
863
+ return true
864
+ }
865
+ }
866
+ }
867
+ }
868
+ p.framesetOK = false
869
+ case a.Param, a.Source, a.Track:
870
+ p.addElement()
871
+ p.oe.pop()
872
+ p.acknowledgeSelfClosingTag()
873
+ case a.Hr:
874
+ p.popUntil(buttonScope, a.P)
875
+ p.addElement()
876
+ p.oe.pop()
877
+ p.acknowledgeSelfClosingTag()
878
+ p.framesetOK = false
879
+ case a.Image:
880
+ p.tok.DataAtom = a.Img
881
+ p.tok.Data = a.Img.String()
882
+ return false
883
+ case a.Isindex:
884
+ if p.form != nil {
885
+ // Ignore the token.
886
+ return true
887
+ }
888
+ action := ""
889
+ prompt := "This is a searchable index. Enter search keywords: "
890
+ attr := []Attribute{{Key: "name", Val: "isindex"}}
891
+ for _, t := range p.tok.Attr {
892
+ switch t.Key {
893
+ case "action":
894
+ action = t.Val
895
+ case "name":
896
+ // Ignore the attribute.
897
+ case "prompt":
898
+ prompt = t.Val
899
+ default:
900
+ attr = append(attr, t)
901
+ }
902
+ }
903
+ p.acknowledgeSelfClosingTag()
904
+ p.popUntil(buttonScope, a.P)
905
+ p.parseImpliedToken(StartTagToken, a.Form, a.Form.String())
906
+ if action != "" {
907
+ p.form.Attr = []Attribute{{Key: "action", Val: action}}
908
+ }
909
+ p.parseImpliedToken(StartTagToken, a.Hr, a.Hr.String())
910
+ p.parseImpliedToken(StartTagToken, a.Label, a.Label.String())
911
+ p.addText(prompt)
912
+ p.addChild(&Node{
913
+ Type: ElementNode,
914
+ DataAtom: a.Input,
915
+ Data: a.Input.String(),
916
+ Attr: attr,
917
+ })
918
+ p.oe.pop()
919
+ p.parseImpliedToken(EndTagToken, a.Label, a.Label.String())
920
+ p.parseImpliedToken(StartTagToken, a.Hr, a.Hr.String())
921
+ p.parseImpliedToken(EndTagToken, a.Form, a.Form.String())
922
+ case a.Textarea:
923
+ p.addElement()
924
+ p.setOriginalIM()
925
+ p.framesetOK = false
926
+ p.im = textIM
927
+ case a.Xmp:
928
+ p.popUntil(buttonScope, a.P)
929
+ p.reconstructActiveFormattingElements()
930
+ p.framesetOK = false
931
+ p.addElement()
932
+ p.setOriginalIM()
933
+ p.im = textIM
934
+ case a.Iframe:
935
+ p.framesetOK = false
936
+ p.addElement()
937
+ p.setOriginalIM()
938
+ p.im = textIM
939
+ case a.Noembed, a.Noscript:
940
+ p.addElement()
941
+ p.setOriginalIM()
942
+ p.im = textIM
943
+ case a.Select:
944
+ p.reconstructActiveFormattingElements()
945
+ p.addElement()
946
+ p.framesetOK = false
947
+ p.im = inSelectIM
948
+ return true
949
+ case a.Optgroup, a.Option:
950
+ if p.top().DataAtom == a.Option {
951
+ p.oe.pop()
952
+ }
953
+ p.reconstructActiveFormattingElements()
954
+ p.addElement()
955
+ case a.Rp, a.Rt:
956
+ if p.elementInScope(defaultScope, a.Ruby) {
957
+ p.generateImpliedEndTags()
958
+ }
959
+ p.addElement()
960
+ case a.Math, a.Svg:
961
+ p.reconstructActiveFormattingElements()
962
+ if p.tok.DataAtom == a.Math {
963
+ adjustAttributeNames(p.tok.Attr, mathMLAttributeAdjustments)
964
+ } else {
965
+ adjustAttributeNames(p.tok.Attr, svgAttributeAdjustments)
966
+ }
967
+ adjustForeignAttributes(p.tok.Attr)
968
+ p.addElement()
969
+ p.top().Namespace = p.tok.Data
970
+ if p.hasSelfClosingToken {
971
+ p.oe.pop()
972
+ p.acknowledgeSelfClosingTag()
973
+ }
974
+ return true
975
+ case a.Caption, a.Col, a.Colgroup, a.Frame, a.Head, a.Tbody, a.Td, a.Tfoot, a.Th, a.Thead, a.Tr:
976
+ // Ignore the token.
977
+ default:
978
+ p.reconstructActiveFormattingElements()
979
+ p.addElement()
980
+ }
981
+ case EndTagToken:
982
+ switch p.tok.DataAtom {
983
+ case a.Body:
984
+ if p.elementInScope(defaultScope, a.Body) {
985
+ p.im = afterBodyIM
986
+ }
987
+ case a.Html:
988
+ if p.elementInScope(defaultScope, a.Body) {
989
+ p.parseImpliedToken(EndTagToken, a.Body, a.Body.String())
990
+ return false
991
+ }
992
+ return true
993
+ case a.Address, a.Article, a.Aside, a.Blockquote, a.Button, a.Center, a.Details, a.Dir, a.Div, a.Dl, a.Fieldset, a.Figcaption, a.Figure, a.Footer, a.Header, a.Hgroup, a.Listing, a.Menu, a.Nav, a.Ol, a.Pre, a.Section, a.Summary, a.Ul:
994
+ p.popUntil(defaultScope, p.tok.DataAtom)
995
+ case a.Form:
996
+ node := p.form
997
+ p.form = nil
998
+ i := p.indexOfElementInScope(defaultScope, a.Form)
999
+ if node == nil || i == -1 || p.oe[i] != node {
1000
+ // Ignore the token.
1001
+ return true
1002
+ }
1003
+ p.generateImpliedEndTags()
1004
+ p.oe.remove(node)
1005
+ case a.P:
1006
+ if !p.elementInScope(buttonScope, a.P) {
1007
+ p.parseImpliedToken(StartTagToken, a.P, a.P.String())
1008
+ }
1009
+ p.popUntil(buttonScope, a.P)
1010
+ case a.Li:
1011
+ p.popUntil(listItemScope, a.Li)
1012
+ case a.Dd, a.Dt:
1013
+ p.popUntil(defaultScope, p.tok.DataAtom)
1014
+ case a.H1, a.H2, a.H3, a.H4, a.H5, a.H6:
1015
+ p.popUntil(defaultScope, a.H1, a.H2, a.H3, a.H4, a.H5, a.H6)
1016
+ case a.A, a.B, a.Big, a.Code, a.Em, a.Font, a.I, a.Nobr, a.S, a.Small, a.Strike, a.Strong, a.Tt, a.U:
1017
+ p.inBodyEndTagFormatting(p.tok.DataAtom)
1018
+ case a.Applet, a.Marquee, a.Object:
1019
+ if p.popUntil(defaultScope, p.tok.DataAtom) {
1020
+ p.clearActiveFormattingElements()
1021
+ }
1022
+ case a.Br:
1023
+ p.tok.Type = StartTagToken
1024
+ return false
1025
+ default:
1026
+ p.inBodyEndTagOther(p.tok.DataAtom)
1027
+ }
1028
+ case CommentToken:
1029
+ p.addChild(&Node{
1030
+ Type: CommentNode,
1031
+ Data: p.tok.Data,
1032
+ })
1033
+ }
1034
+
1035
+ return true
1036
+ }
1037
+
1038
+ func (p *parser) inBodyEndTagFormatting(tagAtom a.Atom) {
1039
+ // This is the "adoption agency" algorithm, described at
1040
+ // https://html.spec.whatwg.org/multipage/syntax.html#adoptionAgency
1041
+
1042
+ // TODO: this is a fairly literal line-by-line translation of that algorithm.
1043
+ // Once the code successfully parses the comprehensive test suite, we should
1044
+ // refactor this code to be more idiomatic.
1045
+
1046
+ // Steps 1-4. The outer loop.
1047
+ for i := 0; i < 8; i++ {
1048
+ // Step 5. Find the formatting element.
1049
+ var formattingElement *Node
1050
+ for j := len(p.afe) - 1; j >= 0; j-- {
1051
+ if p.afe[j].Type == scopeMarkerNode {
1052
+ break
1053
+ }
1054
+ if p.afe[j].DataAtom == tagAtom {
1055
+ formattingElement = p.afe[j]
1056
+ break
1057
+ }
1058
+ }
1059
+ if formattingElement == nil {
1060
+ p.inBodyEndTagOther(tagAtom)
1061
+ return
1062
+ }
1063
+ feIndex := p.oe.index(formattingElement)
1064
+ if feIndex == -1 {
1065
+ p.afe.remove(formattingElement)
1066
+ return
1067
+ }
1068
+ if !p.elementInScope(defaultScope, tagAtom) {
1069
+ // Ignore the tag.
1070
+ return
1071
+ }
1072
+
1073
+ // Steps 9-10. Find the furthest block.
1074
+ var furthestBlock *Node
1075
+ for _, e := range p.oe[feIndex:] {
1076
+ if isSpecialElement(e) {
1077
+ furthestBlock = e
1078
+ break
1079
+ }
1080
+ }
1081
+ if furthestBlock == nil {
1082
+ e := p.oe.pop()
1083
+ for e != formattingElement {
1084
+ e = p.oe.pop()
1085
+ }
1086
+ p.afe.remove(e)
1087
+ return
1088
+ }
1089
+
1090
+ // Steps 11-12. Find the common ancestor and bookmark node.
1091
+ commonAncestor := p.oe[feIndex-1]
1092
+ bookmark := p.afe.index(formattingElement)
1093
+
1094
+ // Step 13. The inner loop. Find the lastNode to reparent.
1095
+ lastNode := furthestBlock
1096
+ node := furthestBlock
1097
+ x := p.oe.index(node)
1098
+ // Steps 13.1-13.2
1099
+ for j := 0; j < 3; j++ {
1100
+ // Step 13.3.
1101
+ x--
1102
+ node = p.oe[x]
1103
+ // Step 13.4 - 13.5.
1104
+ if p.afe.index(node) == -1 {
1105
+ p.oe.remove(node)
1106
+ continue
1107
+ }
1108
+ // Step 13.6.
1109
+ if node == formattingElement {
1110
+ break
1111
+ }
1112
+ // Step 13.7.
1113
+ clone := node.clone()
1114
+ p.afe[p.afe.index(node)] = clone
1115
+ p.oe[p.oe.index(node)] = clone
1116
+ node = clone
1117
+ // Step 13.8.
1118
+ if lastNode == furthestBlock {
1119
+ bookmark = p.afe.index(node) + 1
1120
+ }
1121
+ // Step 13.9.
1122
+ if lastNode.Parent != nil {
1123
+ lastNode.Parent.RemoveChild(lastNode)
1124
+ }
1125
+ node.AppendChild(lastNode)
1126
+ // Step 13.10.
1127
+ lastNode = node
1128
+ }
1129
+
1130
+ // Step 14. Reparent lastNode to the common ancestor,
1131
+ // or for misnested table nodes, to the foster parent.
1132
+ if lastNode.Parent != nil {
1133
+ lastNode.Parent.RemoveChild(lastNode)
1134
+ }
1135
+ switch commonAncestor.DataAtom {
1136
+ case a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr:
1137
+ p.fosterParent(lastNode)
1138
+ default:
1139
+ commonAncestor.AppendChild(lastNode)
1140
+ }
1141
+
1142
+ // Steps 15-17. Reparent nodes from the furthest block's children
1143
+ // to a clone of the formatting element.
1144
+ clone := formattingElement.clone()
1145
+ reparentChildren(clone, furthestBlock)
1146
+ furthestBlock.AppendChild(clone)
1147
+
1148
+ // Step 18. Fix up the list of active formatting elements.
1149
+ if oldLoc := p.afe.index(formattingElement); oldLoc != -1 && oldLoc < bookmark {
1150
+ // Move the bookmark with the rest of the list.
1151
+ bookmark--
1152
+ }
1153
+ p.afe.remove(formattingElement)
1154
+ p.afe.insert(bookmark, clone)
1155
+
1156
+ // Step 19. Fix up the stack of open elements.
1157
+ p.oe.remove(formattingElement)
1158
+ p.oe.insert(p.oe.index(furthestBlock)+1, clone)
1159
+ }
1160
+ }
1161
+
1162
+ // inBodyEndTagOther performs the "any other end tag" algorithm for inBodyIM.
1163
+ // "Any other end tag" handling from 12.2.5.5 The rules for parsing tokens in foreign content
1164
+ // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inforeign
1165
+ func (p *parser) inBodyEndTagOther(tagAtom a.Atom) {
1166
+ for i := len(p.oe) - 1; i >= 0; i-- {
1167
+ if p.oe[i].DataAtom == tagAtom {
1168
+ p.oe = p.oe[:i]
1169
+ break
1170
+ }
1171
+ if isSpecialElement(p.oe[i]) {
1172
+ break
1173
+ }
1174
+ }
1175
+ }
1176
+
1177
+ // Section 12.2.5.4.8.
1178
+ func textIM(p *parser) bool {
1179
+ switch p.tok.Type {
1180
+ case ErrorToken:
1181
+ p.oe.pop()
1182
+ case TextToken:
1183
+ d := p.tok.Data
1184
+ if n := p.oe.top(); n.DataAtom == a.Textarea && n.FirstChild == nil {
1185
+ // Ignore a newline at the start of a <textarea> block.
1186
+ if d != "" && d[0] == '\r' {
1187
+ d = d[1:]
1188
+ }
1189
+ if d != "" && d[0] == '\n' {
1190
+ d = d[1:]
1191
+ }
1192
+ }
1193
+ if d == "" {
1194
+ return true
1195
+ }
1196
+ p.addText(d)
1197
+ return true
1198
+ case EndTagToken:
1199
+ p.oe.pop()
1200
+ }
1201
+ p.im = p.originalIM
1202
+ p.originalIM = nil
1203
+ return p.tok.Type == EndTagToken
1204
+ }
1205
+
1206
+ // Section 12.2.5.4.9.
1207
+ func inTableIM(p *parser) bool {
1208
+ switch p.tok.Type {
1209
+ case ErrorToken:
1210
+ // Stop parsing.
1211
+ return true
1212
+ case TextToken:
1213
+ p.tok.Data = strings.Replace(p.tok.Data, "\x00", "", -1)
1214
+ switch p.oe.top().DataAtom {
1215
+ case a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr:
1216
+ if strings.Trim(p.tok.Data, whitespace) == "" {
1217
+ p.addText(p.tok.Data)
1218
+ return true
1219
+ }
1220
+ }
1221
+ case StartTagToken:
1222
+ switch p.tok.DataAtom {
1223
+ case a.Caption:
1224
+ p.clearStackToContext(tableScope)
1225
+ p.afe = append(p.afe, &scopeMarker)
1226
+ p.addElement()
1227
+ p.im = inCaptionIM
1228
+ return true
1229
+ case a.Colgroup:
1230
+ p.clearStackToContext(tableScope)
1231
+ p.addElement()
1232
+ p.im = inColumnGroupIM
1233
+ return true
1234
+ case a.Col:
1235
+ p.parseImpliedToken(StartTagToken, a.Colgroup, a.Colgroup.String())
1236
+ return false
1237
+ case a.Tbody, a.Tfoot, a.Thead:
1238
+ p.clearStackToContext(tableScope)
1239
+ p.addElement()
1240
+ p.im = inTableBodyIM
1241
+ return true
1242
+ case a.Td, a.Th, a.Tr:
1243
+ p.parseImpliedToken(StartTagToken, a.Tbody, a.Tbody.String())
1244
+ return false
1245
+ case a.Table:
1246
+ if p.popUntil(tableScope, a.Table) {
1247
+ p.resetInsertionMode()
1248
+ return false
1249
+ }
1250
+ // Ignore the token.
1251
+ return true
1252
+ case a.Style, a.Script:
1253
+ return inHeadIM(p)
1254
+ case a.Input:
1255
+ for _, t := range p.tok.Attr {
1256
+ if t.Key == "type" && strings.ToLower(t.Val) == "hidden" {
1257
+ p.addElement()
1258
+ p.oe.pop()
1259
+ return true
1260
+ }
1261
+ }
1262
+ // Otherwise drop down to the default action.
1263
+ case a.Form:
1264
+ if p.form != nil {
1265
+ // Ignore the token.
1266
+ return true
1267
+ }
1268
+ p.addElement()
1269
+ p.form = p.oe.pop()
1270
+ case a.Select:
1271
+ p.reconstructActiveFormattingElements()
1272
+ switch p.top().DataAtom {
1273
+ case a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr:
1274
+ p.fosterParenting = true
1275
+ }
1276
+ p.addElement()
1277
+ p.fosterParenting = false
1278
+ p.framesetOK = false
1279
+ p.im = inSelectInTableIM
1280
+ return true
1281
+ }
1282
+ case EndTagToken:
1283
+ switch p.tok.DataAtom {
1284
+ case a.Table:
1285
+ if p.popUntil(tableScope, a.Table) {
1286
+ p.resetInsertionMode()
1287
+ return true
1288
+ }
1289
+ // Ignore the token.
1290
+ return true
1291
+ case a.Body, a.Caption, a.Col, a.Colgroup, a.Html, a.Tbody, a.Td, a.Tfoot, a.Th, a.Thead, a.Tr:
1292
+ // Ignore the token.
1293
+ return true
1294
+ }
1295
+ case CommentToken:
1296
+ p.addChild(&Node{
1297
+ Type: CommentNode,
1298
+ Data: p.tok.Data,
1299
+ })
1300
+ return true
1301
+ case DoctypeToken:
1302
+ // Ignore the token.
1303
+ return true
1304
+ }
1305
+
1306
+ p.fosterParenting = true
1307
+ defer func() { p.fosterParenting = false }()
1308
+
1309
+ return inBodyIM(p)
1310
+ }
1311
+
1312
+ // Section 12.2.5.4.11.
1313
+ func inCaptionIM(p *parser) bool {
1314
+ switch p.tok.Type {
1315
+ case StartTagToken:
1316
+ switch p.tok.DataAtom {
1317
+ case a.Caption, a.Col, a.Colgroup, a.Tbody, a.Td, a.Tfoot, a.Thead, a.Tr:
1318
+ if p.popUntil(tableScope, a.Caption) {
1319
+ p.clearActiveFormattingElements()
1320
+ p.im = inTableIM
1321
+ return false
1322
+ } else {
1323
+ // Ignore the token.
1324
+ return true
1325
+ }
1326
+ case a.Select:
1327
+ p.reconstructActiveFormattingElements()
1328
+ p.addElement()
1329
+ p.framesetOK = false
1330
+ p.im = inSelectInTableIM
1331
+ return true
1332
+ }
1333
+ case EndTagToken:
1334
+ switch p.tok.DataAtom {
1335
+ case a.Caption:
1336
+ if p.popUntil(tableScope, a.Caption) {
1337
+ p.clearActiveFormattingElements()
1338
+ p.im = inTableIM
1339
+ }
1340
+ return true
1341
+ case a.Table:
1342
+ if p.popUntil(tableScope, a.Caption) {
1343
+ p.clearActiveFormattingElements()
1344
+ p.im = inTableIM
1345
+ return false
1346
+ } else {
1347
+ // Ignore the token.
1348
+ return true
1349
+ }
1350
+ case a.Body, a.Col, a.Colgroup, a.Html, a.Tbody, a.Td, a.Tfoot, a.Th, a.Thead, a.Tr:
1351
+ // Ignore the token.
1352
+ return true
1353
+ }
1354
+ }
1355
+ return inBodyIM(p)
1356
+ }
1357
+
1358
+ // Section 12.2.5.4.12.
1359
+ func inColumnGroupIM(p *parser) bool {
1360
+ switch p.tok.Type {
1361
+ case TextToken:
1362
+ s := strings.TrimLeft(p.tok.Data, whitespace)
1363
+ if len(s) < len(p.tok.Data) {
1364
+ // Add the initial whitespace to the current node.
1365
+ p.addText(p.tok.Data[:len(p.tok.Data)-len(s)])
1366
+ if s == "" {
1367
+ return true
1368
+ }
1369
+ p.tok.Data = s
1370
+ }
1371
+ case CommentToken:
1372
+ p.addChild(&Node{
1373
+ Type: CommentNode,
1374
+ Data: p.tok.Data,
1375
+ })
1376
+ return true
1377
+ case DoctypeToken:
1378
+ // Ignore the token.
1379
+ return true
1380
+ case StartTagToken:
1381
+ switch p.tok.DataAtom {
1382
+ case a.Html:
1383
+ return inBodyIM(p)
1384
+ case a.Col:
1385
+ p.addElement()
1386
+ p.oe.pop()
1387
+ p.acknowledgeSelfClosingTag()
1388
+ return true
1389
+ }
1390
+ case EndTagToken:
1391
+ switch p.tok.DataAtom {
1392
+ case a.Colgroup:
1393
+ if p.oe.top().DataAtom != a.Html {
1394
+ p.oe.pop()
1395
+ p.im = inTableIM
1396
+ }
1397
+ return true
1398
+ case a.Col:
1399
+ // Ignore the token.
1400
+ return true
1401
+ }
1402
+ }
1403
+ if p.oe.top().DataAtom != a.Html {
1404
+ p.oe.pop()
1405
+ p.im = inTableIM
1406
+ return false
1407
+ }
1408
+ return true
1409
+ }
1410
+
1411
+ // Section 12.2.5.4.13.
1412
+ func inTableBodyIM(p *parser) bool {
1413
+ switch p.tok.Type {
1414
+ case StartTagToken:
1415
+ switch p.tok.DataAtom {
1416
+ case a.Tr:
1417
+ p.clearStackToContext(tableBodyScope)
1418
+ p.addElement()
1419
+ p.im = inRowIM
1420
+ return true
1421
+ case a.Td, a.Th:
1422
+ p.parseImpliedToken(StartTagToken, a.Tr, a.Tr.String())
1423
+ return false
1424
+ case a.Caption, a.Col, a.Colgroup, a.Tbody, a.Tfoot, a.Thead:
1425
+ if p.popUntil(tableScope, a.Tbody, a.Thead, a.Tfoot) {
1426
+ p.im = inTableIM
1427
+ return false
1428
+ }
1429
+ // Ignore the token.
1430
+ return true
1431
+ }
1432
+ case EndTagToken:
1433
+ switch p.tok.DataAtom {
1434
+ case a.Tbody, a.Tfoot, a.Thead:
1435
+ if p.elementInScope(tableScope, p.tok.DataAtom) {
1436
+ p.clearStackToContext(tableBodyScope)
1437
+ p.oe.pop()
1438
+ p.im = inTableIM
1439
+ }
1440
+ return true
1441
+ case a.Table:
1442
+ if p.popUntil(tableScope, a.Tbody, a.Thead, a.Tfoot) {
1443
+ p.im = inTableIM
1444
+ return false
1445
+ }
1446
+ // Ignore the token.
1447
+ return true
1448
+ case a.Body, a.Caption, a.Col, a.Colgroup, a.Html, a.Td, a.Th, a.Tr:
1449
+ // Ignore the token.
1450
+ return true
1451
+ }
1452
+ case CommentToken:
1453
+ p.addChild(&Node{
1454
+ Type: CommentNode,
1455
+ Data: p.tok.Data,
1456
+ })
1457
+ return true
1458
+ }
1459
+
1460
+ return inTableIM(p)
1461
+ }
1462
+
1463
+ // Section 12.2.5.4.14.
1464
+ func inRowIM(p *parser) bool {
1465
+ switch p.tok.Type {
1466
+ case StartTagToken:
1467
+ switch p.tok.DataAtom {
1468
+ case a.Td, a.Th:
1469
+ p.clearStackToContext(tableRowScope)
1470
+ p.addElement()
1471
+ p.afe = append(p.afe, &scopeMarker)
1472
+ p.im = inCellIM
1473
+ return true
1474
+ case a.Caption, a.Col, a.Colgroup, a.Tbody, a.Tfoot, a.Thead, a.Tr:
1475
+ if p.popUntil(tableScope, a.Tr) {
1476
+ p.im = inTableBodyIM
1477
+ return false
1478
+ }
1479
+ // Ignore the token.
1480
+ return true
1481
+ }
1482
+ case EndTagToken:
1483
+ switch p.tok.DataAtom {
1484
+ case a.Tr:
1485
+ if p.popUntil(tableScope, a.Tr) {
1486
+ p.im = inTableBodyIM
1487
+ return true
1488
+ }
1489
+ // Ignore the token.
1490
+ return true
1491
+ case a.Table:
1492
+ if p.popUntil(tableScope, a.Tr) {
1493
+ p.im = inTableBodyIM
1494
+ return false
1495
+ }
1496
+ // Ignore the token.
1497
+ return true
1498
+ case a.Tbody, a.Tfoot, a.Thead:
1499
+ if p.elementInScope(tableScope, p.tok.DataAtom) {
1500
+ p.parseImpliedToken(EndTagToken, a.Tr, a.Tr.String())
1501
+ return false
1502
+ }
1503
+ // Ignore the token.
1504
+ return true
1505
+ case a.Body, a.Caption, a.Col, a.Colgroup, a.Html, a.Td, a.Th:
1506
+ // Ignore the token.
1507
+ return true
1508
+ }
1509
+ }
1510
+
1511
+ return inTableIM(p)
1512
+ }
1513
+
1514
+ // Section 12.2.5.4.15.
1515
+ func inCellIM(p *parser) bool {
1516
+ switch p.tok.Type {
1517
+ case StartTagToken:
1518
+ switch p.tok.DataAtom {
1519
+ case a.Caption, a.Col, a.Colgroup, a.Tbody, a.Td, a.Tfoot, a.Th, a.Thead, a.Tr:
1520
+ if p.popUntil(tableScope, a.Td, a.Th) {
1521
+ // Close the cell and reprocess.
1522
+ p.clearActiveFormattingElements()
1523
+ p.im = inRowIM
1524
+ return false
1525
+ }
1526
+ // Ignore the token.
1527
+ return true
1528
+ case a.Select:
1529
+ p.reconstructActiveFormattingElements()
1530
+ p.addElement()
1531
+ p.framesetOK = false
1532
+ p.im = inSelectInTableIM
1533
+ return true
1534
+ }
1535
+ case EndTagToken:
1536
+ switch p.tok.DataAtom {
1537
+ case a.Td, a.Th:
1538
+ if !p.popUntil(tableScope, p.tok.DataAtom) {
1539
+ // Ignore the token.
1540
+ return true
1541
+ }
1542
+ p.clearActiveFormattingElements()
1543
+ p.im = inRowIM
1544
+ return true
1545
+ case a.Body, a.Caption, a.Col, a.Colgroup, a.Html:
1546
+ // Ignore the token.
1547
+ return true
1548
+ case a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr:
1549
+ if !p.elementInScope(tableScope, p.tok.DataAtom) {
1550
+ // Ignore the token.
1551
+ return true
1552
+ }
1553
+ // Close the cell and reprocess.
1554
+ p.popUntil(tableScope, a.Td, a.Th)
1555
+ p.clearActiveFormattingElements()
1556
+ p.im = inRowIM
1557
+ return false
1558
+ }
1559
+ }
1560
+ return inBodyIM(p)
1561
+ }
1562
+
1563
+ // Section 12.2.5.4.16.
1564
+ func inSelectIM(p *parser) bool {
1565
+ switch p.tok.Type {
1566
+ case ErrorToken:
1567
+ // Stop parsing.
1568
+ return true
1569
+ case TextToken:
1570
+ p.addText(strings.Replace(p.tok.Data, "\x00", "", -1))
1571
+ case StartTagToken:
1572
+ switch p.tok.DataAtom {
1573
+ case a.Html:
1574
+ return inBodyIM(p)
1575
+ case a.Option:
1576
+ if p.top().DataAtom == a.Option {
1577
+ p.oe.pop()
1578
+ }
1579
+ p.addElement()
1580
+ case a.Optgroup:
1581
+ if p.top().DataAtom == a.Option {
1582
+ p.oe.pop()
1583
+ }
1584
+ if p.top().DataAtom == a.Optgroup {
1585
+ p.oe.pop()
1586
+ }
1587
+ p.addElement()
1588
+ case a.Select:
1589
+ p.tok.Type = EndTagToken
1590
+ return false
1591
+ case a.Input, a.Keygen, a.Textarea:
1592
+ if p.elementInScope(selectScope, a.Select) {
1593
+ p.parseImpliedToken(EndTagToken, a.Select, a.Select.String())
1594
+ return false
1595
+ }
1596
+ // In order to properly ignore <textarea>, we need to change the tokenizer mode.
1597
+ p.tokenizer.NextIsNotRawText()
1598
+ // Ignore the token.
1599
+ return true
1600
+ case a.Script:
1601
+ return inHeadIM(p)
1602
+ }
1603
+ case EndTagToken:
1604
+ switch p.tok.DataAtom {
1605
+ case a.Option:
1606
+ if p.top().DataAtom == a.Option {
1607
+ p.oe.pop()
1608
+ }
1609
+ case a.Optgroup:
1610
+ i := len(p.oe) - 1
1611
+ if p.oe[i].DataAtom == a.Option {
1612
+ i--
1613
+ }
1614
+ if p.oe[i].DataAtom == a.Optgroup {
1615
+ p.oe = p.oe[:i]
1616
+ }
1617
+ case a.Select:
1618
+ if p.popUntil(selectScope, a.Select) {
1619
+ p.resetInsertionMode()
1620
+ }
1621
+ }
1622
+ case CommentToken:
1623
+ p.addChild(&Node{
1624
+ Type: CommentNode,
1625
+ Data: p.tok.Data,
1626
+ })
1627
+ case DoctypeToken:
1628
+ // Ignore the token.
1629
+ return true
1630
+ }
1631
+
1632
+ return true
1633
+ }
1634
+
1635
+ // Section 12.2.5.4.17.
1636
+ func inSelectInTableIM(p *parser) bool {
1637
+ switch p.tok.Type {
1638
+ case StartTagToken, EndTagToken:
1639
+ switch p.tok.DataAtom {
1640
+ case a.Caption, a.Table, a.Tbody, a.Tfoot, a.Thead, a.Tr, a.Td, a.Th:
1641
+ if p.tok.Type == StartTagToken || p.elementInScope(tableScope, p.tok.DataAtom) {
1642
+ p.parseImpliedToken(EndTagToken, a.Select, a.Select.String())
1643
+ return false
1644
+ } else {
1645
+ // Ignore the token.
1646
+ return true
1647
+ }
1648
+ }
1649
+ }
1650
+ return inSelectIM(p)
1651
+ }
1652
+
1653
+ // Section 12.2.5.4.18.
1654
+ func afterBodyIM(p *parser) bool {
1655
+ switch p.tok.Type {
1656
+ case ErrorToken:
1657
+ // Stop parsing.
1658
+ return true
1659
+ case TextToken:
1660
+ s := strings.TrimLeft(p.tok.Data, whitespace)
1661
+ if len(s) == 0 {
1662
+ // It was all whitespace.
1663
+ return inBodyIM(p)
1664
+ }
1665
+ case StartTagToken:
1666
+ if p.tok.DataAtom == a.Html {
1667
+ return inBodyIM(p)
1668
+ }
1669
+ case EndTagToken:
1670
+ if p.tok.DataAtom == a.Html {
1671
+ if !p.fragment {
1672
+ p.im = afterAfterBodyIM
1673
+ }
1674
+ return true
1675
+ }
1676
+ case CommentToken:
1677
+ // The comment is attached to the <html> element.
1678
+ if len(p.oe) < 1 || p.oe[0].DataAtom != a.Html {
1679
+ panic("html: bad parser state: <html> element not found, in the after-body insertion mode")
1680
+ }
1681
+ p.oe[0].AppendChild(&Node{
1682
+ Type: CommentNode,
1683
+ Data: p.tok.Data,
1684
+ })
1685
+ return true
1686
+ }
1687
+ p.im = inBodyIM
1688
+ return false
1689
+ }
1690
+
1691
+ // Section 12.2.5.4.19.
1692
+ func inFramesetIM(p *parser) bool {
1693
+ switch p.tok.Type {
1694
+ case CommentToken:
1695
+ p.addChild(&Node{
1696
+ Type: CommentNode,
1697
+ Data: p.tok.Data,
1698
+ })
1699
+ case TextToken:
1700
+ // Ignore all text but whitespace.
1701
+ s := strings.Map(func(c rune) rune {
1702
+ switch c {
1703
+ case ' ', '\t', '\n', '\f', '\r':
1704
+ return c
1705
+ }
1706
+ return -1
1707
+ }, p.tok.Data)
1708
+ if s != "" {
1709
+ p.addText(s)
1710
+ }
1711
+ case StartTagToken:
1712
+ switch p.tok.DataAtom {
1713
+ case a.Html:
1714
+ return inBodyIM(p)
1715
+ case a.Frameset:
1716
+ p.addElement()
1717
+ case a.Frame:
1718
+ p.addElement()
1719
+ p.oe.pop()
1720
+ p.acknowledgeSelfClosingTag()
1721
+ case a.Noframes:
1722
+ return inHeadIM(p)
1723
+ }
1724
+ case EndTagToken:
1725
+ switch p.tok.DataAtom {
1726
+ case a.Frameset:
1727
+ if p.oe.top().DataAtom != a.Html {
1728
+ p.oe.pop()
1729
+ if p.oe.top().DataAtom != a.Frameset {
1730
+ p.im = afterFramesetIM
1731
+ return true
1732
+ }
1733
+ }
1734
+ }
1735
+ default:
1736
+ // Ignore the token.
1737
+ }
1738
+ return true
1739
+ }
1740
+
1741
+ // Section 12.2.5.4.20.
1742
+ func afterFramesetIM(p *parser) bool {
1743
+ switch p.tok.Type {
1744
+ case CommentToken:
1745
+ p.addChild(&Node{
1746
+ Type: CommentNode,
1747
+ Data: p.tok.Data,
1748
+ })
1749
+ case TextToken:
1750
+ // Ignore all text but whitespace.
1751
+ s := strings.Map(func(c rune) rune {
1752
+ switch c {
1753
+ case ' ', '\t', '\n', '\f', '\r':
1754
+ return c
1755
+ }
1756
+ return -1
1757
+ }, p.tok.Data)
1758
+ if s != "" {
1759
+ p.addText(s)
1760
+ }
1761
+ case StartTagToken:
1762
+ switch p.tok.DataAtom {
1763
+ case a.Html:
1764
+ return inBodyIM(p)
1765
+ case a.Noframes:
1766
+ return inHeadIM(p)
1767
+ }
1768
+ case EndTagToken:
1769
+ switch p.tok.DataAtom {
1770
+ case a.Html:
1771
+ p.im = afterAfterFramesetIM
1772
+ return true
1773
+ }
1774
+ default:
1775
+ // Ignore the token.
1776
+ }
1777
+ return true
1778
+ }
1779
+
1780
+ // Section 12.2.5.4.21.
1781
+ func afterAfterBodyIM(p *parser) bool {
1782
+ switch p.tok.Type {
1783
+ case ErrorToken:
1784
+ // Stop parsing.
1785
+ return true
1786
+ case TextToken:
1787
+ s := strings.TrimLeft(p.tok.Data, whitespace)
1788
+ if len(s) == 0 {
1789
+ // It was all whitespace.
1790
+ return inBodyIM(p)
1791
+ }
1792
+ case StartTagToken:
1793
+ if p.tok.DataAtom == a.Html {
1794
+ return inBodyIM(p)
1795
+ }
1796
+ case CommentToken:
1797
+ p.doc.AppendChild(&Node{
1798
+ Type: CommentNode,
1799
+ Data: p.tok.Data,
1800
+ })
1801
+ return true
1802
+ case DoctypeToken:
1803
+ return inBodyIM(p)
1804
+ }
1805
+ p.im = inBodyIM
1806
+ return false
1807
+ }
1808
+
1809
+ // Section 12.2.5.4.22.
1810
+ func afterAfterFramesetIM(p *parser) bool {
1811
+ switch p.tok.Type {
1812
+ case CommentToken:
1813
+ p.doc.AppendChild(&Node{
1814
+ Type: CommentNode,
1815
+ Data: p.tok.Data,
1816
+ })
1817
+ case TextToken:
1818
+ // Ignore all text but whitespace.
1819
+ s := strings.Map(func(c rune) rune {
1820
+ switch c {
1821
+ case ' ', '\t', '\n', '\f', '\r':
1822
+ return c
1823
+ }
1824
+ return -1
1825
+ }, p.tok.Data)
1826
+ if s != "" {
1827
+ p.tok.Data = s
1828
+ return inBodyIM(p)
1829
+ }
1830
+ case StartTagToken:
1831
+ switch p.tok.DataAtom {
1832
+ case a.Html:
1833
+ return inBodyIM(p)
1834
+ case a.Noframes:
1835
+ return inHeadIM(p)
1836
+ }
1837
+ case DoctypeToken:
1838
+ return inBodyIM(p)
1839
+ default:
1840
+ // Ignore the token.
1841
+ }
1842
+ return true
1843
+ }
1844
+
1845
+ const whitespaceOrNUL = whitespace + "\x00"
1846
+
1847
+ // Section 12.2.5.5.
1848
+ func parseForeignContent(p *parser) bool {
1849
+ switch p.tok.Type {
1850
+ case TextToken:
1851
+ if p.framesetOK {
1852
+ p.framesetOK = strings.TrimLeft(p.tok.Data, whitespaceOrNUL) == ""
1853
+ }
1854
+ p.tok.Data = strings.Replace(p.tok.Data, "\x00", "\ufffd", -1)
1855
+ p.addText(p.tok.Data)
1856
+ case CommentToken:
1857
+ p.addChild(&Node{
1858
+ Type: CommentNode,
1859
+ Data: p.tok.Data,
1860
+ })
1861
+ case StartTagToken:
1862
+ b := breakout[p.tok.Data]
1863
+ if p.tok.DataAtom == a.Font {
1864
+ loop:
1865
+ for _, attr := range p.tok.Attr {
1866
+ switch attr.Key {
1867
+ case "color", "face", "size":
1868
+ b = true
1869
+ break loop
1870
+ }
1871
+ }
1872
+ }
1873
+ if b {
1874
+ for i := len(p.oe) - 1; i >= 0; i-- {
1875
+ n := p.oe[i]
1876
+ if n.Namespace == "" || htmlIntegrationPoint(n) || mathMLTextIntegrationPoint(n) {
1877
+ p.oe = p.oe[:i+1]
1878
+ break
1879
+ }
1880
+ }
1881
+ return false
1882
+ }
1883
+ switch p.top().Namespace {
1884
+ case "math":
1885
+ adjustAttributeNames(p.tok.Attr, mathMLAttributeAdjustments)
1886
+ case "svg":
1887
+ // Adjust SVG tag names. The tokenizer lower-cases tag names, but
1888
+ // SVG wants e.g. "foreignObject" with a capital second "O".
1889
+ if x := svgTagNameAdjustments[p.tok.Data]; x != "" {
1890
+ p.tok.DataAtom = a.Lookup([]byte(x))
1891
+ p.tok.Data = x
1892
+ }
1893
+ adjustAttributeNames(p.tok.Attr, svgAttributeAdjustments)
1894
+ default:
1895
+ panic("html: bad parser state: unexpected namespace")
1896
+ }
1897
+ adjustForeignAttributes(p.tok.Attr)
1898
+ namespace := p.top().Namespace
1899
+ p.addElement()
1900
+ p.top().Namespace = namespace
1901
+ if namespace != "" {
1902
+ // Don't let the tokenizer go into raw text mode in foreign content
1903
+ // (e.g. in an SVG <title> tag).
1904
+ p.tokenizer.NextIsNotRawText()
1905
+ }
1906
+ if p.hasSelfClosingToken {
1907
+ p.oe.pop()
1908
+ p.acknowledgeSelfClosingTag()
1909
+ }
1910
+ case EndTagToken:
1911
+ for i := len(p.oe) - 1; i >= 0; i-- {
1912
+ if p.oe[i].Namespace == "" {
1913
+ return p.im(p)
1914
+ }
1915
+ if strings.EqualFold(p.oe[i].Data, p.tok.Data) {
1916
+ p.oe = p.oe[:i]
1917
+ break
1918
+ }
1919
+ }
1920
+ return true
1921
+ default:
1922
+ // Ignore the token.
1923
+ }
1924
+ return true
1925
+ }
1926
+
1927
+ // Section 12.2.5.
1928
+ func (p *parser) inForeignContent() bool {
1929
+ if len(p.oe) == 0 {
1930
+ return false
1931
+ }
1932
+ n := p.oe[len(p.oe)-1]
1933
+ if n.Namespace == "" {
1934
+ return false
1935
+ }
1936
+ if mathMLTextIntegrationPoint(n) {
1937
+ if p.tok.Type == StartTagToken && p.tok.DataAtom != a.Mglyph && p.tok.DataAtom != a.Malignmark {
1938
+ return false
1939
+ }
1940
+ if p.tok.Type == TextToken {
1941
+ return false
1942
+ }
1943
+ }
1944
+ if n.Namespace == "math" && n.DataAtom == a.AnnotationXml && p.tok.Type == StartTagToken && p.tok.DataAtom == a.Svg {
1945
+ return false
1946
+ }
1947
+ if htmlIntegrationPoint(n) && (p.tok.Type == StartTagToken || p.tok.Type == TextToken) {
1948
+ return false
1949
+ }
1950
+ if p.tok.Type == ErrorToken {
1951
+ return false
1952
+ }
1953
+ return true
1954
+ }
1955
+
1956
+ // parseImpliedToken parses a token as though it had appeared in the parser's
1957
+ // input.
1958
+ func (p *parser) parseImpliedToken(t TokenType, dataAtom a.Atom, data string) {
1959
+ realToken, selfClosing := p.tok, p.hasSelfClosingToken
1960
+ p.tok = Token{
1961
+ Type: t,
1962
+ DataAtom: dataAtom,
1963
+ Data: data,
1964
+ }
1965
+ p.hasSelfClosingToken = false
1966
+ p.parseCurrentToken()
1967
+ p.tok, p.hasSelfClosingToken = realToken, selfClosing
1968
+ }
1969
+
1970
+ // parseCurrentToken runs the current token through the parsing routines
1971
+ // until it is consumed.
1972
+ func (p *parser) parseCurrentToken() {
1973
+ if p.tok.Type == SelfClosingTagToken {
1974
+ p.hasSelfClosingToken = true
1975
+ p.tok.Type = StartTagToken
1976
+ }
1977
+
1978
+ consumed := false
1979
+ for !consumed {
1980
+ if p.inForeignContent() {
1981
+ consumed = parseForeignContent(p)
1982
+ } else {
1983
+ consumed = p.im(p)
1984
+ }
1985
+ }
1986
+
1987
+ if p.hasSelfClosingToken {
1988
+ // This is a parse error, but ignore it.
1989
+ p.hasSelfClosingToken = false
1990
+ }
1991
+ }
1992
+
1993
+ func (p *parser) parse() error {
1994
+ // Iterate until EOF. Any other error will cause an early return.
1995
+ var err error
1996
+ for err != io.EOF {
1997
+ // CDATA sections are allowed only in foreign content.
1998
+ n := p.oe.top()
1999
+ p.tokenizer.AllowCDATA(n != nil && n.Namespace != "")
2000
+ // Read and parse the next token.
2001
+ p.tokenizer.Next()
2002
+ p.tok = p.tokenizer.Token()
2003
+ if p.tok.Type == ErrorToken {
2004
+ err = p.tokenizer.Err()
2005
+ if err != nil && err != io.EOF {
2006
+ return err
2007
+ }
2008
+ }
2009
+ p.parseCurrentToken()
2010
+ }
2011
+ return nil
2012
+ }
2013
+
2014
+ // Parse returns the parse tree for the HTML from the given Reader.
2015
+ // The input is assumed to be UTF-8 encoded.
2016
+ func Parse(r io.Reader) (*Node, error) {
2017
+ p := &parser{
2018
+ tokenizer: NewTokenizer(r),
2019
+ doc: &Node{
2020
+ Type: DocumentNode,
2021
+ },
2022
+ scripting: true,
2023
+ framesetOK: true,
2024
+ im: initialIM,
2025
+ }
2026
+ err := p.parse()
2027
+ if err != nil {
2028
+ return nil, err
2029
+ }
2030
+ return p.doc, nil
2031
+ }
2032
+
2033
+ // ParseFragment parses a fragment of HTML and returns the nodes that were
2034
+ // found. If the fragment is the InnerHTML for an existing element, pass that
2035
+ // element in context.
2036
+ func ParseFragment(r io.Reader, context *Node) ([]*Node, error) {
2037
+ contextTag := ""
2038
+ if context != nil {
2039
+ if context.Type != ElementNode {
2040
+ return nil, errors.New("html: ParseFragment of non-element Node")
2041
+ }
2042
+ // The next check isn't just context.DataAtom.String() == context.Data because
2043
+ // it is valid to pass an element whose tag isn't a known atom. For example,
2044
+ // DataAtom == 0 and Data = "tagfromthefuture" is perfectly consistent.
2045
+ if context.DataAtom != a.Lookup([]byte(context.Data)) {
2046
+ return nil, fmt.Errorf("html: inconsistent Node: DataAtom=%q, Data=%q", context.DataAtom, context.Data)
2047
+ }
2048
+ contextTag = context.DataAtom.String()
2049
+ }
2050
+ p := &parser{
2051
+ tokenizer: NewTokenizerFragment(r, contextTag),
2052
+ doc: &Node{
2053
+ Type: DocumentNode,
2054
+ },
2055
+ scripting: true,
2056
+ fragment: true,
2057
+ context: context,
2058
+ }
2059
+
2060
+ root := &Node{
2061
+ Type: ElementNode,
2062
+ DataAtom: a.Html,
2063
+ Data: a.Html.String(),
2064
+ }
2065
+ p.doc.AppendChild(root)
2066
+ p.oe = nodeStack{root}
2067
+ p.resetInsertionMode()
2068
+
2069
+ for n := context; n != nil; n = n.Parent {
2070
+ if n.Type == ElementNode && n.DataAtom == a.Form {
2071
+ p.form = n
2072
+ break
2073
+ }
2074
+ }
2075
+
2076
+ err := p.parse()
2077
+ if err != nil {
2078
+ return nil, err
2079
+ }
2080
+
2081
+ parent := p.doc
2082
+ if context != nil {
2083
+ parent = root
2084
+ }
2085
+
2086
+ var result []*Node
2087
+ for c := parent.FirstChild; c != nil; {
2088
+ next := c.NextSibling
2089
+ parent.RemoveChild(c)
2090
+ result = append(result, c)
2091
+ c = next
2092
+ }
2093
+ return result, nil
2094
+ }