diff -Nru golang-github-tdewolff-parse-2.3.9/buffer/lexer.go golang-github-tdewolff-parse-2.4.2/buffer/lexer.go --- golang-github-tdewolff-parse-2.3.9/buffer/lexer.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/buffer/lexer.go 2019-12-17 13:35:25.000000000 +0000 @@ -52,7 +52,7 @@ n := len(b) if n == 0 { z.buf = nullBuffer - } else if b[n-1] != 0 { + } else { // Append NULL to buffer, but try to avoid reallocation if cap(b) > n { // Overwrite next byte but restore when done diff -Nru golang-github-tdewolff-parse-2.3.9/common.go golang-github-tdewolff-parse-2.4.2/common.go --- golang-github-tdewolff-parse-2.3.9/common.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/common.go 2019-12-17 13:35:25.000000000 +0000 @@ -5,7 +5,6 @@ "bytes" "encoding/base64" "errors" - "net/url" ) // ErrBadDataURI is returned by DataURI when the byte slice does not start with 'data:' or is too short. @@ -178,8 +177,8 @@ return nil, nil, err } data = decoded[:n] - } else if unescaped, err := url.QueryUnescape(string(data)); err == nil { - data = []byte(unescaped) + } else { + data = DecodeURL(data) } return mediatype, data, nil } @@ -190,6 +189,7 @@ } // QuoteEntity parses the given byte slice and returns the quote that got matched (' or ") and its entity length. +// TODO: deprecated func QuoteEntity(b []byte) (quote byte, n int) { if len(b) < 5 || b[0] != '&' { return 0, 0 @@ -221,9 +221,9 @@ } } } else if len(b) >= 6 && b[5] == ';' { - if EqualFold(b[1:5], []byte{'q', 'u', 'o', 't'}) { + if bytes.Equal(b[1:5], []byte{'q', 'u', 'o', 't'}) { return '"', 6 // " - } else if EqualFold(b[1:5], []byte{'a', 'p', 'o', 's'}) { + } else if bytes.Equal(b[1:5], []byte{'a', 'p', 'o', 's'}) { return '\'', 6 // ' } } diff -Nru golang-github-tdewolff-parse-2.3.9/common_test.go golang-github-tdewolff-parse-2.4.2/common_test.go --- golang-github-tdewolff-parse-2.3.9/common_test.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/common_test.go 2019-12-17 13:35:25.000000000 +0000 @@ -92,6 +92,7 @@ {"data:;base64,dGV4dA==", "text/plain", "text", nil}, {"data:image/svg+xml,", "image/svg+xml", "", nil}, {"data:;base64,()", "", "", base64.CorruptInputError(0)}, + {"data:image/svg+xml,%3Cpath%20stroke-width='9.38%'/%3E", "image/svg+xml", "", nil}, } for _, tt := range dataURITests { t.Run(tt.dataURI, func(t *testing.T) { diff -Nru golang-github-tdewolff-parse-2.3.9/css/hash.go golang-github-tdewolff-parse-2.4.2/css/hash.go --- golang-github-tdewolff-parse-2.3.9/css/hash.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/css/hash.go 2019-12-17 13:35:25.000000000 +0000 @@ -11,329 +11,423 @@ // Unique hash definitions to be used instead of strings const ( Ms_Filter Hash = 0xa // -ms-filter - Accelerator Hash = 0x4b30b // accelerator - Aliceblue Hash = 0x5b109 // aliceblue - Alpha Hash = 0x63605 // alpha - Antiquewhite Hash = 0x4900c // antiquewhite - Aquamarine Hash = 0x7a70a // aquamarine - Azimuth Hash = 0x63a07 // azimuth - Background Hash = 0x2d0a // background - Background_Attachment Hash = 0x4fb15 // background-attachment - Background_Color Hash = 0x17c10 // background-color - Background_Image Hash = 0x61510 // background-image - Background_Position Hash = 0x2d13 // background-position - Background_Position_X Hash = 0x8ac15 // background-position-x - Background_Position_Y Hash = 0x2d15 // background-position-y - Background_Repeat Hash = 0x4211 // background-repeat - Background_Size Hash = 0x660f // background-size - Behavior Hash = 0x7508 // behavior - Black Hash = 0xa505 // black - Blanchedalmond Hash = 0xaa0e // blanchedalmond - Blueviolet Hash = 0x5b60a // blueviolet - Bold Hash = 0xbf04 // bold - Border Hash = 0xca06 // border - Border_Bottom Hash = 0xca0d // border-bottom - Border_Bottom_Color Hash = 0xca13 // border-bottom-color - Border_Bottom_Style Hash = 0xe913 // border-bottom-style - Border_Bottom_Width Hash = 0x11013 // border-bottom-width - Border_Box Hash = 0x1310a // border-box - Border_Collapse Hash = 0x1620f // border-collapse - Border_Color Hash = 0x18c0c // border-color - Border_Left Hash = 0x1980b // border-left - Border_Left_Color Hash = 0x19811 // border-left-color - Border_Left_Style Hash = 0x1a911 // border-left-style - Border_Left_Width Hash = 0x1ba11 // border-left-width - Border_Right Hash = 0x1cb0c // border-right - Border_Right_Color Hash = 0x1cb12 // border-right-color - Border_Right_Style Hash = 0x1dd12 // border-right-style - Border_Right_Width Hash = 0x1ef12 // border-right-width - Border_Spacing Hash = 0x2010e // border-spacing - Border_Style Hash = 0x20f0c // border-style - Border_Top Hash = 0x21b0a // border-top - Border_Top_Color Hash = 0x21b10 // border-top-color - Border_Top_Style Hash = 0x22b10 // border-top-style - Border_Top_Width Hash = 0x23b10 // border-top-width - Border_Width Hash = 0x24b0c // border-width - Bottom Hash = 0xd106 // bottom - Box_Shadow Hash = 0x1380a // box-shadow - Burlywood Hash = 0x25709 // burlywood - Cadetblue Hash = 0x75509 // cadetblue - Calc Hash = 0x75204 // calc - Caption_Side Hash = 0x2730c // caption-side - Caret_Color Hash = 0x2850b // caret-color - Center Hash = 0x10a06 // center - Charset Hash = 0x47607 // charset - Chartreuse Hash = 0x2900a // chartreuse - Chocolate Hash = 0x29a09 // chocolate - Clear Hash = 0x2c805 // clear - Clip Hash = 0x2cd04 // clip - Color Hash = 0xd805 // color - Column_Rule Hash = 0x3220b // column-rule - Column_Rule_Color Hash = 0x32211 // column-rule-color - Content Hash = 0x33307 // content - Cornflowerblue Hash = 0x3430e // cornflowerblue - Cornsilk Hash = 0x35108 // cornsilk - Counter_Increment Hash = 0x35911 // counter-increment - Counter_Reset Hash = 0x3740d // counter-reset - Cue Hash = 0x38103 // cue - Cue_After Hash = 0x38109 // cue-after - Cue_Before Hash = 0x38a0a // cue-before - Currentcolor Hash = 0x39b0c // currentcolor - Cursive Hash = 0x3a707 // cursive - Cursor Hash = 0x3ba06 // cursor - Darkblue Hash = 0xb708 // darkblue - Darkcyan Hash = 0xc208 // darkcyan - Darkgoldenrod Hash = 0x25f0d // darkgoldenrod - Darkgray Hash = 0x26b08 // darkgray - Darkgreen Hash = 0x83709 // darkgreen - Darkkhaki Hash = 0x94e09 // darkkhaki - Darkmagenta Hash = 0x5790b // darkmagenta - Darkolivegreen Hash = 0x7c60e // darkolivegreen - Darkorange Hash = 0x82b0a // darkorange - Darkorchid Hash = 0x9450a // darkorchid - Darksalmon Hash = 0x9890a // darksalmon - Darkseagreen Hash = 0x9ea0c // darkseagreen - Darkslateblue Hash = 0x3c00d // darkslateblue - Darkslategray Hash = 0x3cd0d // darkslategray - Darkturquoise Hash = 0x3da0d // darkturquoise - Darkviolet Hash = 0x3e70a // darkviolet - Deeppink Hash = 0x27d08 // deeppink - Deepskyblue Hash = 0x95c0b // deepskyblue - Default Hash = 0x5ef07 // default - Direction Hash = 0xac109 // direction - Display Hash = 0x3f107 // display - Document Hash = 0x3ff08 // document - Dodgerblue Hash = 0x4070a // dodgerblue - Elevation Hash = 0x4d409 // elevation - Empty_Cells Hash = 0x5200b // empty-cells - Fantasy Hash = 0x56107 // fantasy - Fill Hash = 0x60c04 // fill + Accelerator Hash = 0x3760b // accelerator + Aliceblue Hash = 0x7a209 // aliceblue + Align_Content Hash = 0xd8b0d // align-content + Align_Items Hash = 0x7ef0b // align-items + Align_Self Hash = 0x8cb0a // align-self + All Hash = 0x69103 // all + Alpha Hash = 0x37205 // alpha + Animation Hash = 0xca09 // animation + Animation_Delay Hash = 0x2050f // animation-delay + Animation_Direction Hash = 0x8e913 // animation-direction + Animation_Duration Hash = 0x35d12 // animation-duration + Animation_Fill_Mode Hash = 0x66c13 // animation-fill-mode + Animation_Iteration_Count Hash = 0xd3c19 // animation-iteration-count + Animation_Name Hash = 0xca0e // animation-name + Animation_Play_State Hash = 0xfc14 // animation-play-state + Animation_Timing_Function Hash = 0x14119 // animation-timing-function + Antiquewhite Hash = 0x6490c // antiquewhite + Aquamarine Hash = 0x9ec0a // aquamarine + Attr Hash = 0x59804 // attr + Auto Hash = 0x44504 // auto + Azimuth Hash = 0x15a07 // azimuth + Background Hash = 0x2b0a // background + Background_Attachment Hash = 0x2b15 // background-attachment + Background_Clip Hash = 0xb6e0f // background-clip + Background_Color Hash = 0x21710 // background-color + Background_Image Hash = 0x5ad10 // background-image + Background_Origin Hash = 0x17111 // background-origin + Background_Position Hash = 0x18e13 // background-position + Background_Position_X Hash = 0x18e15 // background-position-x + Background_Position_Y Hash = 0x1a315 // background-position-y + Background_Repeat Hash = 0x1b811 // background-repeat + Background_Size Hash = 0x1cb0f // background-size + Behavior Hash = 0x1da08 // behavior + Black Hash = 0x1e205 // black + Blanchedalmond Hash = 0x1e70e // blanchedalmond + Blueviolet Hash = 0x7a70a // blueviolet + Bold Hash = 0x1fc04 // bold + Border Hash = 0x22706 // border + Border_Bottom Hash = 0x2270d // border-bottom + Border_Bottom_Color Hash = 0x22713 // border-bottom-color + Border_Bottom_Style Hash = 0x23a13 // border-bottom-style + Border_Bottom_Width Hash = 0x25d13 // border-bottom-width + Border_Box Hash = 0x27e0a // border-box + Border_Collapse Hash = 0x2b60f // border-collapse + Border_Color Hash = 0x2d30c // border-color + Border_Left Hash = 0x2df0b // border-left + Border_Left_Color Hash = 0x2df11 // border-left-color + Border_Left_Style Hash = 0x2f011 // border-left-style + Border_Left_Width Hash = 0x30111 // border-left-width + Border_Right Hash = 0x3120c // border-right + Border_Right_Color Hash = 0x31212 // border-right-color + Border_Right_Style Hash = 0x32412 // border-right-style + Border_Right_Width Hash = 0x33612 // border-right-width + Border_Spacing Hash = 0x3480e // border-spacing + Border_Style Hash = 0x3ab0c // border-style + Border_Top Hash = 0x3b70a // border-top + Border_Top_Color Hash = 0x3b710 // border-top-color + Border_Top_Style Hash = 0x3c710 // border-top-style + Border_Top_Width Hash = 0x3d710 // border-top-width + Border_Width Hash = 0x3e70c // border-width + Bottom Hash = 0x22e06 // bottom + Box_Shadow Hash = 0x2850a // box-shadow + Burlywood Hash = 0x3f309 // burlywood + Cadetblue Hash = 0x9c609 // cadetblue + Calc Hash = 0x9c304 // calc + Caption_Side Hash = 0x40f0c // caption-side + Caret_Color Hash = 0x4240b // caret-color + Center Hash = 0xdb06 // center + Charset Hash = 0x62f07 // charset + Chartreuse Hash = 0x42f0a // chartreuse + Chocolate Hash = 0x43909 // chocolate + Clamp Hash = 0x44e05 // clamp + Clear Hash = 0x45d05 // clear + Clip Hash = 0xb7904 // clip + Cm Hash = 0x53802 // cm + Color Hash = 0x2505 // color + Column_Count Hash = 0x4620c // column-count + Column_Gap Hash = 0x6a30a // column-gap + Column_Rule Hash = 0x4880b // column-rule + Column_Rule_Color Hash = 0x48811 // column-rule-color + Column_Rule_Style Hash = 0x49911 // column-rule-style + Column_Rule_Width Hash = 0x4aa11 // column-rule-width + Column_Width Hash = 0x4bb0c // column-width + Columns Hash = 0x74607 // columns + Content Hash = 0x5607 // content + Cornflowerblue Hash = 0x4c70e // cornflowerblue + Cornsilk Hash = 0x4d508 // cornsilk + Counter_Increment Hash = 0xd5011 // counter-increment + Counter_Reset Hash = 0x4690d // counter-reset + Cue Hash = 0x4dd03 // cue + Cue_After Hash = 0x4dd09 // cue-after + Cue_Before Hash = 0x4e60a // cue-before + Currentcolor Hash = 0x5010c // currentcolor + Cursive Hash = 0x50d07 // cursive + Cursor Hash = 0x51406 // cursor + Darkblue Hash = 0x1f408 // darkblue + Darkcyan Hash = 0x1ff08 // darkcyan + Darkgoldenrod Hash = 0x3fb0d // darkgoldenrod + Darkgray Hash = 0x40708 // darkgray + Darkgreen Hash = 0x75c09 // darkgreen + Darkkhaki Hash = 0xa1409 // darkkhaki + Darkmagenta Hash = 0xce90b // darkmagenta + Darkolivegreen Hash = 0x6d90e // darkolivegreen + Darkorange Hash = 0x7500a // darkorange + Darkorchid Hash = 0xa0b0a // darkorchid + Darksalmon Hash = 0xa990a // darksalmon + Darkseagreen Hash = 0xb110c // darkseagreen + Darkslateblue Hash = 0xc1c0d // darkslateblue + Darkslategray Hash = 0xbfa0d // darkslategray + Darkturquoise Hash = 0xcaa0d // darkturquoise + Darkviolet Hash = 0x51a0a // darkviolet + Deeppink Hash = 0x67d08 // deeppink + Deepskyblue Hash = 0x4190b // deepskyblue + Default Hash = 0xa2207 // default + Deg Hash = 0x70103 // deg + Direction Hash = 0x8d909 // direction + Display Hash = 0xcce07 // display + Document Hash = 0x52408 // document + Dodgerblue Hash = 0x52c0a // dodgerblue + Dpcm Hash = 0x53604 // dpcm + Dpi Hash = 0x54f03 // dpi + Dppx Hash = 0x55b04 // dppx + Elevation Hash = 0x6d09 // elevation + Empty_Cells Hash = 0x3910b // empty-cells + Env Hash = 0x4f503 // env + Fantasy Hash = 0x3a407 // fantasy + Fill Hash = 0x67604 // fill Filter Hash = 0x406 // filter - Firebrick Hash = 0x41109 // firebrick - Flex Hash = 0x41a04 // flex - Float Hash = 0x41e05 // float - Floralwhite Hash = 0x4230b // floralwhite - Font Hash = 0x10304 // font - Font_Face Hash = 0x10309 // font-face - Font_Family Hash = 0x44d0b // font-family - Font_Size Hash = 0x45809 // font-size - Font_Size_Adjust Hash = 0x45810 // font-size-adjust - Font_Stretch Hash = 0x46c0c // font-stretch - Font_Style Hash = 0x47d0a // font-style - Font_Variant Hash = 0x4870c // font-variant - Font_Weight Hash = 0x4a20b // font-weight - Forestgreen Hash = 0x3900b // forestgreen - Fuchsia Hash = 0x4ad07 // fuchsia - Gainsboro Hash = 0x8809 // gainsboro - Ghostwhite Hash = 0x14c0a // ghostwhite - Goldenrod Hash = 0x26309 // goldenrod - Greenyellow Hash = 0x83b0b // greenyellow - Grid Hash = 0x5d204 // grid - Height Hash = 0x70906 // height - Honeydew Hash = 0x64008 // honeydew - Hsl Hash = 0x12203 // hsl - Hsla Hash = 0x12204 // hsla - Ime_Mode Hash = 0x95608 // ime-mode - Import Hash = 0x56806 // import - Important Hash = 0x56809 // important - Include_Source Hash = 0x8960e // include-source - Indianred Hash = 0x57109 // indianred - Inherit Hash = 0x5a507 // inherit - Initial Hash = 0x5ac07 // initial - Keyframes Hash = 0x43109 // keyframes - Large Hash = 0x54c05 // large - Larger Hash = 0x54c06 // larger - Lavender Hash = 0x12408 // lavender - Lavenderblush Hash = 0x1240d // lavenderblush - Lawngreen Hash = 0x9c09 // lawngreen - Layer_Background_Color Hash = 0x17616 // layer-background-color - Layer_Background_Image Hash = 0x60f16 // layer-background-image - Layout_Flow Hash = 0x5880b // layout-flow - Layout_Grid Hash = 0x5cb0b // layout-grid - Layout_Grid_Char Hash = 0xa5210 // layout-grid-char - Layout_Grid_Char_Spacing Hash = 0xa5218 // layout-grid-char-spacing - Layout_Grid_Line Hash = 0x5cb10 // layout-grid-line - Layout_Grid_Mode Hash = 0x5e110 // layout-grid-mode - Layout_Grid_Type Hash = 0x5f610 // layout-grid-type - Left Hash = 0x19f04 // left - Lemonchiffon Hash = 0xfa0c // lemonchiffon - Letter_Spacing Hash = 0x5bd0e // letter-spacing - Lightblue Hash = 0x62509 // lightblue - Lightcoral Hash = 0x62e0a // lightcoral - Lightcyan Hash = 0x66c09 // lightcyan - Lightgoldenrodyellow Hash = 0x67514 // lightgoldenrodyellow - Lightgray Hash = 0x69409 // lightgray - Lightgreen Hash = 0x69d0a // lightgreen - Lightpink Hash = 0x6a709 // lightpink - Lightsalmon Hash = 0x6b00b // lightsalmon - Lightseagreen Hash = 0x6bb0d // lightseagreen - Lightskyblue Hash = 0x6c80c // lightskyblue - Lightslateblue Hash = 0x6d40e // lightslateblue - Lightsteelblue Hash = 0x6e20e // lightsteelblue - Lightyellow Hash = 0x6f00b // lightyellow - Limegreen Hash = 0x6fb09 // limegreen - Line_Break Hash = 0x5d70a // line-break - Line_Height Hash = 0x7040b // line-height - Linear_Gradient Hash = 0x70f0f // linear-gradient - List_Style Hash = 0x71e0a // list-style - List_Style_Image Hash = 0x71e10 // list-style-image - List_Style_Position Hash = 0x72e13 // list-style-position - List_Style_Type Hash = 0x7410f // list-style-type - Local Hash = 0x75005 // local - Magenta Hash = 0x57d07 // magenta - Margin Hash = 0x2dd06 // margin - Margin_Bottom Hash = 0x2dd0d // margin-bottom - Margin_Left Hash = 0x2e90b // margin-left - Margin_Right Hash = 0x3000c // margin-right - Margin_Top Hash = 0x8720a // margin-top - Marker_Offset Hash = 0x75e0d // marker-offset - Marks Hash = 0x76b05 // marks - Mask Hash = 0x78a04 // mask - Max_Height Hash = 0x78e0a // max-height - Max_Width Hash = 0x79809 // max-width - Media Hash = 0xae905 // media - Medium Hash = 0x7a106 // medium - Mediumaquamarine Hash = 0x7a110 // mediumaquamarine - Mediumblue Hash = 0x7b10a // mediumblue - Mediumorchid Hash = 0x7bb0c // mediumorchid - Mediumpurple Hash = 0x7d40c // mediumpurple - Mediumseagreen Hash = 0x7e00e // mediumseagreen - Mediumslateblue Hash = 0x7ee0f // mediumslateblue - Mediumspringgreen Hash = 0x7fd11 // mediumspringgreen - Mediumturquoise Hash = 0x80e0f // mediumturquoise - Mediumvioletred Hash = 0x81d0f // mediumvioletred - Midnightblue Hash = 0x84b0c // midnightblue - Min_Height Hash = 0x8570a // min-height - Min_Width Hash = 0x86109 // min-width - Mintcream Hash = 0x86a09 // mintcream - Mistyrose Hash = 0x88709 // mistyrose - Moccasin Hash = 0x89008 // moccasin - Monospace Hash = 0x99009 // monospace - Namespace Hash = 0x4cc09 // namespace - Navajowhite Hash = 0x4dc0b // navajowhite - No_Repeat Hash = 0x53309 // no-repeat - None Hash = 0x8d204 // none - Normal Hash = 0x9706 // normal - Olivedrab Hash = 0x8a409 // olivedrab - Orangered Hash = 0x82f09 // orangered - Orphans Hash = 0x4bc07 // orphans - Outline Hash = 0x8d607 // outline - Outline_Color Hash = 0x8d60d // outline-color - Outline_Style Hash = 0x8e30d // outline-style - Outline_Width Hash = 0x8f00d // outline-width - Overflow Hash = 0x54008 // overflow - Overflow_X Hash = 0x5400a // overflow-x - Overflow_Y Hash = 0x8fd0a // overflow-y - Padding Hash = 0x2d007 // padding - Padding_Bottom Hash = 0x2d00e // padding-bottom - Padding_Box Hash = 0x59a0b // padding-box - Padding_Left Hash = 0x87b0c // padding-left - Padding_Right Hash = 0x9ac0d // padding-right - Padding_Top Hash = 0x9a20b // padding-top - Page Hash = 0x90704 // page - Page_Break_After Hash = 0x90710 // page-break-after - Page_Break_Before Hash = 0x91711 // page-break-before - Page_Break_Inside Hash = 0x92811 // page-break-inside - Palegoldenrod Hash = 0x9390d // palegoldenrod - Palegreen Hash = 0x96709 // palegreen - Paleturquoise Hash = 0x9700d // paleturquoise - Palevioletred Hash = 0x97d0d // palevioletred - Papayawhip Hash = 0x9990a // papayawhip - Pause Hash = 0x9b905 // pause - Pause_After Hash = 0x9b90b // pause-after - Pause_Before Hash = 0x9c40c // pause-before - Peachpuff Hash = 0x60409 // peachpuff - Pitch Hash = 0x9d005 // pitch - Pitch_Range Hash = 0x9d00b // pitch-range - Play_During Hash = 0x3f40b // play-during - Position Hash = 0x3808 // position - Powderblue Hash = 0x9db0a // powderblue - Progid Hash = 0x9e506 // progid - Quotes Hash = 0x9f606 // quotes + Firebrick Hash = 0x83509 // firebrick + Flex Hash = 0x55f04 // flex + Flex_Basis Hash = 0x89d0a // flex-basis + Flex_Direction Hash = 0x8d40e // flex-direction + Flex_Flow Hash = 0xc8709 // flex-flow + Flex_Grow Hash = 0x55f09 // flex-grow + Flex_Shrink Hash = 0x5680b // flex-shrink + Flex_Wrap Hash = 0x57309 // flex-wrap + Float Hash = 0x59505 // float + Floralwhite Hash = 0x5bd0b // floralwhite + Font Hash = 0x25404 // font + Font_Face Hash = 0x25409 // font-face + Font_Family Hash = 0x5ee0b // font-family + Font_Size Hash = 0x5f909 // font-size + Font_Size_Adjust Hash = 0x5f910 // font-size-adjust + Font_Stretch Hash = 0x6250c // font-stretch + Font_Style Hash = 0x6360a // font-style + Font_Variant Hash = 0x6400c // font-variant + Font_Weight Hash = 0x65b0b // font-weight + Forestgreen Hash = 0x4ec0b // forestgreen + Fuchsia Hash = 0x66607 // fuchsia + Gainsboro Hash = 0xec09 // gainsboro + Ghostwhite Hash = 0x2990a // ghostwhite + Goldenrod Hash = 0x3ff09 // goldenrod + Grad Hash = 0x1004 // grad + Greenyellow Hash = 0x7600b // greenyellow + Grid Hash = 0x35504 // grid + Grid_Area Hash = 0x35509 // grid-area + Grid_Auto_Columns Hash = 0x7bb11 // grid-auto-columns + Grid_Auto_Flow Hash = 0x81c0e // grid-auto-flow + Grid_Auto_Rows Hash = 0x8640e // grid-auto-rows + Grid_Column Hash = 0x69e0b // grid-column + Grid_Column_End Hash = 0xcdb0f // grid-column-end + Grid_Column_Gap Hash = 0x69e0f // grid-column-gap + Grid_Column_Start Hash = 0x6bd11 // grid-column-start + Grid_Row Hash = 0x6ce08 // grid-row + Grid_Row_End Hash = 0x6ce0c // grid-row-end + Grid_Row_Gap Hash = 0x6e70c // grid-row-gap + Grid_Row_Start Hash = 0x7030e // grid-row-start + Grid_Template Hash = 0x7110d // grid-template + Grid_Template_Areas Hash = 0x71113 // grid-template-areas + Grid_Template_Columns Hash = 0x73815 // grid-template-columns + Grid_Template_Rows Hash = 0x77012 // grid-template-rows + Height Hash = 0x9306 // height + Honeydew Hash = 0x16008 // honeydew + Hsl Hash = 0x26f03 // hsl + Hsla Hash = 0x26f04 // hsla + Hz Hash = 0x68502 // hz + Ime_Mode Hash = 0xa1c08 // ime-mode + Import Hash = 0x78d06 // import + Important Hash = 0x78d09 // important + In Hash = 0x4402 // in + Include_Source Hash = 0x1800e // include-source + Indianred Hash = 0xb0909 // indianred + Inherit Hash = 0x79607 // inherit + Initial Hash = 0x79d07 // initial + Invert Hash = 0x7e406 // invert + Justify_Content Hash = 0x4e0f // justify-content + Justify_Items Hash = 0x6050d // justify-items + Justify_Self Hash = 0x82a0c // justify-self + Keyframes Hash = 0x5cb09 // keyframes + Khz Hash = 0x68403 // khz + Large Hash = 0xa905 // large + Larger Hash = 0xa906 // larger + Lavender Hash = 0x27108 // lavender + Lavenderblush Hash = 0x2710d // lavenderblush + Lawngreen Hash = 0x2ca09 // lawngreen + Layer_Background_Color Hash = 0x21116 // layer-background-color + Layer_Background_Image Hash = 0x5a716 // layer-background-image + Layout_Flow Hash = 0xcf80b // layout-flow + Layout_Grid Hash = 0x8050b // layout-grid + Layout_Grid_Char Hash = 0x80510 // layout-grid-char + Layout_Grid_Char_Spacing Hash = 0x80518 // layout-grid-char-spacing + Layout_Grid_Line Hash = 0x83e10 // layout-grid-line + Layout_Grid_Mode Hash = 0x85410 // layout-grid-mode + Layout_Grid_Type Hash = 0x88710 // layout-grid-type + Left Hash = 0x2e604 // left + Lemonchiffon Hash = 0x24b0c // lemonchiffon + Letter_Spacing Hash = 0x7ae0e // letter-spacing + Lightblue Hash = 0x8ba09 // lightblue + Lightcoral Hash = 0x8c30a // lightcoral + Lightcyan Hash = 0x8e209 // lightcyan + Lightgoldenrodyellow Hash = 0x8fc14 // lightgoldenrodyellow + Lightgray Hash = 0x91009 // lightgray + Lightgreen Hash = 0x9190a // lightgreen + Lightpink Hash = 0x92309 // lightpink + Lightsalmon Hash = 0x92c0b // lightsalmon + Lightseagreen Hash = 0x9370d // lightseagreen + Lightskyblue Hash = 0x9440c // lightskyblue + Lightslateblue Hash = 0x9500e // lightslateblue + Lightsteelblue Hash = 0x95e0e // lightsteelblue + Lightyellow Hash = 0x96c0b // lightyellow + Limegreen Hash = 0x97709 // limegreen + Line_Break Hash = 0x84a0a // line-break + Line_Height Hash = 0x8e0b // line-height + Linear_Gradient Hash = 0x9800f // linear-gradient + List_Style Hash = 0x98f0a // list-style + List_Style_Image Hash = 0x98f10 // list-style-image + List_Style_Position Hash = 0x99f13 // list-style-position + List_Style_Type Hash = 0x9b20f // list-style-type + Local Hash = 0x9c105 // local + Magenta Hash = 0xced07 // magenta + Margin Hash = 0x53906 // margin + Margin_Bottom Hash = 0xda40d // margin-bottom + Margin_Left Hash = 0xdb00b // margin-left + Margin_Right Hash = 0xb890c // margin-right + Margin_Top Hash = 0x5390a // margin-top + Marker_Offset Hash = 0xad00d // marker-offset + Marks Hash = 0xaee05 // marks + Mask Hash = 0x9cf04 // mask + Max Hash = 0x9d303 // max + Max_Height Hash = 0x9d30a // max-height + Max_Width Hash = 0x9dd09 // max-width + Media Hash = 0xd3805 // media + Medium Hash = 0x9e606 // medium + Mediumaquamarine Hash = 0x9e610 // mediumaquamarine + Mediumblue Hash = 0x9f60a // mediumblue + Mediumorchid Hash = 0xa000c // mediumorchid + Mediumpurple Hash = 0xa420c // mediumpurple + Mediumseagreen Hash = 0xa4e0e // mediumseagreen + Mediumslateblue Hash = 0xa5c0f // mediumslateblue + Mediumspringgreen Hash = 0xa6b11 // mediumspringgreen + Mediumturquoise Hash = 0xa7c0f // mediumturquoise + Mediumvioletred Hash = 0xa8b0f // mediumvioletred + Midnightblue Hash = 0xaa90c // midnightblue + Min Hash = 0x14d03 // min + Min_Height Hash = 0xab50a // min-height + Min_Width Hash = 0xabf09 // min-width + Mintcream Hash = 0xac809 // mintcream + Mistyrose Hash = 0xae409 // mistyrose + Mm Hash = 0xaed02 // mm + Moccasin Hash = 0xb0308 // moccasin + Monospace Hash = 0xaa009 // monospace + Ms Hash = 0x102 // ms + Namespace Hash = 0xd409 // namespace + Navajowhite Hash = 0x750b // navajowhite + No_Repeat Hash = 0xbf09 // no-repeat + None Hash = 0x38e04 // none + Normal Hash = 0x36e06 // normal + Offset Hash = 0xad706 // offset + Offset_Anchor Hash = 0xad70d // offset-anchor + Offset_Distance Hash = 0xb1d0f // offset-distance + Offset_Path Hash = 0xb2c0b // offset-path + Offset_Position Hash = 0xb370f // offset-position + Offset_Rotate Hash = 0xb460d // offset-rotate + Olivedrab Hash = 0xb6609 // olivedrab + Orangered Hash = 0x75409 // orangered + Order Hash = 0x22805 // order + Orphans Hash = 0x37f07 // orphans + Outline Hash = 0xba707 // outline + Outline_Color Hash = 0xba70d // outline-color + Outline_Style Hash = 0xbb40d // outline-style + Outline_Width Hash = 0xbc10d // outline-width + Overflow Hash = 0x9d08 // overflow + Overflow_X Hash = 0x9d0a // overflow-x + Overflow_Y Hash = 0xbce0a // overflow-y + Padding Hash = 0x45207 // padding + Padding_Bottom Hash = 0xb7c0e // padding-bottom + Padding_Box Hash = 0x4520b // padding-box + Padding_Left Hash = 0xd0a0c // padding-left + Padding_Right Hash = 0x5420d // padding-right + Padding_Top Hash = 0x57b0b // padding-top + Page Hash = 0x58504 // page + Page_Break_After Hash = 0x58510 // page-break-after + Page_Break_Before Hash = 0x6ac11 // page-break-before + Page_Break_Inside Hash = 0x6f211 // page-break-inside + Palegoldenrod Hash = 0xc100d // palegoldenrod + Palegreen Hash = 0xbd809 // palegreen + Paleturquoise Hash = 0xbe10d // paleturquoise + Palevioletred Hash = 0xbee0d // palevioletred + Papayawhip Hash = 0xc070a // papayawhip + Pause Hash = 0xc2905 // pause + Pause_After Hash = 0xc290b // pause-after + Pause_Before Hash = 0xc340c // pause-before + Pc Hash = 0x53702 // pc + Peachpuff Hash = 0x89509 // peachpuff + Pitch Hash = 0x55005 // pitch + Pitch_Range Hash = 0x5500b // pitch-range + Place_Content Hash = 0xc400d // place-content + Place_Items Hash = 0xc4d0b // place-items + Place_Self Hash = 0xc7e0a // place-self + Play_During Hash = 0xcd10b // play-during + Position Hash = 0x13908 // position + Powderblue Hash = 0xc9b0a // powderblue + Progid Hash = 0xca506 // progid + Pt Hash = 0x39302 // pt + Px Hash = 0x55d02 // px + Q Hash = 0x64d01 // q + Quotes Hash = 0xcb706 // quotes + Rad Hash = 0x903 // rad Radial_Gradient Hash = 0x90f // radial-gradient - Repeat Hash = 0x4d06 // repeat - Rgb Hash = 0x4f903 // rgb - Rgba Hash = 0x4f904 // rgba - Richness Hash = 0x55108 // richness - Right Hash = 0x1d205 // right - Rosybrown Hash = 0x8f09 // rosybrown - Round Hash = 0x3205 // round - Royalblue Hash = 0x66309 // royalblue - Ruby_Align Hash = 0x8c90a // ruby-align - Ruby_Overhang Hash = 0x7c0d // ruby-overhang - Ruby_Position Hash = 0xdc0d // ruby-position - Saddlebrown Hash = 0x4c20b // saddlebrown - Sandybrown Hash = 0x52a0a // sandybrown - Sans_Serif Hash = 0x5580a // sans-serif - Scroll Hash = 0x2b306 // scroll - Scrollbar_3d_Light_Color Hash = 0x64c18 // scrollbar-3d-light-color - Scrollbar_Arrow_Color Hash = 0x2b315 // scrollbar-arrow-color - Scrollbar_Base_Color Hash = 0x43914 // scrollbar-base-color - Scrollbar_Dark_Shadow_Color Hash = 0x76f1b // scrollbar-dark-shadow-color - Scrollbar_Face_Color Hash = 0x9fb14 // scrollbar-face-color - Scrollbar_Highlight_Color Hash = 0xa9e19 // scrollbar-highlight-color - Scrollbar_Shadow_Color Hash = 0xa0f16 // scrollbar-shadow-color - Scrollbar_Track_Color Hash = 0xa2515 // scrollbar-track-color - Seagreen Hash = 0x6c008 // seagreen - Seashell Hash = 0x16f08 // seashell - Serif Hash = 0x55d05 // serif - Size Hash = 0x7104 // size - Slateblue Hash = 0x3c409 // slateblue - Slategray Hash = 0x3d109 // slategray - Small Hash = 0x8c305 // small - Smaller Hash = 0x8c307 // smaller - Space Hash = 0x15d05 // space - Speak Hash = 0xa3a05 // speak - Speak_Header Hash = 0xa3a0c // speak-header - Speak_Numeral Hash = 0xa460d // speak-numeral - Speak_Punctuation Hash = 0xa6a11 // speak-punctuation - Speech_Rate Hash = 0xa7b0b // speech-rate - Springgreen Hash = 0x8030b // springgreen - Steelblue Hash = 0x6e709 // steelblue - Stress Hash = 0x2ae06 // stress - Stroke Hash = 0x46606 // stroke - Supports Hash = 0xa9708 // supports - Table_Layout Hash = 0x5820c // table-layout - Text_Align Hash = 0x2a10a // text-align - Text_Align_Last Hash = 0x2a10f // text-align-last - Text_Autospace Hash = 0x1540e // text-autospace - Text_Decoration Hash = 0x4e50f // text-decoration - Text_Decoration_Color Hash = 0x4e515 // text-decoration-color - Text_Emphasis Hash = 0xa840d // text-emphasis - Text_Emphasis_Color Hash = 0xa8413 // text-emphasis-color - Text_Indent Hash = 0x170b // text-indent - Text_Justify Hash = 0x210c // text-justify - Text_Kashida_Space Hash = 0x50f12 // text-kashida-space - Text_Overflow Hash = 0x53b0d // text-overflow - Text_Shadow Hash = 0x520b // text-shadow - Text_Transform Hash = 0x2f30e // text-transform - Text_Underline_Position Hash = 0x30b17 // text-underline-position - Top Hash = 0x22203 // top - Transition Hash = 0x3390a // transition - Transparent Hash = 0x3690b // transparent - Turquoise Hash = 0x3de09 // turquoise - Unicode_Bidi Hash = 0xab70c // unicode-bidi - Unset Hash = 0xaca05 // unset - Vertical_Align Hash = 0x3ac0e // vertical-align - Visibility Hash = 0xacf0a // visibility - Voice_Family Hash = 0xad90c // voice-family - Volume Hash = 0xae506 // volume - White Hash = 0x15105 // white - White_Space Hash = 0x4970b // white-space - Whitesmoke Hash = 0x4290a // whitesmoke - Widows Hash = 0x64706 // widows - Width Hash = 0x11e05 // width - Word_Break Hash = 0x5c0a // word-break - Word_Spacing Hash = 0x1410c // word-spacing - Word_Wrap Hash = 0x59209 // word-wrap - Writing_Mode Hash = 0x6880c // writing-mode - X_Large Hash = 0x54a07 // x-large - X_Small Hash = 0x8c107 // x-small - Xx_Large Hash = 0x54908 // xx-large - Xx_Small Hash = 0x8c008 // xx-small - Yellow Hash = 0x68306 // yellow - Yellowgreen Hash = 0x8400b // yellowgreen - Z_Index Hash = 0xaee07 // z-index + Repeat Hash = 0xc206 // repeat + Repeat_X Hash = 0x1c308 // repeat-x + Repeat_Y Hash = 0xc208 // repeat-y + Rgb Hash = 0x2903 // rgb + Rgba Hash = 0x2904 // rgba + Richness Hash = 0xae08 // richness + Right Hash = 0x31905 // right + Rosybrown Hash = 0xf309 // rosybrown + Round Hash = 0x3005 // round + Row_Gap Hash = 0x6ec07 // row-gap + Royalblue Hash = 0x69509 // royalblue + Ruby_Align Hash = 0xd860a // ruby-align + Ruby_Overhang Hash = 0xe00d // ruby-overhang + Ruby_Position Hash = 0x1340d // ruby-position + S Hash = 0x201 // s + Saddlebrown Hash = 0xb50b // saddlebrown + Sandybrown Hash = 0x3850a // sandybrown + Sans_Serif Hash = 0x39b0a // sans-serif + Scroll Hash = 0x12006 // scroll + Scrollbar_3d_Light_Color Hash = 0xd6f18 // scrollbar-3d-light-color + Scrollbar_Arrow_Color Hash = 0x12015 // scrollbar-arrow-color + Scrollbar_Base_Color Hash = 0x8a614 // scrollbar-base-color + Scrollbar_Dark_Shadow_Color Hash = 0x5d31b // scrollbar-dark-shadow-color + Scrollbar_Face_Color Hash = 0x61114 // scrollbar-face-color + Scrollbar_Highlight_Color Hash = 0x7cb19 // scrollbar-highlight-color + Scrollbar_Shadow_Color Hash = 0x87116 // scrollbar-shadow-color + Scrollbar_Track_Color Hash = 0x72315 // scrollbar-track-color + Seagreen Hash = 0x93c08 // seagreen + Seashell Hash = 0x2c308 // seashell + Serif Hash = 0x3a005 // serif + Size Hash = 0x1d604 // size + Slateblue Hash = 0x95509 // slateblue + Slategray Hash = 0xbfe09 // slategray + Small Hash = 0x68f05 // small + Smaller Hash = 0x68f07 // smaller + Solid Hash = 0x74c05 // solid + Space Hash = 0x6905 // space + Speak Hash = 0x78105 // speak + Speak_Header Hash = 0x7810c // speak-header + Speak_Numeral Hash = 0x7f90d // speak-numeral + Speak_Punctuation Hash = 0xaf211 // speak-punctuation + Speech_Rate Hash = 0xc570b // speech-rate + Springgreen Hash = 0xa710b // springgreen + Steelblue Hash = 0x96309 // steelblue + Stress Hash = 0x11b06 // stress + Stroke Hash = 0xc7806 // stroke + Supports Hash = 0xcbc08 // supports + Table_Layout Hash = 0xcf20c // table-layout + Text_Align Hash = 0x10e0a // text-align + Text_Align_Last Hash = 0x10e0f // text-align-last + Text_Autospace Hash = 0x4400e // text-autospace + Text_Decoration Hash = 0x7e0f // text-decoration + Text_Decoration_Color Hash = 0x2a115 // text-decoration-color + Text_Decoration_Line Hash = 0x7e14 // text-decoration-line + Text_Decoration_Style Hash = 0xb5115 // text-decoration-style + Text_Decoration_Thickness Hash = 0xc6019 // text-decoration-thickness + Text_Emphasis Hash = 0x170d // text-emphasis + Text_Emphasis_Color Hash = 0x1713 // text-emphasis-color + Text_Indent Hash = 0x3f0b // text-indent + Text_Justify Hash = 0x490c // text-justify + Text_Kashida_Space Hash = 0x5c12 // text-kashida-space + Text_Overflow Hash = 0x980d // text-overflow + Text_Shadow Hash = 0xd600b // text-shadow + Text_Transform Hash = 0xd970e // text-transform + Text_Underline_Position Hash = 0xdba17 // text-underline-position + Top Hash = 0x3be03 // top + Transition Hash = 0x4750a // transition + Transition_Delay Hash = 0x59a10 // transition-delay + Transition_Duration Hash = 0xb9413 // transition-duration + Transition_Property Hash = 0x47513 // transition-property + Transition_Timing_Function Hash = 0xa281a // transition-timing-function + Transparent Hash = 0xd150b // transparent + Turn Hash = 0xd1f04 // turn + Turquoise Hash = 0xa8209 // turquoise + Unicode_Bidi Hash = 0xcc40c // unicode-bidi + Unset Hash = 0xd2305 // unset + Url Hash = 0x3f403 // url + Var Hash = 0x64503 // var + Vertical_Align Hash = 0x7e60e // vertical-align + Visibility Hash = 0x4f70a // visibility + Voice_Family Hash = 0xd280c // voice-family + Volume Hash = 0xd3406 // volume + White Hash = 0x7b05 // white + White_Space Hash = 0x6500b // white-space + Whitesmoke Hash = 0x5c30a // whitesmoke + Widows Hash = 0xd6a06 // widows + Width Hash = 0x26b05 // width + Word_Break Hash = 0x1670a // word-break + Word_Spacing Hash = 0x28e0c // word-spacing + Word_Wrap Hash = 0xd0209 // word-wrap + Writing_Mode Hash = 0xc8f0c // writing-mode + X_Large Hash = 0xa707 // x-large + X_Small Hash = 0x68d07 // x-small + Xx_Large Hash = 0xa608 // xx-large + Xx_Small Hash = 0x68c08 // xx-small + Yellow Hash = 0x76506 // yellow + Yellowgreen Hash = 0x7650b // yellowgreen + Z_Index Hash = 0x68607 // z-index ) // String returns the hash' name. @@ -379,379 +473,485 @@ return 0 } -const _Hash_hash0 = 0x4c0d9a56 +const _Hash_hash0 = 0x9acb0442 const _Hash_maxLen = 27 -const _Hash_text = "-ms-filteradial-gradientext-indentext-justifybackground-posi" + - "tion-ybackground-repeatext-shadoword-breakbackground-sizebeh" + - "avioruby-overhangainsborosybrownormalawngreenblackblanchedal" + - "mondarkblueboldarkcyanborder-bottom-coloruby-positionborder-" + - "bottom-stylemonchiffont-facenterborder-bottom-widthslavender" + - "blushborder-box-shadoword-spacinghostwhitext-autospaceborder" + - "-collapseashellayer-background-colorborder-colorborder-left-" + - "colorborder-left-styleborder-left-widthborder-right-colorbor" + - "der-right-styleborder-right-widthborder-spacingborder-styleb" + - "order-top-colorborder-top-styleborder-top-widthborder-widthb" + - "urlywoodarkgoldenrodarkgraycaption-sideeppinkcaret-colorchar" + - "treusechocolatext-align-lastresscrollbar-arrow-colorclearcli" + - "padding-bottomargin-bottomargin-leftext-transformargin-right" + - "ext-underline-positioncolumn-rule-colorcontentransitioncornf" + - "lowerbluecornsilkcounter-incrementransparentcounter-resetcue" + - "-aftercue-beforestgreencurrentcolorcursivertical-aligncursor" + - "darkslatebluedarkslategraydarkturquoisedarkvioletdisplay-dur" + - "ingdocumentdodgerbluefirebrickflexfloatfloralwhitesmokeyfram" + - "escrollbar-base-colorfont-familyfont-size-adjustrokefont-str" + - "etcharsetfont-stylefont-variantiquewhite-spacefont-weightfuc" + - "hsiacceleratorphansaddlebrownamespacelevationavajowhitext-de" + - "coration-colorgbackground-attachmentext-kashida-spacempty-ce" + - "llsandybrowno-repeatext-overflow-xx-largerichnessans-serifan" + - "tasyimportantindianredarkmagentable-layout-floword-wrapaddin" + - "g-boxinheritinitialicebluevioletter-spacinglayout-grid-line-" + - "breaklayout-grid-modefaultlayout-grid-typeachpuffillayer-bac" + - "kground-imagelightbluelightcoralphazimuthoneydewidowscrollba" + - "r-3d-light-coloroyalbluelightcyanlightgoldenrodyellowriting-" + - "modelightgraylightgreenlightpinklightsalmonlightseagreenligh" + - "tskybluelightslatebluelightsteelbluelightyellowlimegreenline" + - "-heightlinear-gradientlist-style-imagelist-style-positionlis" + - "t-style-typelocalcadetbluemarker-offsetmarkscrollbar-dark-sh" + - "adow-colormaskmax-heightmax-widthmediumaquamarinemediumbluem" + - "ediumorchidarkolivegreenmediumpurplemediumseagreenmediumslat" + - "ebluemediumspringgreenmediumturquoisemediumvioletredarkorang" + - "eredarkgreenyellowgreenmidnightbluemin-heightmin-widthmintcr" + - "eamargin-topadding-leftmistyrosemoccasinclude-sourceolivedra" + - "background-position-xx-smalleruby-alignoneoutline-coloroutli" + - "ne-styleoutline-widthoverflow-ypage-break-afterpage-break-be" + - "forepage-break-insidepalegoldenrodarkorchidarkkhakime-modeep" + - "skybluepalegreenpaleturquoisepalevioletredarksalmonospacepap" + - "ayawhipadding-topadding-rightpause-afterpause-beforepitch-ra" + - "ngepowderblueprogidarkseagreenquotescrollbar-face-colorscrol" + - "lbar-shadow-colorscrollbar-track-colorspeak-headerspeak-nume" + - "ralayout-grid-char-spacingspeak-punctuationspeech-ratext-emp" + - "hasis-colorsupportscrollbar-highlight-colorunicode-bidirecti" + - "onunsetvisibilityvoice-familyvolumediaz-index" +const _Hash_text = "-ms-filteradial-gradientext-emphasis-colorgbackground-attach" + + "mentext-indentext-justify-contentext-kashida-spacelevationav" + + "ajowhitext-decoration-line-heightext-overflow-xx-largerichne" + + "ssaddlebrowno-repeat-yanimation-namespacenteruby-overhangain" + + "sborosybrownanimation-play-statext-align-lastresscrollbar-ar" + + "row-coloruby-positionanimation-timing-functionazimuthoneydew" + + "ord-breakbackground-originclude-sourcebackground-position-xb" + + "ackground-position-ybackground-repeat-xbackground-sizebehavi" + + "orblackblanchedalmondarkblueboldarkcyanimation-delayer-backg" + + "round-colorborder-bottom-colorborder-bottom-stylemonchiffont" + + "-faceborder-bottom-widthslavenderblushborder-box-shadoword-s" + + "pacinghostwhitext-decoration-colorborder-collapseashellawngr" + + "eenborder-colorborder-left-colorborder-left-styleborder-left" + + "-widthborder-right-colorborder-right-styleborder-right-width" + + "border-spacingrid-areanimation-durationormalphacceleratorpha" + + "nsandybrownonempty-cellsans-serifantasyborder-styleborder-to" + + "p-colorborder-top-styleborder-top-widthborder-widthburlywood" + + "arkgoldenrodarkgraycaption-sideepskybluecaret-colorchartreus" + + "echocolatext-autospaceclampadding-boxclearcolumn-counter-res" + + "etransition-propertycolumn-rule-colorcolumn-rule-stylecolumn" + + "-rule-widthcolumn-widthcornflowerbluecornsilkcue-aftercue-be" + + "forestgreenvisibilitycurrentcolorcursivecursordarkvioletdocu" + + "mentdodgerbluedpcmargin-topadding-rightdpitch-rangedppxflex-" + + "growflex-shrinkflex-wrapadding-topage-break-afterfloattransi" + + "tion-delayer-background-imagefloralwhitesmokeyframescrollbar" + + "-dark-shadow-colorfont-familyfont-size-adjustify-itemscrollb" + + "ar-face-colorfont-stretcharsetfont-stylefont-variantiquewhit" + + "e-spacefont-weightfuchsianimation-fill-modeeppinkhz-indexx-s" + + "malleroyalbluegrid-column-gapage-break-beforegrid-column-sta" + + "rtgrid-row-endarkolivegreengrid-row-gapage-break-insidegrid-" + + "row-startgrid-template-areascrollbar-track-colorgrid-templat" + + "e-columnsolidarkorangeredarkgreenyellowgreengrid-template-ro" + + "wspeak-headerimportantinheritinitialicebluevioletter-spacing" + + "rid-auto-columnscrollbar-highlight-colorinvertical-align-ite" + + "mspeak-numeralayout-grid-char-spacingrid-auto-flowjustify-se" + + "lfirebricklayout-grid-line-breaklayout-grid-modegrid-auto-ro" + + "wscrollbar-shadow-colorlayout-grid-typeachpufflex-basiscroll" + + "bar-base-colorlightbluelightcoralign-selflex-directionlightc" + + "yanimation-directionlightgoldenrodyellowlightgraylightgreenl" + + "ightpinklightsalmonlightseagreenlightskybluelightslateblueli" + + "ghtsteelbluelightyellowlimegreenlinear-gradientlist-style-im" + + "agelist-style-positionlist-style-typelocalcadetbluemaskmax-h" + + "eightmax-widthmediumaquamarinemediumbluemediumorchidarkorchi" + + "darkkhakime-modefaultransition-timing-functionmediumpurpleme" + + "diumseagreenmediumslatebluemediumspringgreenmediumturquoisem" + + "ediumvioletredarksalmonospacemidnightbluemin-heightmin-width" + + "mintcreamarker-offset-anchormistyrosemmarkspeak-punctuationm" + + "occasindianredarkseagreenoffset-distanceoffset-pathoffset-po" + + "sitionoffset-rotatext-decoration-styleolivedrabackground-cli" + + "padding-bottomargin-rightransition-durationoutline-coloroutl" + + "ine-styleoutline-widthoverflow-ypalegreenpaleturquoisepalevi" + + "oletredarkslategraypapayawhipalegoldenrodarkslatebluepause-a" + + "fterpause-beforeplace-contentplace-itemspeech-ratext-decorat" + + "ion-thicknesstrokeplace-selflex-flowriting-modepowderbluepro" + + "gidarkturquoisequotesupportsunicode-bidisplay-duringrid-colu" + + "mn-endarkmagentable-layout-floword-wrapadding-leftransparent" + + "urnunsetvoice-familyvolumedianimation-iteration-counter-incr" + + "ementext-shadowidowscrollbar-3d-light-coloruby-align-content" + + "ext-transformargin-bottomargin-leftext-underline-position" -var _Hash_table = [1 << 9]Hash{ - 0x0: 0xad90c, // voice-family - 0x2: 0x4290a, // whitesmoke - 0x4: 0x9d005, // pitch - 0x6: 0x7c0d, // ruby-overhang - 0x7: 0xaee07, // z-index - 0x8: 0x8a409, // olivedrab - 0x9: 0x3a707, // cursive - 0xb: 0x4a20b, // font-weight - 0xf: 0x81d0f, // mediumvioletred - 0x11: 0x54908, // xx-large - 0x12: 0x1ef12, // border-right-width - 0x14: 0xca0d, // border-bottom - 0x18: 0x660f, // background-size - 0x19: 0x3390a, // transition - 0x1a: 0x44d0b, // font-family - 0x1b: 0xa460d, // speak-numeral - 0x1c: 0xae905, // media - 0x1d: 0x90704, // page - 0x1e: 0x8d60d, // outline-color - 0x1f: 0x3000c, // margin-right - 0x20: 0x1620f, // border-collapse - 0x21: 0x12408, // lavender - 0x22: 0x70f0f, // linear-gradient - 0x23: 0x6e20e, // lightsteelblue - 0x26: 0xa8413, // text-emphasis-color - 0x27: 0x4230b, // floralwhite - 0x28: 0x97d0d, // palevioletred - 0x29: 0x64008, // honeydew - 0x2a: 0x8d204, // none - 0x2b: 0x1dd12, // border-right-style - 0x2c: 0xa2515, // scrollbar-track-color - 0x2e: 0x3205, // round - 0x2f: 0x8f09, // rosybrown - 0x30: 0x2d15, // background-position-y - 0x31: 0x23b10, // border-top-width - 0x32: 0x47d0a, // font-style - 0x33: 0x18c0c, // border-color - 0x34: 0x5a507, // inherit - 0x37: 0x5cb10, // layout-grid-line - 0x38: 0x4f904, // rgba - 0x39: 0x96709, // palegreen - 0x3b: 0x1540e, // text-autospace - 0x3c: 0x76b05, // marks - 0x3d: 0x70906, // height - 0x3e: 0x68306, // yellow - 0x3f: 0x11e05, // width - 0x41: 0x45810, // font-size-adjust - 0x44: 0x9390d, // palegoldenrod - 0x45: 0x5790b, // darkmagenta - 0x47: 0x3c409, // slateblue - 0x48: 0x2b306, // scroll - 0x49: 0xa7b0b, // speech-rate - 0x4d: 0x95c0b, // deepskyblue - 0x4f: 0x9a20b, // padding-top - 0x50: 0x27d08, // deeppink - 0x52: 0x4d06, // repeat - 0x55: 0x35108, // cornsilk - 0x57: 0x7104, // size - 0x59: 0x16f08, // seashell - 0x5a: 0x84b0c, // midnightblue - 0x5c: 0x56809, // important - 0x5d: 0x95608, // ime-mode - 0x5e: 0x71e0a, // list-style - 0x5f: 0x92811, // page-break-inside - 0x60: 0x4c20b, // saddlebrown - 0x61: 0x7410f, // list-style-type - 0x62: 0x5f610, // layout-grid-type - 0x63: 0x75204, // calc - 0x64: 0x3ba06, // cursor - 0x66: 0x5880b, // layout-flow - 0x67: 0x1410c, // word-spacing - 0x68: 0x5e110, // layout-grid-mode - 0x69: 0x1380a, // box-shadow - 0x6b: 0x9f606, // quotes - 0x6c: 0x4fb15, // background-attachment - 0x6d: 0x55108, // richness - 0x6e: 0x22b10, // border-top-style - 0x6f: 0x38a0a, // cue-before - 0x70: 0x15105, // white - 0x71: 0x80e0f, // mediumturquoise - 0x73: 0x87b0c, // padding-left - 0x76: 0x5d70a, // line-break - 0x78: 0x2dd0d, // margin-bottom - 0x7a: 0x7c60e, // darkolivegreen - 0x7c: 0x26309, // goldenrod - 0x7d: 0x6bb0d, // lightseagreen - 0x7e: 0x14c0a, // ghostwhite - 0x7f: 0x3c00d, // darkslateblue - 0x80: 0x2010e, // border-spacing - 0x81: 0x8f00d, // outline-width - 0x83: 0x46c0c, // font-stretch - 0x85: 0x3cd0d, // darkslategray - 0x86: 0x8720a, // margin-top - 0x88: 0x8030b, // springgreen - 0x89: 0x8400b, // yellowgreen - 0x8a: 0x6f00b, // lightyellow - 0x8c: 0x6b00b, // lightsalmon - 0x8d: 0x4b30b, // accelerator - 0x8e: 0x50f12, // text-kashida-space - 0x90: 0x19811, // border-left-color - 0x92: 0xaca05, // unset - 0x95: 0x52a0a, // sandybrown - 0x96: 0x4211, // background-repeat - 0x97: 0x9c40c, // pause-before - 0x98: 0x3d109, // slategray - 0x99: 0x26b08, // darkgray - 0x9b: 0x60c04, // fill - 0x9d: 0x6e709, // steelblue - 0xa1: 0xc208, // darkcyan - 0xa2: 0x9fb14, // scrollbar-face-color - 0xa4: 0xd106, // bottom - 0xa5: 0xa6a11, // speak-punctuation - 0xa6: 0x9700d, // paleturquoise - 0xa7: 0x62e0a, // lightcoral - 0xa8: 0xae506, // volume - 0xaa: 0x6880c, // writing-mode - 0xab: 0x7ee0f, // mediumslateblue - 0xad: 0x8c305, // small - 0xae: 0x53b0d, // text-overflow - 0xb0: 0x5c0a, // word-break - 0xb4: 0x4970b, // white-space - 0xb7: 0x10304, // font - 0xb8: 0x8d607, // outline - 0xb9: 0x3690b, // transparent - 0xba: 0x2900a, // chartreuse - 0xbb: 0x56806, // import - 0xbd: 0x3e70a, // darkviolet - 0xbe: 0x2d13, // background-position - 0xbf: 0x4ad07, // fuchsia - 0xc1: 0x3808, // position - 0xc4: 0x53309, // no-repeat - 0xc6: 0x78a04, // mask - 0xc7: 0x3de09, // turquoise - 0xca: 0xaa0e, // blanchedalmond - 0xcb: 0xac109, // direction - 0xcc: 0x12204, // hsla - 0xcd: 0x520b, // text-shadow - 0xd3: 0x5cb0b, // layout-grid - 0xd5: 0x4cc09, // namespace - 0xd6: 0x8809, // gainsboro - 0xd7: 0x10309, // font-face - 0xd8: 0xb708, // darkblue - 0xda: 0x47607, // charset - 0xdd: 0x88709, // mistyrose - 0xde: 0x170b, // text-indent - 0xe0: 0x17616, // layer-background-color - 0xe2: 0x5ac07, // initial - 0xe5: 0x8960e, // include-source - 0xe6: 0xa5210, // layout-grid-char - 0xe9: 0x5400a, // overflow-x - 0xea: 0x46606, // stroke - 0xeb: 0x41109, // firebrick - 0xed: 0x41e05, // float - 0xef: 0x1cb0c, // border-right - 0xf0: 0x67514, // lightgoldenrodyellow - 0xf1: 0x86a09, // mintcream - 0xf3: 0x82b0a, // darkorange - 0xf4: 0x60409, // peachpuff - 0xf5: 0x7b10a, // mediumblue - 0xf7: 0x8c107, // x-small - 0xf9: 0xa9e19, // scrollbar-highlight-color - 0xfb: 0x10a06, // center - 0xfc: 0x2e90b, // margin-left - 0xfd: 0x9d00b, // pitch-range - 0xfe: 0x6a709, // lightpink - 0x102: 0xa5218, // layout-grid-char-spacing - 0x103: 0x2850b, // caret-color - 0x108: 0x56107, // fantasy - 0x10f: 0x7fd11, // mediumspringgreen - 0x110: 0x210c, // text-justify - 0x111: 0x9450a, // darkorchid - 0x112: 0x9990a, // papayawhip - 0x114: 0x9ea0c, // darkseagreen - 0x115: 0x4d409, // elevation - 0x116: 0x3220b, // column-rule - 0x118: 0x30b17, // text-underline-position - 0x11a: 0xca13, // border-bottom-color - 0x11c: 0x1d205, // right - 0x11d: 0x11013, // border-bottom-width - 0x11e: 0x5bd0e, // letter-spacing - 0x11f: 0x3740d, // counter-reset - 0x121: 0x63605, // alpha - 0x122: 0xa9708, // supports - 0x123: 0x3430e, // cornflowerblue - 0x126: 0xacf0a, // visibility - 0x127: 0x82f09, // orangered - 0x12a: 0x4e515, // text-decoration-color - 0x12b: 0x3da0d, // darkturquoise - 0x12d: 0x6fb09, // limegreen - 0x12e: 0x61510, // background-image - 0x12f: 0x9db0a, // powderblue - 0x130: 0x7508, // behavior - 0x131: 0x66c09, // lightcyan - 0x132: 0x35911, // counter-increment - 0x133: 0x6d40e, // lightslateblue - 0x134: 0x57109, // indianred - 0x136: 0xdc0d, // ruby-position - 0x139: 0x5b60a, // blueviolet - 0x13d: 0x64706, // widows - 0x13e: 0x2d0a, // background - 0x13f: 0x7a110, // mediumaquamarine - 0x140: 0xfa0c, // lemonchiffon - 0x141: 0x3ac0e, // vertical-align - 0x142: 0x2ae06, // stress - 0x145: 0x9706, // normal - 0x146: 0xa840d, // text-emphasis - 0x147: 0x7d40c, // mediumpurple - 0x148: 0x94e09, // darkkhaki - 0x149: 0x1cb12, // border-right-color - 0x14a: 0x4070a, // dodgerblue - 0x14d: 0x83709, // darkgreen - 0x14e: 0x5d204, // grid - 0x14f: 0x75509, // cadetblue - 0x150: 0x2dd06, // margin - 0x151: 0x91711, // page-break-before - 0x152: 0x89008, // moccasin - 0x153: 0x9e506, // progid - 0x156: 0x8fd0a, // overflow-y - 0x157: 0x90f, // radial-gradient - 0x159: 0x1310a, // border-box - 0x15b: 0x5ef07, // default - 0x15c: 0x20f0c, // border-style - 0x15e: 0x38109, // cue-after - 0x15f: 0x9b90b, // pause-after - 0x160: 0xa0f16, // scrollbar-shadow-color - 0x161: 0x22203, // top - 0x162: 0x54c05, // large - 0x164: 0x29a09, // chocolate - 0x165: 0x66309, // royalblue - 0x166: 0x4e50f, // text-decoration - 0x168: 0x4f903, // rgb - 0x16a: 0x75e0d, // marker-offset - 0x16b: 0x3ff08, // document - 0x16d: 0x21b10, // border-top-color - 0x16f: 0x8570a, // min-height - 0x171: 0x79809, // max-width - 0x173: 0x5200b, // empty-cells - 0x175: 0x2d00e, // padding-bottom - 0x17c: 0x9890a, // darksalmon - 0x17d: 0x1240d, // lavenderblush - 0x17e: 0x1a911, // border-left-style - 0x17f: 0x5580a, // sans-serif - 0x180: 0xa3a05, // speak - 0x182: 0x1980b, // border-left - 0x186: 0x2a10f, // text-align-last - 0x187: 0x86109, // min-width - 0x188: 0x33307, // content - 0x189: 0x69409, // lightgray - 0x18a: 0x39b0c, // currentcolor - 0x18b: 0x21b0a, // border-top - 0x18c: 0x90710, // page-break-after - 0x18f: 0x24b0c, // border-width - 0x192: 0x60f16, // layer-background-image - 0x193: 0x19f04, // left - 0x194: 0x7bb0c, // mediumorchid - 0x195: 0x4dc0b, // navajowhite - 0x196: 0x25709, // burlywood - 0x197: 0x2d007, // padding - 0x198: 0x5820c, // table-layout - 0x199: 0x4bc07, // orphans - 0x19a: 0x99009, // monospace - 0x19d: 0x8e30d, // outline-style - 0x19e: 0x59209, // word-wrap - 0x19f: 0x76f1b, // scrollbar-dark-shadow-color - 0x1a0: 0x43914, // scrollbar-base-color - 0x1a1: 0x41a04, // flex - 0x1a3: 0x9c09, // lawngreen - 0x1a4: 0x3f107, // display - 0x1a6: 0x5b109, // aliceblue - 0x1a7: 0x2c805, // clear - 0x1a9: 0x54008, // overflow - 0x1ab: 0x64c18, // scrollbar-3d-light-color - 0x1ac: 0x7040b, // line-height - 0x1ad: 0x83b0b, // greenyellow - 0x1ae: 0x3900b, // forestgreen - 0x1af: 0x45809, // font-size - 0x1b1: 0x7a106, // medium - 0x1b2: 0x8c008, // xx-small - 0x1b3: 0x55d05, // serif - 0x1b4: 0x54a07, // x-large - 0x1b8: 0xa, // -ms-filter - 0x1b9: 0xd805, // color - 0x1ba: 0x2b315, // scrollbar-arrow-color - 0x1bb: 0x54c06, // larger - 0x1bc: 0x4900c, // antiquewhite - 0x1bd: 0x75005, // local - 0x1bf: 0x7e00e, // mediumseagreen - 0x1c0: 0x78e0a, // max-height - 0x1c1: 0xbf04, // bold - 0x1c3: 0x8ac15, // background-position-x - 0x1c5: 0x2a10a, // text-align - 0x1c6: 0x9b905, // pause - 0x1c7: 0x1ba11, // border-left-width - 0x1c8: 0x25f0d, // darkgoldenrod - 0x1cb: 0x57d07, // magenta - 0x1cc: 0xca06, // border - 0x1cd: 0x2f30e, // text-transform - 0x1ce: 0x71e10, // list-style-image - 0x1cf: 0x4870c, // font-variant - 0x1d0: 0x406, // filter - 0x1d1: 0x38103, // cue - 0x1d6: 0x3f40b, // play-during - 0x1d9: 0x8c90a, // ruby-align - 0x1da: 0x2cd04, // clip - 0x1db: 0x17c10, // background-color - 0x1de: 0x63a07, // azimuth - 0x1e2: 0x2730c, // caption-side - 0x1e3: 0x59a0b, // padding-box - 0x1e4: 0x9ac0d, // padding-right - 0x1e5: 0x12203, // hsl - 0x1e6: 0x8c307, // smaller - 0x1e9: 0x72e13, // list-style-position - 0x1ec: 0xab70c, // unicode-bidi - 0x1ef: 0x7a70a, // aquamarine - 0x1f0: 0x15d05, // space - 0x1f1: 0xa505, // black - 0x1f3: 0xa3a0c, // speak-header - 0x1f4: 0x6c008, // seagreen - 0x1f7: 0x32211, // column-rule-color - 0x1fa: 0x62509, // lightblue - 0x1fc: 0xe913, // border-bottom-style - 0x1fd: 0x69d0a, // lightgreen - 0x1fe: 0x43109, // keyframes - 0x1ff: 0x6c80c, // lightskyblue +var _Hash_table = [1 << 10]Hash{ + 0x3: 0xc290b, // pause-after + 0x6: 0xd5011, // counter-increment + 0x8: 0xcce07, // display + 0x9: 0x51a0a, // darkviolet + 0xb: 0xbf09, // no-repeat + 0xd: 0x4402, // in + 0x14: 0x6f211, // page-break-inside + 0x15: 0x6250c, // font-stretch + 0x19: 0x5f910, // font-size-adjust + 0x1a: 0x47513, // transition-property + 0x1c: 0x78105, // speak + 0x1f: 0x82a0c, // justify-self + 0x20: 0x61114, // scrollbar-face-color + 0x24: 0x2b60f, // border-collapse + 0x25: 0x68607, // z-index + 0x27: 0xd8b0d, // align-content + 0x2a: 0x99f13, // list-style-position + 0x2b: 0xcdb0f, // grid-column-end + 0x2c: 0x14119, // animation-timing-function + 0x30: 0xb0909, // indianred + 0x34: 0x97709, // limegreen + 0x35: 0xbc10d, // outline-width + 0x3f: 0x15a07, // azimuth + 0x40: 0x1e70e, // blanchedalmond + 0x41: 0x84a0a, // line-break + 0x42: 0x7a209, // aliceblue + 0x43: 0xf309, // rosybrown + 0x46: 0xa7c0f, // mediumturquoise + 0x49: 0xd6a06, // widows + 0x4b: 0xb370f, // offset-position + 0x4d: 0xd150b, // transparent + 0x4e: 0x79d07, // initial + 0x52: 0x1cb0f, // background-size + 0x55: 0x2505, // color + 0x56: 0x59a10, // transition-delay + 0x5a: 0x750b, // navajowhite + 0x5b: 0x7110d, // grid-template + 0x5c: 0x3b710, // border-top-color + 0x62: 0xbce0a, // overflow-y + 0x64: 0x9370d, // lightseagreen + 0x6c: 0x10e0f, // text-align-last + 0x6f: 0x8050b, // layout-grid + 0x70: 0xca09, // animation + 0x71: 0x1da08, // behavior + 0x72: 0x5390a, // margin-top + 0x74: 0x3ab0c, // border-style + 0x78: 0x5d31b, // scrollbar-dark-shadow-color + 0x79: 0x69103, // all + 0x7a: 0x3f0b, // text-indent + 0x7b: 0xbe10d, // paleturquoise + 0x7e: 0x58510, // page-break-after + 0x80: 0x5420d, // padding-right + 0x84: 0x7e60e, // vertical-align + 0x85: 0x50d07, // cursive + 0x8a: 0x7030e, // grid-row-start + 0x8c: 0xae08, // richness + 0x8e: 0x3b70a, // border-top + 0x94: 0x35509, // grid-area + 0x95: 0x85410, // layout-grid-mode + 0x96: 0xaee05, // marks + 0x97: 0x64d01, // q + 0x98: 0x78d09, // important + 0x9c: 0x406, // filter + 0x9d: 0xa8b0f, // mediumvioletred + 0xa5: 0xc570b, // speech-rate + 0xa8: 0x53702, // pc + 0xab: 0x90f, // radial-gradient + 0xae: 0x11b06, // stress + 0xb4: 0x6050d, // justify-items + 0xb7: 0x9500e, // lightslateblue + 0xba: 0x35504, // grid + 0xbb: 0xb0308, // moccasin + 0xbe: 0xd0209, // word-wrap + 0xc0: 0x6d90e, // darkolivegreen + 0xc5: 0xc6019, // text-decoration-thickness + 0xc7: 0xdb06, // center + 0xc8: 0x2a115, // text-decoration-color + 0xcb: 0xabf09, // min-width + 0xce: 0x5ee0b, // font-family + 0xd1: 0xa1c08, // ime-mode + 0xd3: 0x3d710, // border-top-width + 0xd4: 0x53906, // margin + 0xd9: 0x4880b, // column-rule + 0xda: 0x98f0a, // list-style + 0xdf: 0x6ce0c, // grid-row-end + 0xe4: 0x2050f, // animation-delay + 0xe8: 0x4aa11, // column-rule-width + 0xec: 0x57309, // flex-wrap + 0xed: 0xced07, // magenta + 0xee: 0x88710, // layout-grid-type + 0xef: 0x4520b, // padding-box + 0xf0: 0x7e14, // text-decoration-line + 0xf2: 0x4dd09, // cue-after + 0xf4: 0x8640e, // grid-auto-rows + 0xf5: 0x7650b, // yellowgreen + 0xf8: 0x89509, // peachpuff + 0xf9: 0x74607, // columns + 0xfa: 0x22805, // order + 0xfb: 0x3120c, // border-right + 0x100: 0x1800e, // include-source + 0x104: 0xc2905, // pause + 0x105: 0x1fc04, // bold + 0x106: 0xcc40c, // unicode-bidi + 0x108: 0x67604, // fill + 0x109: 0x75c09, // darkgreen + 0x10b: 0x45d05, // clear + 0x10c: 0x67d08, // deeppink + 0x110: 0x8e913, // animation-direction + 0x112: 0x1b811, // background-repeat + 0x117: 0xca506, // progid + 0x11d: 0x8a614, // scrollbar-base-color + 0x11e: 0xa, // -ms-filter + 0x11f: 0x2ca09, // lawngreen + 0x120: 0x51406, // cursor + 0x121: 0x44e05, // clamp + 0x123: 0x48811, // column-rule-color + 0x128: 0x40f0c, // caption-side + 0x12a: 0xc9b0a, // powderblue + 0x12b: 0xdba17, // text-underline-position + 0x12d: 0x72315, // scrollbar-track-color + 0x131: 0x81c0e, // grid-auto-flow + 0x132: 0x7810c, // speak-header + 0x133: 0x25409, // font-face + 0x136: 0xa710b, // springgreen + 0x13a: 0xc7e0a, // place-self + 0x13d: 0xc206, // repeat + 0x13e: 0x9800f, // linear-gradient + 0x142: 0x5010c, // currentcolor + 0x145: 0xad706, // offset + 0x14a: 0x69e0f, // grid-column-gap + 0x14c: 0x6905, // space + 0x14e: 0x39b0a, // sans-serif + 0x14f: 0x6360a, // font-style + 0x153: 0x66607, // fuchsia + 0x154: 0xb7904, // clip + 0x155: 0xae409, // mistyrose + 0x158: 0x9d08, // overflow + 0x15d: 0xc7806, // stroke + 0x162: 0x80510, // layout-grid-char + 0x163: 0xa420c, // mediumpurple + 0x165: 0x4f503, // env + 0x168: 0x4690d, // counter-reset + 0x16b: 0x5cb09, // keyframes + 0x16f: 0x7b05, // white + 0x172: 0x1004, // grad + 0x174: 0xda40d, // margin-bottom + 0x175: 0x31212, // border-right-color + 0x177: 0x25404, // font + 0x178: 0xc100d, // palegoldenrod + 0x179: 0x73815, // grid-template-columns + 0x17a: 0x7e0f, // text-decoration + 0x17e: 0x89d0a, // flex-basis + 0x186: 0x7ef0b, // align-items + 0x189: 0x4bb0c, // column-width + 0x18a: 0x3c710, // border-top-style + 0x18b: 0x1d604, // size + 0x18c: 0xd3805, // media + 0x191: 0xb7c0e, // padding-bottom + 0x194: 0x2df11, // border-left-color + 0x195: 0x7a70a, // blueviolet + 0x198: 0x92c0b, // lightsalmon + 0x19d: 0x27108, // lavender + 0x19e: 0x5a716, // layer-background-image + 0x1a0: 0x6500b, // white-space + 0x1a3: 0xe00d, // ruby-overhang + 0x1a4: 0x24b0c, // lemonchiffon + 0x1a5: 0x3be03, // top + 0x1a9: 0x2c308, // seashell + 0x1aa: 0x7ae0e, // letter-spacing + 0x1ac: 0x2b0a, // background + 0x1af: 0x64503, // var + 0x1b0: 0xaed02, // mm + 0x1b6: 0x12015, // scrollbar-arrow-color + 0x1b8: 0xd970e, // text-transform + 0x1b9: 0x65b0b, // font-weight + 0x1ba: 0x53802, // cm + 0x1bb: 0x12006, // scroll + 0x1c0: 0x21710, // background-color + 0x1c1: 0x2710d, // lavenderblush + 0x1c6: 0xb5115, // text-decoration-style + 0x1c9: 0x79607, // inherit + 0x1cf: 0x2e604, // left + 0x1d0: 0x6490c, // antiquewhite + 0x1d4: 0xb6609, // olivedrab + 0x1da: 0x2990a, // ghostwhite + 0x1dd: 0x91009, // lightgray + 0x1e2: 0x26f04, // hsla + 0x1e3: 0x26f03, // hsl + 0x1e4: 0xbd809, // palegreen + 0x1e5: 0x4190b, // deepskyblue + 0x1e8: 0xac809, // mintcream + 0x1ea: 0x7e406, // invert + 0x1eb: 0x6400c, // font-variant + 0x1ec: 0x8fc14, // lightgoldenrodyellow + 0x1ee: 0x62f07, // charset + 0x1ef: 0xc8f0c, // writing-mode + 0x1f0: 0x5c30a, // whitesmoke + 0x1f5: 0x9d0a, // overflow-x + 0x1f6: 0xaa90c, // midnightblue + 0x1f7: 0xcb706, // quotes + 0x1f8: 0x22706, // border + 0x1fa: 0x42f0a, // chartreuse + 0x1fc: 0xba707, // outline + 0x1fd: 0xa281a, // transition-timing-function + 0x1fe: 0xcbc08, // supports + 0x204: 0x1670a, // word-break + 0x205: 0xaa009, // monospace + 0x206: 0x2850a, // box-shadow + 0x209: 0x5680b, // flex-shrink + 0x20f: 0xd0a0c, // padding-left + 0x214: 0xc4d0b, // place-items + 0x216: 0xc070a, // papayawhip + 0x217: 0x17111, // background-origin + 0x218: 0x52408, // document + 0x219: 0x52c0a, // dodgerblue + 0x21c: 0x9440c, // lightskyblue + 0x21e: 0x6bd11, // grid-column-start + 0x221: 0x30111, // border-left-width + 0x224: 0x68c08, // xx-small + 0x226: 0x1f408, // darkblue + 0x229: 0x25d13, // border-bottom-width + 0x22a: 0x98f10, // list-style-image + 0x22d: 0x44504, // auto + 0x230: 0x1e205, // black + 0x231: 0xaf211, // speak-punctuation + 0x232: 0x13908, // position + 0x234: 0xc340c, // pause-before + 0x236: 0x95e0e, // lightsteelblue + 0x23a: 0xcd10b, // play-during + 0x23f: 0x83509, // firebrick + 0x249: 0x6ce08, // grid-row + 0x24a: 0x55d02, // px + 0x24c: 0x1a315, // background-position-y + 0x251: 0xd1f04, // turn + 0x256: 0xba70d, // outline-color + 0x257: 0x9c304, // calc + 0x258: 0xd3c19, // animation-iteration-count + 0x259: 0xad70d, // offset-anchor + 0x25b: 0xa4e0e, // mediumseagreen + 0x25e: 0x4620c, // column-count + 0x263: 0x10e0a, // text-align + 0x266: 0x66c13, // animation-fill-mode + 0x267: 0x32412, // border-right-style + 0x268: 0xa707, // x-large + 0x269: 0x8d40e, // flex-direction + 0x26a: 0x4f70a, // visibility + 0x26f: 0xb2c0b, // offset-path + 0x270: 0x27e0a, // border-box + 0x276: 0x70103, // deg + 0x278: 0x1713, // text-emphasis-color + 0x27f: 0xc1c0d, // darkslateblue + 0x283: 0x55f09, // flex-grow + 0x285: 0x8e209, // lightcyan + 0x28a: 0x102, // ms + 0x28d: 0xa906, // larger + 0x28e: 0xa990a, // darksalmon + 0x292: 0x2f011, // border-left-style + 0x293: 0xa8209, // turquoise + 0x294: 0x3a407, // fantasy + 0x296: 0xec09, // gainsboro + 0x297: 0x201, // s + 0x298: 0x23a13, // border-bottom-style + 0x299: 0xce90b, // darkmagenta + 0x29b: 0xb50b, // saddlebrown + 0x2a0: 0x59505, // float + 0x2a3: 0x6ec07, // row-gap + 0x2a5: 0xd3406, // volume + 0x2a6: 0xab50a, // min-height + 0x2a7: 0x77012, // grid-template-rows + 0x2a9: 0x3760b, // accelerator + 0x2b0: 0x68f05, // small + 0x2b1: 0x59804, // attr + 0x2b2: 0x28e0c, // word-spacing + 0x2b3: 0x35d12, // animation-duration + 0x2b5: 0x4dd03, // cue + 0x2b6: 0x95509, // slateblue + 0x2b8: 0x38e04, // none + 0x2b9: 0x6a30a, // column-gap + 0x2ba: 0x4e0f, // justify-content + 0x2bb: 0x5607, // content + 0x2bd: 0x54f03, // dpi + 0x2be: 0x87116, // scrollbar-shadow-color + 0x2bf: 0x78d06, // import + 0x2c0: 0xc8709, // flex-flow + 0x2c1: 0x69509, // royalblue + 0x2c3: 0x9c609, // cadetblue + 0x2c4: 0x490c, // text-justify + 0x2cb: 0x8c30a, // lightcoral + 0x2cf: 0xb890c, // margin-right + 0x2d2: 0x76506, // yellow + 0x2d3: 0x26b05, // width + 0x2d6: 0x14d03, // min + 0x2da: 0x1340d, // ruby-position + 0x2dc: 0x40708, // darkgray + 0x2e2: 0x69e0b, // grid-column + 0x2e4: 0xa1409, // darkkhaki + 0x2e5: 0xc400d, // place-content + 0x2e7: 0xbee0d, // palevioletred + 0x2ea: 0x5bd0b, // floralwhite + 0x2eb: 0xc208, // repeat-y + 0x2ee: 0x980d, // text-overflow + 0x2f1: 0xca0e, // animation-name + 0x2fb: 0x7cb19, // scrollbar-highlight-color + 0x2fe: 0x5500b, // pitch-range + 0x302: 0x3005, // round + 0x305: 0x4c70e, // cornflowerblue + 0x307: 0x7f90d, // speak-numeral + 0x308: 0x9e606, // medium + 0x30a: 0x170d, // text-emphasis + 0x30d: 0x9dd09, // max-width + 0x311: 0x36e06, // normal + 0x312: 0x68403, // khz + 0x315: 0x2903, // rgb + 0x316: 0x8ba09, // lightblue + 0x317: 0x8d909, // direction + 0x31a: 0xd280c, // voice-family + 0x31c: 0x3480e, // border-spacing + 0x321: 0x6d09, // elevation + 0x323: 0x1c308, // repeat-x + 0x324: 0x83e10, // layout-grid-line + 0x326: 0xa000c, // mediumorchid + 0x32b: 0xa6b11, // mediumspringgreen + 0x32d: 0xa905, // large + 0x32e: 0xd860a, // ruby-align + 0x330: 0xbfa0d, // darkslategray + 0x332: 0x5c12, // text-kashida-space + 0x334: 0xbb40d, // outline-style + 0x336: 0x3a005, // serif + 0x337: 0x4240b, // caret-color + 0x33a: 0x37205, // alpha + 0x33c: 0x71113, // grid-template-areas + 0x33d: 0x49911, // column-rule-style + 0x33f: 0xcf80b, // layout-flow + 0x340: 0x31905, // right + 0x341: 0x3e70c, // border-width + 0x343: 0xb6e0f, // background-clip + 0x345: 0x74c05, // solid + 0x346: 0x2df0b, // border-left + 0x348: 0x9ec0a, // aquamarine + 0x349: 0x3850a, // sandybrown + 0x34a: 0x16008, // honeydew + 0x34b: 0x75409, // orangered + 0x34c: 0xb110c, // darkseagreen + 0x34d: 0x37f07, // orphans + 0x34e: 0x6e70c, // grid-row-gap + 0x351: 0x22e06, // bottom + 0x359: 0x9c105, // local + 0x35c: 0x8cb0a, // align-self + 0x35e: 0x33612, // border-right-width + 0x360: 0x2b15, // background-attachment + 0x364: 0x9190a, // lightgreen + 0x366: 0x39302, // pt + 0x368: 0x4400e, // text-autospace + 0x36b: 0x3f403, // url + 0x36c: 0x68502, // hz + 0x371: 0x9306, // height + 0x372: 0x5ad10, // background-image + 0x377: 0x903, // rad + 0x37c: 0x21116, // layer-background-color + 0x37d: 0x1ff08, // darkcyan + 0x382: 0x18e13, // background-position + 0x384: 0x9d303, // max + 0x38c: 0xa608, // xx-large + 0x38d: 0x3f309, // burlywood + 0x38f: 0xd6f18, // scrollbar-3d-light-color + 0x390: 0x3ff09, // goldenrod + 0x392: 0x92309, // lightpink + 0x393: 0x8e0b, // line-height + 0x396: 0x22713, // border-bottom-color + 0x398: 0x80518, // layout-grid-char-spacing + 0x39c: 0x2904, // rgba + 0x3a1: 0x9f60a, // mediumblue + 0x3a3: 0x9d30a, // max-height + 0x3a4: 0x7bb11, // grid-auto-columns + 0x3a5: 0xa0b0a, // darkorchid + 0x3a9: 0x7600b, // greenyellow + 0x3ae: 0x96c0b, // lightyellow + 0x3b1: 0x4750a, // transition + 0x3b3: 0x4e60a, // cue-before + 0x3b9: 0x96309, // steelblue + 0x3be: 0xa5c0f, // mediumslateblue + 0x3bf: 0xcaa0d, // darkturquoise + 0x3c0: 0x43909, // chocolate + 0x3c3: 0x5f909, // font-size + 0x3c5: 0x55f04, // flex + 0x3c7: 0xd2305, // unset + 0x3c8: 0xd600b, // text-shadow + 0x3ca: 0x4ec0b, // forestgreen + 0x3cc: 0xbfe09, // slategray + 0x3cd: 0x6ac11, // page-break-before + 0x3ce: 0x55b04, // dppx + 0x3d0: 0x2270d, // border-bottom + 0x3d3: 0xb1d0f, // offset-distance + 0x3d4: 0x3fb0d, // darkgoldenrod + 0x3d6: 0x53604, // dpcm + 0x3d8: 0x7500a, // darkorange + 0x3dc: 0xb9413, // transition-duration + 0x3de: 0x2d30c, // border-color + 0x3df: 0x18e15, // background-position-x + 0x3e0: 0x55005, // pitch + 0x3e2: 0xdb00b, // margin-left + 0x3e3: 0x58504, // page + 0x3e5: 0x57b0b, // padding-top + 0x3e7: 0xb460d, // offset-rotate + 0x3e8: 0x93c08, // seagreen + 0x3e9: 0x4d508, // cornsilk + 0x3ea: 0x68f07, // smaller + 0x3ec: 0xcf20c, // table-layout + 0x3ed: 0xfc14, // animation-play-state + 0x3ef: 0xa2207, // default + 0x3f0: 0x68d07, // x-small + 0x3f3: 0x9e610, // mediumaquamarine + 0x3f4: 0xad00d, // marker-offset + 0x3f9: 0xd409, // namespace + 0x3fa: 0x9cf04, // mask + 0x3fb: 0x45207, // padding + 0x3fd: 0x9b20f, // list-style-type + 0x3ff: 0x3910b, // empty-cells } diff -Nru golang-github-tdewolff-parse-2.3.9/css/lex.go golang-github-tdewolff-parse-2.4.2/css/lex.go --- golang-github-tdewolff-parse-2.3.9/css/lex.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/css/lex.go 2019-12-17 13:35:25.000000000 +0000 @@ -158,6 +158,11 @@ l.r.Restore() } +// Offset returns the current position in the input stream. +func (l *Lexer) Offset() int { + return l.r.Offset() +} + // Next returns the next Token. It returns ErrorToken when an error was encountered. Using Err() one can retrieve the error message. func (l *Lexer) Next() (TokenType, []byte) { switch l.r.Peek(0) { @@ -348,7 +353,8 @@ l.r.Move(n) return true } else if c == 0 && l.r.Err() != nil { - return true + l.r.Rewind(mark) + return false } } l.r.Move(1) @@ -638,6 +644,7 @@ break } else if c == '\\' { if !l.consumeEscape() { + // either newline or EOF after backslash l.r.Move(1) l.consumeNewline() } diff -Nru golang-github-tdewolff-parse-2.3.9/css/lex_test.go golang-github-tdewolff-parse-2.4.2/css/lex_test.go --- golang-github-tdewolff-parse-2.3.9/css/lex_test.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/css/lex_test.go 2019-12-17 13:35:25.000000000 +0000 @@ -13,107 +13,113 @@ func TestTokens(t *testing.T) { var tokenTests = []struct { - css string - expected []TokenType + css string + ttypes []TokenType + lexemes []string }{ - {" ", TTs{}}, - {"5.2 .4", TTs{NumberToken, NumberToken}}, - {"color: red;", TTs{IdentToken, ColonToken, IdentToken, SemicolonToken}}, - {"background: url(\"http://x\");", TTs{IdentToken, ColonToken, URLToken, SemicolonToken}}, - {"background: URL(x.png);", TTs{IdentToken, ColonToken, URLToken, SemicolonToken}}, - {"color: rgb(4, 0%, 5em);", TTs{IdentToken, ColonToken, FunctionToken, NumberToken, CommaToken, PercentageToken, CommaToken, DimensionToken, RightParenthesisToken, SemicolonToken}}, - {"body { \"string\" }", TTs{IdentToken, LeftBraceToken, StringToken, RightBraceToken}}, - {"body { \"str\\\"ing\" }", TTs{IdentToken, LeftBraceToken, StringToken, RightBraceToken}}, - {".class { }", TTs{DelimToken, IdentToken, LeftBraceToken, RightBraceToken}}, - {"#class { }", TTs{HashToken, LeftBraceToken, RightBraceToken}}, - {"#class\\#withhash { }", TTs{HashToken, LeftBraceToken, RightBraceToken}}, - {"@media print { }", TTs{AtKeywordToken, IdentToken, LeftBraceToken, RightBraceToken}}, - {"/*comment*/", TTs{CommentToken}}, - {"/*com* /ment*/", TTs{CommentToken}}, - {"~= |= ^= $= *=", TTs{IncludeMatchToken, DashMatchToken, PrefixMatchToken, SuffixMatchToken, SubstringMatchToken}}, - {"||", TTs{ColumnToken}}, - {"", TTs{CDOToken, CDCToken}}, - {"U+1234", TTs{UnicodeRangeToken}}, - {"5.2 .4 4e-22", TTs{NumberToken, NumberToken, NumberToken}}, - {"--custom-variable", TTs{CustomPropertyNameToken}}, + {" ", TTs{}, []string{}}, + {"5.2 .4", TTs{NumberToken, NumberToken}, []string{"5.2", ".4"}}, + {"color: red;", TTs{IdentToken, ColonToken, IdentToken, SemicolonToken}, []string{"color", ":", "red", ";"}}, + {"background: url(\"http://x\");", TTs{IdentToken, ColonToken, URLToken, SemicolonToken}, []string{"background", ":", `url("http://x")`, ";"}}, + {"background: URL(x.png);", TTs{IdentToken, ColonToken, URLToken, SemicolonToken}, []string{"background", ":", "URL(x.png)", ";"}}, + {"color: rgb(4, 0%, 5em);", TTs{IdentToken, ColonToken, FunctionToken, NumberToken, CommaToken, PercentageToken, CommaToken, DimensionToken, RightParenthesisToken, SemicolonToken}, []string{"color", ":", "rgb(", "4", ",", "0%", ",", "5em", ")", ";"}}, + {"body { \"string\" }", TTs{IdentToken, LeftBraceToken, StringToken, RightBraceToken}, []string{"body", "{", `"string"`, "}"}}, + {"body { \"str\\\"ing\" }", TTs{IdentToken, LeftBraceToken, StringToken, RightBraceToken}, []string{"body", "{", `"str\"ing"`, "}"}}, + {".class { }", TTs{DelimToken, IdentToken, LeftBraceToken, RightBraceToken}, []string{".", "class", "{", "}"}}, + {"#class { }", TTs{HashToken, LeftBraceToken, RightBraceToken}, []string{"#class", "{", "}"}}, + {"#class\\#withhash { }", TTs{HashToken, LeftBraceToken, RightBraceToken}, []string{`#class\#withhash`, "{", "}"}}, + {"@media print { }", TTs{AtKeywordToken, IdentToken, LeftBraceToken, RightBraceToken}, []string{"@media", "print", "{", "}"}}, + {"/*comment*/", TTs{CommentToken}, []string{"/*comment*/"}}, + {"/*com* /ment*/", TTs{CommentToken}, []string{"/*com* /ment*/"}}, + {"~= |= ^= $= *=", TTs{IncludeMatchToken, DashMatchToken, PrefixMatchToken, SuffixMatchToken, SubstringMatchToken}, []string{"~=", "|=", "^=", "$=", "*="}}, + {"||", TTs{ColumnToken}, []string{"||"}}, + {"", TTs{CDOToken, CDCToken}, []string{""}}, + {"U+1234", TTs{UnicodeRangeToken}, []string{"U+1234"}}, + {"5.2 .4 4e-22", TTs{NumberToken, NumberToken, NumberToken}, []string{"5.2", ".4", "4e-22"}}, + {"--custom-variable", TTs{CustomPropertyNameToken}, []string{"--custom-variable"}}, // unexpected ending - {"ident", TTs{IdentToken}}, - {"123.", TTs{NumberToken, DelimToken}}, - {"\"string", TTs{StringToken}}, - {"123/*comment", TTs{NumberToken, CommentToken}}, - {"U+1-", TTs{IdentToken, NumberToken, DelimToken}}, + {"ident", TTs{IdentToken}, []string{"ident"}}, + {"123.", TTs{NumberToken, DelimToken}, []string{"123", "."}}, + {"\"string", TTs{StringToken}, []string{`"string`}}, + {"123/*comment", TTs{NumberToken, CommentToken}, []string{"123", "/*comment"}}, + {"U+1-", TTs{IdentToken, NumberToken, DelimToken}, []string{"U", "+1", "-"}}, // unicode - {"fooδbar􀀀", TTs{IdentToken}}, - {"foo\\æ\\†", TTs{IdentToken}}, - // {"foo\x00bar", TTs{IdentToken}}, - {"'foo\u554abar'", TTs{StringToken}}, - {"\\000026B", TTs{IdentToken}}, - {"\\26 B", TTs{IdentToken}}, + {"fooδbar􀀀", TTs{IdentToken}, []string{"fooδbar􀀀"}}, + {"foo\\æ\\†", TTs{IdentToken}, []string{"foo\\æ\\†"}}, + {"'foo\u554abar'", TTs{StringToken}, []string{"'foo\u554abar'"}}, + {"\\000026B", TTs{IdentToken}, []string{"\\000026B"}}, + {"\\26 B", TTs{IdentToken}, []string{"\\26 B"}}, // hacks - {`\-\mo\z\-b\i\nd\in\g:\url(//business\i\nfo.co.uk\/labs\/xbl\/xbl\.xml\#xss);`, TTs{IdentToken, ColonToken, URLToken, SemicolonToken}}, - {"width/**/:/**/ 40em;", TTs{IdentToken, CommentToken, ColonToken, CommentToken, DimensionToken, SemicolonToken}}, - {":root *> #quince", TTs{ColonToken, IdentToken, DelimToken, DelimToken, HashToken}}, - {"html[xmlns*=\"\"]:root", TTs{IdentToken, LeftBracketToken, IdentToken, SubstringMatchToken, StringToken, RightBracketToken, ColonToken, IdentToken}}, - {"body:nth-of-type(1)", TTs{IdentToken, ColonToken, FunctionToken, NumberToken, RightParenthesisToken}}, - {"color/*\\**/: blue\\9;", TTs{IdentToken, CommentToken, ColonToken, IdentToken, SemicolonToken}}, - {"color: blue !ie;", TTs{IdentToken, ColonToken, IdentToken, DelimToken, IdentToken, SemicolonToken}}, + {`\-\mo\z\-b\i\nd\in\g:\url(//business\i\nfo.co.uk\/labs\/xbl\/xbl\.xml\#xss);`, TTs{IdentToken, ColonToken, URLToken, SemicolonToken}, []string{`\-\mo\z\-b\i\nd\in\g`, ":", `\url(//business\i\nfo.co.uk\/labs\/xbl\/xbl\.xml\#xss)`, ";"}}, + {"width/**/:/**/ 40em;", TTs{IdentToken, CommentToken, ColonToken, CommentToken, DimensionToken, SemicolonToken}, []string{"width", "/**/", ":", "/**/", "40em", ";"}}, + {":root *> #quince", TTs{ColonToken, IdentToken, DelimToken, DelimToken, HashToken}, []string{":", "root", "*", ">", "#quince"}}, + {"html[xmlns*=\"\"]:root", TTs{IdentToken, LeftBracketToken, IdentToken, SubstringMatchToken, StringToken, RightBracketToken, ColonToken, IdentToken}, []string{"html", "[", "xmlns", "*=", `""`, "]", ":", "root"}}, + {"body:nth-of-type(1)", TTs{IdentToken, ColonToken, FunctionToken, NumberToken, RightParenthesisToken}, []string{"body", ":", "nth-of-type(", "1", ")"}}, + {"color/*\\**/: blue\\9;", TTs{IdentToken, CommentToken, ColonToken, IdentToken, SemicolonToken}, []string{"color", `/*\**/`, ":", `blue\9`, ";"}}, + {"color: blue !ie;", TTs{IdentToken, ColonToken, IdentToken, DelimToken, IdentToken, SemicolonToken}, []string{"color", ":", "blue", "!", "ie", ";"}}, // escapes, null and replacement character - {"c\\\x00olor: white;", TTs{IdentToken, ColonToken, IdentToken, SemicolonToken}}, - {"null\\0", TTs{IdentToken}}, - {"eof\\", TTs{IdentToken}}, - {"\"a\x00b\"", TTs{StringToken}}, - {"a\\\x00b", TTs{IdentToken}}, - {"url(a\x00b)", TTs{BadURLToken}}, // null character cannot be unquoted - {"/*a\x00b*/", TTs{CommentToken}}, + {"c\\\x00olor: white;", TTs{IdentToken, ColonToken, IdentToken, SemicolonToken}, []string{"c\\\x00olor", ":", "white", ";"}}, + {"null\\0", TTs{IdentToken}, []string{`null\0`}}, + {"\\", TTs{DelimToken}, []string{"\\"}}, + {"abc\\", TTs{IdentToken, DelimToken}, []string{"abc", "\\"}}, + {"#\\", TTs{DelimToken, DelimToken}, []string{"#", "\\"}}, + {"#abc\\", TTs{HashToken, DelimToken}, []string{"#abc", "\\"}}, + {"\"abc\\", TTs{StringToken}, []string{"\"abc\\"}}, // should officially not include backslash, but no biggie + {"url(abc\\", TTs{BadURLToken}, []string{"url(abc\\"}}, + {"\"a\x00b\"", TTs{StringToken}, []string{"\"a\x00b\""}}, + {"a\\\x00b", TTs{IdentToken}, []string{"a\\\x00b"}}, + {"url(a\x00b)", TTs{BadURLToken}, []string{"url(a\x00b)"}}, // null character cannot be unquoted + {"/*a\x00b*/", TTs{CommentToken}, []string{"/*a\x00b*/"}}, // coverage - {" \n\r\n\r\"\\\r\n\\\r\"", TTs{StringToken}}, - {"U+?????? U+ABCD?? U+ABC-DEF", TTs{UnicodeRangeToken, UnicodeRangeToken, UnicodeRangeToken}}, - {"U+? U+A?", TTs{IdentToken, DelimToken, DelimToken, IdentToken, DelimToken, IdentToken, DelimToken}}, - {"-5.23 -moz", TTs{NumberToken, IdentToken}}, - {"()", TTs{LeftParenthesisToken, RightParenthesisToken}}, - {"url( //url\n )", TTs{URLToken}}, - {"url( ", TTs{URLToken}}, - {"url( //url", TTs{URLToken}}, - {"url(\")a", TTs{URLToken}}, - {"url(a'\\\n)a", TTs{BadURLToken, IdentToken}}, - {"url(\"\n)a", TTs{BadURLToken, IdentToken}}, - {"url(a h)a", TTs{BadURLToken, IdentToken}}, - {"= 1.0.6~) + + -- Anthony Fok Fri, 21 Feb 2020 04:00:46 -0700 + +golang-github-tdewolff-parse (2.3.14-1) unstable; urgency=medium + + * New upstream version 2.3.14 + * debian/gbp.conf: Set debian-branch to debian/sid for DEP-14 conformance + * Add "Rules-Requires-Root: no" to debian/control + * Bump Standards-Version to 4.5.0 (no change) + * Update versioned dependency according to go.mod + + -- Anthony Fok Wed, 19 Feb 2020 03:19:04 -0700 + golang-github-tdewolff-parse (2.3.9-1) unstable; urgency=medium * New upstream version 2.3.9 diff -Nru golang-github-tdewolff-parse-2.3.9/debian/control golang-github-tdewolff-parse-2.4.2/debian/control --- golang-github-tdewolff-parse-2.3.9/debian/control 2019-10-08 22:03:35.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/debian/control 2020-02-21 10:58:44.000000000 +0000 @@ -7,18 +7,19 @@ Build-Depends: debhelper-compat (= 12), dh-golang, golang-any, - golang-github-tdewolff-test-dev (>= 1.0.0-2~) -Standards-Version: 4.4.1 + golang-github-tdewolff-test-dev (>= 1.0.6~) +Standards-Version: 4.5.0 Vcs-Browser: https://salsa.debian.org/go-team/packages/golang-github-tdewolff-parse Vcs-Git: https://salsa.debian.org/go-team/packages/golang-github-tdewolff-parse.git Homepage: https://github.com/tdewolff/parse +Rules-Requires-Root: no XS-Go-Import-Path: github.com/tdewolff/parse Package: golang-github-tdewolff-parse-dev Architecture: all Depends: ${shlibs:Depends}, ${misc:Depends}, - golang-github-tdewolff-test-dev (>= 1.0.0-2~) + golang-github-tdewolff-test-dev (>= 1.0.6~) Description: Go parsers for web formats This package contains several lexers and parsers written in Go. All subpackages are built to be streaming, high performance diff -Nru golang-github-tdewolff-parse-2.3.9/debian/gbp.conf golang-github-tdewolff-parse-2.4.2/debian/gbp.conf --- golang-github-tdewolff-parse-2.3.9/debian/gbp.conf 2018-12-20 14:28:01.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/debian/gbp.conf 2020-02-19 10:14:28.000000000 +0000 @@ -1,2 +1,4 @@ [DEFAULT] +debian-branch = debian/sid +dist = DEP14 pristine-tar = True diff -Nru golang-github-tdewolff-parse-2.3.9/error.go golang-github-tdewolff-parse-2.4.2/error.go --- golang-github-tdewolff-parse-2.3.9/error.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/error.go 2019-12-17 13:35:25.000000000 +0000 @@ -10,40 +10,39 @@ // Error is a parsing error returned by parser. It contains a message and an offset at which the error occurred. type Error struct { Message string - r io.Reader - Offset int - line int - column int - context string + Line int + Column int + Context string } // NewError creates a new error -func NewError(msg string, r io.Reader, offset int) *Error { +func NewError(r io.Reader, offset int, message string, a ...interface{}) *Error { + line, column, context := Position(r, offset) + if 0 < len(a) { + message = fmt.Sprintf(message, a...) + } return &Error{ - Message: msg, - r: r, - Offset: offset, + Message: message, + Line: line, + Column: column, + Context: context, } } // NewErrorLexer creates a new error from an active Lexer. -func NewErrorLexer(msg string, l *buffer.Lexer) *Error { +func NewErrorLexer(l *buffer.Lexer, message string, a ...interface{}) *Error { r := buffer.NewReader(l.Bytes()) offset := l.Offset() - return NewError(msg, r, offset) + return NewError(r, offset, message, a...) } -// Positions re-parses the file to determine the line, column, and context of the error. +// Positions returns the line, column, and context of the error. // Context is the entire line at which the error occurred. func (e *Error) Position() (int, int, string) { - if e.line == 0 { - e.line, e.column, e.context = Position(e.r, e.Offset) - } - return e.line, e.column, e.context + return e.Line, e.Column, e.Context } // Error returns the error string, containing the context and line + column number. func (e *Error) Error() string { - line, column, context := e.Position() - return fmt.Sprintf("parse error:%d:%d: %s\n%s", line, column, e.Message, context) + return fmt.Sprintf("%s on line %d and column %d\n%s", e.Message, e.Line, e.Column, e.Context) } diff -Nru golang-github-tdewolff-parse-2.3.9/error_test.go golang-github-tdewolff-parse-2.4.2/error_test.go --- golang-github-tdewolff-parse-2.3.9/error_test.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/error_test.go 2019-12-17 13:35:25.000000000 +0000 @@ -9,25 +9,30 @@ ) func TestError(t *testing.T) { - err := NewError("message", bytes.NewBufferString("buffer"), 3) + err := NewError(bytes.NewBufferString("buffer"), 3, "message") line, column, context := err.Position() test.T(t, line, 1, "line") test.T(t, column, 4, "column") test.T(t, "\n"+context, "\n 1: buffer\n ^", "context") - test.T(t, err.Error(), "parse error:1:4: message\n 1: buffer\n ^", "error") + test.T(t, err.Error(), "message on line 1 and column 4\n 1: buffer\n ^", "error") } func TestErrorLexer(t *testing.T) { l := buffer.NewLexer(bytes.NewBufferString("buffer")) l.Move(3) - err := NewErrorLexer("message", l) + err := NewErrorLexer(l, "message") line, column, context := err.Position() test.T(t, line, 1, "line") test.T(t, column, 4, "column") test.T(t, "\n"+context, "\n 1: buffer\n ^", "context") - test.T(t, err.Error(), "parse error:1:4: message\n 1: buffer\n ^", "error") + test.T(t, err.Error(), "message on line 1 and column 4\n 1: buffer\n ^", "error") +} + +func TestErrorMessages(t *testing.T) { + err := NewError(bytes.NewBufferString("buffer"), 3, "message %d", 5) + test.T(t, err.Error(), "message 5 on line 1 and column 4\n 1: buffer\n ^", "error") } diff -Nru golang-github-tdewolff-parse-2.3.9/go.mod golang-github-tdewolff-parse-2.4.2/go.mod --- golang-github-tdewolff-parse-2.3.9/go.mod 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/go.mod 2019-12-17 13:35:25.000000000 +0000 @@ -1,3 +1,5 @@ module github.com/tdewolff/parse/v2 -require github.com/tdewolff/test v1.0.0 +go 1.13 + +require github.com/tdewolff/test v1.0.6 diff -Nru golang-github-tdewolff-parse-2.3.9/go.sum golang-github-tdewolff-parse-2.4.2/go.sum --- golang-github-tdewolff-parse-2.3.9/go.sum 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/go.sum 2019-12-17 13:35:25.000000000 +0000 @@ -1,2 +1,2 @@ -github.com/tdewolff/test v1.0.0 h1:jOwzqCXr5ePXEPGJaq2ivoR6HOCi+D5TPfpoyg8yvmU= -github.com/tdewolff/test v1.0.0/go.mod h1:DiQUlutnqlEvdvhSn2LPGy4TFwRauAaYDsL+683RNX4= +github.com/tdewolff/test v1.0.6 h1:76mzYJQ83Op284kMT+63iCNCI7NEERsIN8dLM+RiKr4= +github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= diff -Nru golang-github-tdewolff-parse-2.3.9/html/hash.go golang-github-tdewolff-parse-2.4.2/html/hash.go --- golang-github-tdewolff-parse-2.3.9/html/hash.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/html/hash.go 2019-12-17 13:35:25.000000000 +0000 @@ -10,384 +10,239 @@ // Unique hash definitions to be used instead of strings const ( - A Hash = 0x1 // a - Abbr Hash = 0x6e104 // abbr - About Hash = 0x5 // about - Accept Hash = 0x7106 // accept - Accept_Charset Hash = 0x710e // accept-charset - Accesskey Hash = 0x8309 // accesskey - Acronym Hash = 0xed07 // acronym - Action Hash = 0x2bd06 // action - Address Hash = 0x6a407 // address - Align Hash = 0x2e05 // align - Alink Hash = 0x10405 // alink - Allowfullscreen Hash = 0x2350f // allowfullscreen - Alt Hash = 0x11d03 // alt - Annotation Hash = 0x20d0a // annotation - AnnotationXml Hash = 0x20d0d // annotationXml - Applet Hash = 0x16a06 // applet - Area Hash = 0x39504 // area - Article Hash = 0x43007 // article - Aside Hash = 0xa405 // aside - Async Hash = 0x12905 // async - Audio Hash = 0x14705 // audio - Autocomplete Hash = 0x1530c // autocomplete - Autofocus Hash = 0x15f09 // autofocus - Autoplay Hash = 0x17408 // autoplay - Axis Hash = 0x17c04 // axis - B Hash = 0x101 // b - Background Hash = 0x5d0a // background - Base Hash = 0x3cc04 // base - Basefont Hash = 0x3cc08 // basefont - Bdi Hash = 0xfd03 // bdi - Bdo Hash = 0x18503 // bdo - Bgcolor Hash = 0x19807 // bgcolor - Bgsound Hash = 0x1a707 // bgsound - Big Hash = 0x1ba03 // big - Blink Hash = 0x1bd05 // blink - Blockquote Hash = 0x1c20a // blockquote - Body Hash = 0x7f04 // body - Border Hash = 0x33b06 // border - Br Hash = 0x3402 // br - Button Hash = 0x1cc06 // button - Canvas Hash = 0xa006 // canvas - Caption Hash = 0x28207 // caption - Center Hash = 0x4e306 // center - Challenge Hash = 0x1ed09 // challenge - Charset Hash = 0x7807 // charset - Checked Hash = 0x37f07 // checked - Cite Hash = 0x12d04 // cite - Class Hash = 0x1d705 // class - Classid Hash = 0x1d707 // classid - Clear Hash = 0x43405 // clear - Code Hash = 0x1de04 // code - Codebase Hash = 0x3c808 // codebase - Codetype Hash = 0x1de08 // codetype - Col Hash = 0x19a03 // col - Colgroup Hash = 0x1f608 // colgroup - Color Hash = 0x19a05 // color - Cols Hash = 0x20804 // cols - Colspan Hash = 0x20807 // colspan - Command Hash = 0x21a07 // command - Compact Hash = 0x22107 // compact - Content Hash = 0x66e07 // content - Contenteditable Hash = 0x66e0f // contenteditable - Contextmenu Hash = 0x3df0b // contextmenu - Controls Hash = 0x22c08 // controls - Coords Hash = 0x25306 // coords - Crossorigin Hash = 0x25e0b // crossorigin - Data Hash = 0x4c104 // data - Datalist Hash = 0x4c108 // datalist - Datatype Hash = 0x4d808 // datatype - Datetime Hash = 0x2ed08 // datetime - Dd Hash = 0x31902 // dd - Declare Hash = 0xa707 // declare - Default Hash = 0x4a07 // default - DefaultChecked Hash = 0x50c0e // defaultChecked - DefaultMuted Hash = 0x56f0c // defaultMuted - DefaultSelected Hash = 0x4a0f // defaultSelected - Defer Hash = 0x5805 // defer - Del Hash = 0x9303 // del - Desc Hash = 0x9d04 // desc - Details Hash = 0xb307 // details - Dfn Hash = 0xcf03 // dfn - Dialog Hash = 0xfe06 // dialog - Dir Hash = 0xdb03 // dir - Dirname Hash = 0xdb07 // dirname - Disabled Hash = 0x10b08 // disabled - Div Hash = 0x11203 // div - Dl Hash = 0x13302 // dl - Download Hash = 0x49508 // download - Draggable Hash = 0x1ad09 // draggable - Dropzone Hash = 0x43b08 // dropzone - Dt Hash = 0x60802 // dt - Em Hash = 0xcb02 // em - Embed Hash = 0xcb05 // embed - Enabled Hash = 0x8d07 // enabled - Enctype Hash = 0x2d207 // enctype - Face Hash = 0x4e104 // face - Fieldset Hash = 0x62a08 // fieldset - Figcaption Hash = 0x27f0a // figcaption - Figure Hash = 0x29306 // figure - Font Hash = 0x3d004 // font - Footer Hash = 0x12006 // footer - For Hash = 0x29f03 // for - ForeignObject Hash = 0x29f0d // foreignObject - Foreignobject Hash = 0x2ac0d // foreignobject - Form Hash = 0x2b904 // form - Formaction Hash = 0x2b90a // formaction - Formenctype Hash = 0x2ce0b // formenctype - Formmethod Hash = 0x2d90a // formmethod - Formnovalidate Hash = 0x2e30e // formnovalidate - Formtarget Hash = 0x2f80a // formtarget - Frame Hash = 0xd305 // frame - Frameborder Hash = 0x3360b // frameborder - Frameset Hash = 0xd308 // frameset - H1 Hash = 0x19602 // h1 - H2 Hash = 0x32702 // h2 - H3 Hash = 0x34c02 // h3 - H4 Hash = 0x38e02 // h4 - H5 Hash = 0x60a02 // h5 - H6 Hash = 0x30202 // h6 - Head Hash = 0x37404 // head - Header Hash = 0x37406 // header - Headers Hash = 0x37407 // headers - Height Hash = 0x30406 // height - Hgroup Hash = 0x30c06 // hgroup - Hidden Hash = 0x31706 // hidden - High Hash = 0x32404 // high - Hr Hash = 0x13b02 // hr - Href Hash = 0x13b04 // href - Hreflang Hash = 0x13b08 // hreflang - Html Hash = 0x30804 // html - Http_Equiv Hash = 0x3290a // http-equiv - I Hash = 0xa01 // i - Icon Hash = 0x66d04 // icon - Id Hash = 0xa602 // id - Iframe Hash = 0x33506 // iframe - Image Hash = 0x34105 // image - Img Hash = 0x34603 // img - Inert Hash = 0x55a05 // inert - Inlist Hash = 0x26706 // inlist - Input Hash = 0x48205 // input - Ins Hash = 0x1b03 // ins - Isindex Hash = 0x17e07 // isindex - Ismap Hash = 0x34e05 // ismap - Itemid Hash = 0x12e06 // itemid - Itemprop Hash = 0x59208 // itemprop - Itemref Hash = 0x62407 // itemref - Itemscope Hash = 0x35809 // itemscope - Itemtype Hash = 0x36208 // itemtype - Kbd Hash = 0xfc03 // kbd - Keygen Hash = 0x8906 // keygen - Keytype Hash = 0x68d07 // keytype - Kind Hash = 0x10804 // kind - Label Hash = 0x9505 // label - Lang Hash = 0x13f04 // lang - Language Hash = 0x13f08 // language - Legend Hash = 0x1b406 // legend - Li Hash = 0x2f02 // li - Link Hash = 0x10504 // link - List Hash = 0x26904 // list - Listing Hash = 0x4c507 // listing - Longdesc Hash = 0x9908 // longdesc - Loop Hash = 0x13404 // loop - Low Hash = 0x23703 // low - Main Hash = 0x1904 // main - Malignmark Hash = 0xf30a // malignmark - Manifest Hash = 0x68308 // manifest - Map Hash = 0x16903 // map - Mark Hash = 0xf904 // mark - Marquee Hash = 0x36a07 // marquee - Math Hash = 0x37104 // math - Max Hash = 0x38603 // max - Maxlength Hash = 0x38609 // maxlength - Media Hash = 0xe005 // media - Mediagroup Hash = 0xe00a // mediagroup - Menu Hash = 0x3e604 // menu - Meta Hash = 0x4d404 // meta - Meter Hash = 0x2f305 // meter - Method Hash = 0x2dd06 // method - Mglyph Hash = 0x34706 // mglyph - Mi Hash = 0x6b02 // mi - Min Hash = 0x6b03 // min - Mn Hash = 0x2e602 // mn - Mo Hash = 0x4ff02 // mo - Ms Hash = 0x35b02 // ms - Mtext Hash = 0x39005 // mtext - Multiple Hash = 0x39e08 // multiple - Muted Hash = 0x3a605 // muted - Name Hash = 0xde04 // name - Nav Hash = 0x2b03 // nav - Nobr Hash = 0x3204 // nobr - Noembed Hash = 0xc907 // noembed - Noframes Hash = 0xd108 // noframes - Nohref Hash = 0x13906 // nohref - Noresize Hash = 0x24308 // noresize - Noscript Hash = 0x31c08 // noscript - Noshade Hash = 0x50707 // noshade - Novalidate Hash = 0x2e70a // novalidate - Nowrap Hash = 0x3ab06 // nowrap - Object Hash = 0x2b306 // object - Ol Hash = 0x19b02 // ol - Onabort Hash = 0x1d007 // onabort - Onafterprint Hash = 0x2870c // onafterprint - Onbeforeprint Hash = 0x2c10d // onbeforeprint - Onbeforeunload Hash = 0x6980e // onbeforeunload - Onblur Hash = 0xbe06 // onblur - Oncancel Hash = 0x14b08 // oncancel - Oncanplay Hash = 0x18709 // oncanplay - Oncanplaythrough Hash = 0x18710 // oncanplaythrough - Onchange Hash = 0x45108 // onchange - Onclick Hash = 0x6cb07 // onclick - Onclose Hash = 0x3b707 // onclose - Oncontextmenu Hash = 0x3dd0d // oncontextmenu - Oncuechange Hash = 0x3ea0b // oncuechange - Ondblclick Hash = 0x3f50a // ondblclick - Ondrag Hash = 0x3ff06 // ondrag - Ondragend Hash = 0x3ff09 // ondragend - Ondragenter Hash = 0x4080b // ondragenter - Ondragleave Hash = 0x4130b // ondragleave - Ondragover Hash = 0x41e0a // ondragover - Ondragstart Hash = 0x4280b // ondragstart - Ondrop Hash = 0x43906 // ondrop - Ondurationchange Hash = 0x44910 // ondurationchange - Onemptied Hash = 0x44009 // onemptied - Onended Hash = 0x45907 // onended - Onerror Hash = 0x46007 // onerror - Onfocus Hash = 0x46707 // onfocus - Onhashchange Hash = 0x4740c // onhashchange - Oninput Hash = 0x48007 // oninput - Oninvalid Hash = 0x48709 // oninvalid - Onkeydown Hash = 0x49009 // onkeydown - Onkeypress Hash = 0x49d0a // onkeypress - Onkeyup Hash = 0x4ac07 // onkeyup - Onload Hash = 0x4b906 // onload - Onloadeddata Hash = 0x4b90c // onloadeddata - Onloadedmetadata Hash = 0x4cc10 // onloadedmetadata - Onloadstart Hash = 0x4e90b // onloadstart - Onmessage Hash = 0x4f409 // onmessage - Onmousedown Hash = 0x4fd0b // onmousedown - Onmousemove Hash = 0x51a0b // onmousemove - Onmouseout Hash = 0x5250a // onmouseout - Onmouseover Hash = 0x52f0b // onmouseover - Onmouseup Hash = 0x53a09 // onmouseup - Onmousewheel Hash = 0x5480c // onmousewheel - Onoffline Hash = 0x55409 // onoffline - Ononline Hash = 0x55f08 // ononline - Onpagehide Hash = 0x5670a // onpagehide - Onpageshow Hash = 0x57b0a // onpageshow - Onpause Hash = 0x58707 // onpause - Onplay Hash = 0x59e06 // onplay - Onplaying Hash = 0x59e09 // onplaying - Onpopstate Hash = 0x5a70a // onpopstate - Onprogress Hash = 0x5b10a // onprogress - Onratechange Hash = 0x5c00c // onratechange - Onreset Hash = 0x5cc07 // onreset - Onresize Hash = 0x5d308 // onresize - Onscroll Hash = 0x5db08 // onscroll - Onseeked Hash = 0x5e608 // onseeked - Onseeking Hash = 0x5ee09 // onseeking - Onselect Hash = 0x5f708 // onselect - Onshow Hash = 0x60106 // onshow - Onstalled Hash = 0x60c09 // onstalled - Onstorage Hash = 0x61509 // onstorage - Onsubmit Hash = 0x61e08 // onsubmit - Onsuspend Hash = 0x63a09 // onsuspend - Ontimeupdate Hash = 0x3d10c // ontimeupdate - Onunload Hash = 0x64308 // onunload - Onvolumechange Hash = 0x64b0e // onvolumechange - Onwaiting Hash = 0x65909 // onwaiting - Open Hash = 0x13604 // open - Optgroup Hash = 0x66208 // optgroup - Optimum Hash = 0x67d07 // optimum - Option Hash = 0x69406 // option - Output Hash = 0x206 // output - P Hash = 0x501 // p - Param Hash = 0x1505 // param - Pattern Hash = 0x2507 // pattern - Pauseonexit Hash = 0x5890b // pauseonexit - Picture Hash = 0x3e07 // picture - Ping Hash = 0xe904 // ping - Placeholder Hash = 0x1fd0b // placeholder - Plaintext Hash = 0x26e09 // plaintext - Poster Hash = 0x31106 // poster - Pre Hash = 0x35203 // pre - Prefix Hash = 0x35206 // prefix - Preload Hash = 0x3b007 // preload - Profile Hash = 0x4b207 // profile - Progress Hash = 0x5b308 // progress - Prompt Hash = 0x54206 // prompt - Property Hash = 0x59608 // property - Public Hash = 0x66906 // public - Q Hash = 0xae01 // q - Radiogroup Hash = 0x350a // radiogroup - Rb Hash = 0x5c02 // rb - Readonly Hash = 0x39608 // readonly - Rel Hash = 0x3b103 // rel - Required Hash = 0xac08 // required - Resource Hash = 0x29708 // resource - Rev Hash = 0x4303 // rev - Reversed Hash = 0x4308 // reversed - Rows Hash = 0xc304 // rows - Rowspan Hash = 0xc307 // rowspan - Rp Hash = 0x28d02 // rp - Rt Hash = 0x1d502 // rt - Rtc Hash = 0x1d503 // rtc - Ruby Hash = 0x12504 // ruby - Rules Hash = 0x19e05 // rules - S Hash = 0x1201 // s - Samp Hash = 0x1204 // samp - Sandbox Hash = 0x1d07 // sandbox - Scope Hash = 0x35c05 // scope - Scoped Hash = 0x35c06 // scoped - Script Hash = 0x31e06 // script - Scrolling Hash = 0x5dd09 // scrolling - Seamless Hash = 0x3bc08 // seamless - Section Hash = 0xb907 // section - Select Hash = 0x5f906 // select - Selected Hash = 0x5f908 // selected - Shape Hash = 0x1a205 // shape - Size Hash = 0x24704 // size - Sizes Hash = 0x24705 // sizes - Small Hash = 0x23305 // small - Sortable Hash = 0x24b08 // sortable - Source Hash = 0x29906 // source - Spacer Hash = 0x25806 // spacer - Span Hash = 0xc604 // span - Spellcheck Hash = 0x37a0a // spellcheck - Src Hash = 0x3c303 // src - Srcdoc Hash = 0x3c306 // srcdoc - Srclang Hash = 0x46d07 // srclang - Srcset Hash = 0x4a606 // srcset - Start Hash = 0x42e05 // start - Step Hash = 0x26b04 // step - Strike Hash = 0x68906 // strike - Strong Hash = 0x5ba06 // strong - Style Hash = 0x6aa05 // style - Sub Hash = 0x62003 // sub - Summary Hash = 0x6af07 // summary - Sup Hash = 0x6b603 // sup - Svg Hash = 0x6b903 // svg - System Hash = 0x6bc06 // system - Tabindex Hash = 0x708 // tabindex - Table Hash = 0x24e05 // table - Target Hash = 0x2fc06 // target - Tbody Hash = 0x7e05 // tbody - Td Hash = 0xda02 // td - Template Hash = 0x6bf08 // template - Text Hash = 0x27304 // text - Textarea Hash = 0x39108 // textarea - Tfoot Hash = 0x11f05 // tfoot - Th Hash = 0x19002 // th - Thead Hash = 0x37305 // thead - Time Hash = 0x2f104 // time - Title Hash = 0x16f05 // title - Tr Hash = 0x22702 // tr - Track Hash = 0x22705 // track - Translate Hash = 0x27609 // translate - Truespeed Hash = 0x63109 // truespeed - Tt Hash = 0x2702 // tt - Type Hash = 0x11904 // type - Typemustmatch Hash = 0x1e20d // typemustmatch - Typeof Hash = 0x4dc06 // typeof - U Hash = 0x301 // u - Ul Hash = 0x4e02 // ul - Undeterminate Hash = 0x640d // undeterminate - Usemap Hash = 0x16606 // usemap - Valign Hash = 0x2d06 // valign - Value Hash = 0x11405 // value - Valuetype Hash = 0x11409 // valuetype - Var Hash = 0x33203 // var - Video Hash = 0x6c705 // video - Visible Hash = 0x6d207 // visible - Vlink Hash = 0x6d905 // vlink - Vocab Hash = 0x6de05 // vocab - Wbr Hash = 0x58403 // wbr - Width Hash = 0x60605 // width - Wrap Hash = 0x3ad04 // wrap - Xmlns Hash = 0xe05 // xmlns - Xmp Hash = 0x2303 // xmp + A Hash = 0x1 // a + Abbr Hash = 0x37a04 // abbr + About Hash = 0x5 // about + Accept Hash = 0x1106 // accept + Accept_Charset Hash = 0x110e // accept-charset + Action Hash = 0x23f06 // action + Address Hash = 0x5a07 // address + Align Hash = 0x32705 // align + Alink Hash = 0x7005 // alink + Allowfullscreen Hash = 0x2ad0f // allowfullscreen + Amp_Boilerplate Hash = 0x610f // amp-boilerplate + Area Hash = 0x1e304 // area + Article Hash = 0x2707 // article + Aside Hash = 0xb405 // aside + Async Hash = 0xac05 // async + Audio Hash = 0xd105 // audio + Autofocus Hash = 0xe409 // autofocus + Autoplay Hash = 0x10808 // autoplay + Axis Hash = 0x11004 // axis + B Hash = 0x101 // b + Background Hash = 0x300a // background + Base Hash = 0x19604 // base + Bb Hash = 0x37b02 // bb + Bdi Hash = 0x7503 // bdi + Bdo Hash = 0x31f03 // bdo + Bgcolor Hash = 0x12607 // bgcolor + Blockquote Hash = 0x13e0a // blockquote + Body Hash = 0xd04 // body + Br Hash = 0x37c02 // br + Button Hash = 0x14806 // button + Canvas Hash = 0xb006 // canvas + Caption Hash = 0x21f07 // caption + Charset Hash = 0x1807 // charset + Checked Hash = 0x1b307 // checked + Cite Hash = 0xfb04 // cite + Class Hash = 0x15905 // class + Classid Hash = 0x15907 // classid + Clear Hash = 0x2b05 // clear + Code Hash = 0x19204 // code + Codebase Hash = 0x19208 // codebase + Codetype Hash = 0x1a408 // codetype + Col Hash = 0x12803 // col + Colgroup Hash = 0x1bb08 // colgroup + Color Hash = 0x12805 // color + Cols Hash = 0x1cf04 // cols + Colspan Hash = 0x1cf07 // colspan + Compact Hash = 0x1ec07 // compact + Content Hash = 0x28407 // content + Controls Hash = 0x20108 // controls + Data Hash = 0x1f04 // data + Datalist Hash = 0x1f08 // datalist + Datatype Hash = 0x4d08 // datatype + Dd Hash = 0x5b02 // dd + Declare Hash = 0xb707 // declare + Default Hash = 0x7f07 // default + DefaultChecked Hash = 0x1730e // defaultChecked + DefaultMuted Hash = 0x7f0c // defaultMuted + DefaultSelected Hash = 0x8a0f // defaultSelected + Defer Hash = 0x9805 // defer + Del Hash = 0x10503 // del + Details Hash = 0x15f07 // details + Dfn Hash = 0x16c03 // dfn + Dialog Hash = 0xa606 // dialog + Dir Hash = 0x7603 // dir + Disabled Hash = 0x18008 // disabled + Div Hash = 0x18703 // div + Dl Hash = 0x1b902 // dl + Dt Hash = 0x23102 // dt + Em Hash = 0x4302 // em + Embed Hash = 0x4905 // embed + Enabled Hash = 0x26c07 // enabled + Enctype Hash = 0x1fa07 // enctype + Face Hash = 0x5604 // face + Fieldset Hash = 0x21408 // fieldset + Figcaption Hash = 0x21c0a // figcaption + Figure Hash = 0x22606 // figure + Footer Hash = 0xdb06 // footer + For Hash = 0x23b03 // for + Form Hash = 0x23b04 // form + Formaction Hash = 0x23b0a // formaction + Formnovalidate Hash = 0x2450e // formnovalidate + Frame Hash = 0x28c05 // frame + Frameborder Hash = 0x28c0b // frameborder + H1 Hash = 0x2e002 // h1 + H2 Hash = 0x25302 // h2 + H3 Hash = 0x25502 // h3 + H4 Hash = 0x25702 // h4 + H5 Hash = 0x25902 // h5 + H6 Hash = 0x25b02 // h6 + Head Hash = 0x2d204 // head + Header Hash = 0x2d206 // header + Hgroup Hash = 0x25d06 // hgroup + Hidden Hash = 0x26806 // hidden + Hr Hash = 0x32d02 // hr + Href Hash = 0x32d04 // href + Hreflang Hash = 0x32d08 // hreflang + Html Hash = 0x27304 // html + Http_Equiv Hash = 0x2770a // http-equiv + I Hash = 0x2401 // i + Icon Hash = 0x28304 // icon + Id Hash = 0xb602 // id + Iframe Hash = 0x28b06 // iframe + Img Hash = 0x29703 // img + Inert Hash = 0xf605 // inert + Inlist Hash = 0x29a06 // inlist + Input Hash = 0x2a405 // input + Ins Hash = 0x2a903 // ins + Ismap Hash = 0x11205 // ismap + Itemscope Hash = 0xfc09 // itemscope + Kbd Hash = 0x7403 // kbd + Keygen Hash = 0x1f606 // keygen + Label Hash = 0xbe05 // label + Lang Hash = 0x33104 // lang + Language Hash = 0x33108 // language + Legend Hash = 0x2c506 // legend + Li Hash = 0x2302 // li + Link Hash = 0x7104 // link + Longdesc Hash = 0xc208 // longdesc + Main Hash = 0xf404 // main + Manifest Hash = 0x2bc08 // manifest + Map Hash = 0xee03 // map + Mark Hash = 0x2cb04 // mark + Math Hash = 0x2cf04 // math + Max Hash = 0x2d803 // max + Maxlength Hash = 0x2d809 // maxlength + Media Hash = 0xa405 // media + Menu Hash = 0x12204 // menu + Meta Hash = 0x2e204 // meta + Meter Hash = 0x2f705 // meter + Method Hash = 0x2fc06 // method + Multiple Hash = 0x30208 // multiple + Muted Hash = 0x30a05 // muted + Name Hash = 0xa204 // name + Nav Hash = 0x32403 // nav + Nohref Hash = 0x32b06 // nohref + Noresize Hash = 0x13608 // noresize + Noscript Hash = 0x14d08 // noscript + Noshade Hash = 0x16e07 // noshade + Novalidate Hash = 0x2490a // novalidate + Nowrap Hash = 0x1d506 // nowrap + Object Hash = 0xd506 // object + Ol Hash = 0xcb02 // ol + Open Hash = 0x32104 // open + Optgroup Hash = 0x35608 // optgroup + Option Hash = 0x30f06 // option + Output Hash = 0x206 // output + P Hash = 0x501 // p + Param Hash = 0xf005 // param + Pauseonexit Hash = 0x1160b // pauseonexit + Picture Hash = 0x1c207 // picture + Plaintext Hash = 0x1da09 // plaintext + Poster Hash = 0x26206 // poster + Pre Hash = 0x35d03 // pre + Prefix Hash = 0x35d06 // prefix + Profile Hash = 0x36407 // profile + Progress Hash = 0x34208 // progress + Property Hash = 0x31508 // property + Q Hash = 0x14301 // q + Rb Hash = 0x2f02 // rb + Readonly Hash = 0x1e408 // readonly + Rel Hash = 0xbc03 // rel + Required Hash = 0x22a08 // required + Resource Hash = 0x1c708 // resource + Rev Hash = 0x7803 // rev + Reversed Hash = 0x7808 // reversed + Rows Hash = 0x9c04 // rows + Rowspan Hash = 0x9c07 // rowspan + Rp Hash = 0x6a02 // rp + Rt Hash = 0x2802 // rt + Rtc Hash = 0xf903 // rtc + Ruby Hash = 0xe004 // ruby + Rules Hash = 0x12c05 // rules + S Hash = 0x1c01 // s + Samp Hash = 0x6004 // samp + Scope Hash = 0x10005 // scope + Scoped Hash = 0x10006 // scoped + Script Hash = 0x14f06 // script + Scrolling Hash = 0xc809 // scrolling + Seamless Hash = 0x19808 // seamless + Section Hash = 0x13007 // section + Select Hash = 0x16506 // select + Selected Hash = 0x16508 // selected + Shape Hash = 0x19f05 // shape + Size Hash = 0x13a04 // size + Slot Hash = 0x20804 // slot + Small Hash = 0x2ab05 // small + Sortable Hash = 0x2ef08 // sortable + Source Hash = 0x1c906 // source + Span Hash = 0x9f04 // span + Src Hash = 0x34903 // src + Srcset Hash = 0x34906 // srcset + Start Hash = 0x2505 // start + Strong Hash = 0x29e06 // strong + Style Hash = 0x2c205 // style + Sub Hash = 0x31d03 // sub + Summary Hash = 0x33907 // summary + Sup Hash = 0x34003 // sup + Svg Hash = 0x34f03 // svg + Tabindex Hash = 0x2e408 // tabindex + Table Hash = 0x2f205 // table + Target Hash = 0x706 // target + Tbody Hash = 0xc05 // tbody + Td Hash = 0x1e02 // td + Template Hash = 0x4208 // template + Text Hash = 0x1df04 // text + Textarea Hash = 0x1df08 // textarea + Tfoot Hash = 0xda05 // tfoot + Th Hash = 0x2d102 // th + Thead Hash = 0x2d105 // thead + Time Hash = 0x12004 // time + Title Hash = 0x15405 // title + Tr Hash = 0x1f202 // tr + Track Hash = 0x1f205 // track + Translate Hash = 0x20b09 // translate + Truespeed Hash = 0x23209 // truespeed + Type Hash = 0x5104 // type + Typemustmatch Hash = 0x1a80d // typemustmatch + Typeof Hash = 0x5106 // typeof + U Hash = 0x301 // u + Ul Hash = 0x8302 // ul + Undeterminate Hash = 0x370d // undeterminate + Usemap Hash = 0xeb06 // usemap + Valign Hash = 0x32606 // valign + Value Hash = 0x18905 // value + Valuetype Hash = 0x18909 // valuetype + Var Hash = 0x28003 // var + Video Hash = 0x35205 // video + Visible Hash = 0x36b07 // visible + Vlink Hash = 0x37205 // vlink + Vocab Hash = 0x37705 // vocab + Wbr Hash = 0x37e03 // wbr + Xmlns Hash = 0x2eb05 // xmlns + Xmp Hash = 0x36203 // xmp ) // String returns the hash' name. @@ -434,415 +289,255 @@ } const _Hash_hash0 = 0x9acb0442 -const _Hash_maxLen = 16 -const _Hash_text = "aboutputabindexmlnsamparamainsandboxmpatternavalignobradiogr" + - "oupictureversedefaultSelectedeferbackgroundeterminateaccept-" + - "charsetbodyaccesskeygenabledelabelongdescanvasideclarequired" + - "etailsectionblurowspanoembedfnoframesetdirnamediagroupingacr" + - "onymalignmarkbdialogalinkindisabledivaluetypealtfooterubyasy" + - "ncitemidloopenohreflanguageaudioncancelautocompleteautofocus" + - "emappletitleautoplayaxisindexbdoncanplaythrough1bgcolorulesh" + - "apebgsoundraggablegendbigblinkblockquotebuttonabortclassidco" + - "detypemustmatchallengecolgrouplaceholdercolspannotationXmlco" + - "mmandcompactrackcontrolsmallowfullscreenoresizesortablecoord" + - "spacercrossoriginlisteplaintextranslatefigcaptionafterprintf" + - "iguresourceforeignObjectforeignobjectformactionbeforeprintfo" + - "rmenctypeformmethodformnovalidatetimeterformtargeth6heightml" + - "hgrouposterhiddenoscripthigh2http-equivariframeborderimageim" + - "glyph3ismaprefixitemscopeditemtypemarqueematheaderspellcheck" + - "edmaxlength4mtextareadonlymultiplemutednowrapreloadoncloseam" + - "lessrcdocodebasefontimeupdateoncontextmenuoncuechangeondblcl" + - "ickondragendondragenterondragleaveondragoverondragstarticlea" + - "rondropzonemptiedondurationchangeonendedonerroronfocusrclang" + - "onhashchangeoninputoninvalidonkeydownloadonkeypressrcsetonke" + - "yuprofileonloadeddatalistingonloadedmetadatatypeofacenteronl" + - "oadstartonmessageonmousedownoshadefaultCheckedonmousemoveonm" + - "ouseoutonmouseoveronmouseupromptonmousewheelonofflinertononl" + - "ineonpagehidefaultMutedonpageshowbronpauseonexitempropertyon" + - "playingonpopstateonprogresstrongonratechangeonresetonresizeo" + - "nscrollingonseekedonseekingonselectedonshowidth5onstalledons" + - "torageonsubmitemrefieldsetruespeedonsuspendonunloadonvolumec" + - "hangeonwaitingoptgroupublicontenteditableoptimumanifestrikey" + - "typeoptionbeforeunloaddresstylesummarysupsvgsystemplatevideo" + - "nclickvisiblevlinkvocabbr" +const _Hash_maxLen = 15 +const _Hash_text = "aboutputargetbodyaccept-charsetdatalistarticlearbackgroundet" + + "erminatemplatembedatatypeofaceaddressamp-boilerplatealinkbdi" + + "reversedefaultMutedefaultSelectedeferowspanamedialogasyncanv" + + "asideclarelabelongdescrollingaudiobjectfooterubyautofocusema" + + "paramainertcitemscopedelautoplayaxismapauseonexitimenubgcolo" + + "rulesectionoresizeblockquotebuttonoscriptitleclassidetailsel" + + "ectedfnoshadefaultCheckedisabledivaluetypecodebaseamlesshape" + + "codetypemustmatcheckedlcolgroupicturesourcecolspanowraplaint" + + "extareadonlycompactrackeygenctypecontrolslotranslatefieldset" + + "figcaptionfigurequiredtruespeedformactionformnovalidateh2h3h" + + "4h5h6hgrouposterhiddenabledhtmlhttp-equivaricontentiframebor" + + "derimginlistronginputinsmallowfullscreenmanifestylegendmarkm" + + "atheadermaxlength1metabindexmlnsortablemetermethodmultiplemu" + + "tedoptionpropertysubdopenavalignohreflanguagesummarysuprogre" + + "ssrcsetsvgvideoptgrouprefixmprofilevisiblevlinkvocabbrwbr" -var _Hash_table = [1 << 10]Hash{ - 0x4: 0x13b02, // hr - 0x8: 0x3e07, // picture - 0x9: 0x48007, // oninput - 0xb: 0x11405, // value - 0xf: 0x708, // tabindex - 0x12: 0x2870c, // onafterprint - 0x18: 0x1e20d, // typemustmatch - 0x1a: 0x13302, // dl - 0x1b: 0x67d07, // optimum - 0x1e: 0x38e02, // h4 - 0x21: 0x5ee09, // onseeking - 0x22: 0x11f05, // tfoot - 0x23: 0x66e0f, // contenteditable - 0x24: 0x6bf08, // template - 0x29: 0x63a09, // onsuspend - 0x2b: 0x51a0b, // onmousemove - 0x30: 0x2bd06, // action - 0x33: 0xd305, // frame - 0x35: 0x19e05, // rules - 0x38: 0x18503, // bdo - 0x39: 0x3ab06, // nowrap - 0x3e: 0x62a08, // fieldset - 0x47: 0xf30a, // malignmark - 0x49: 0x44009, // onemptied - 0x4c: 0x46d07, // srclang - 0x4e: 0x3c306, // srcdoc - 0x4f: 0xa602, // id - 0x50: 0x64308, // onunload - 0x51: 0x30c06, // hgroup - 0x55: 0x19a05, // color - 0x56: 0x35c05, // scope - 0x59: 0x640d, // undeterminate - 0x5b: 0x37406, // header - 0x5c: 0xa405, // aside - 0x5d: 0x2f80a, // formtarget - 0x60: 0xe05, // xmlns - 0x61: 0x19b02, // ol - 0x63: 0x9d04, // desc - 0x65: 0x26e09, // plaintext - 0x66: 0x3ad04, // wrap - 0x67: 0x17c04, // axis - 0x68: 0x19a03, // col - 0x69: 0x2d06, // valign - 0x70: 0x65909, // onwaiting - 0x71: 0x31706, // hidden - 0x75: 0x41e0a, // ondragover - 0x78: 0x29f0d, // foreignObject - 0x7a: 0x32404, // high - 0x7b: 0xf904, // mark - 0x88: 0x68906, // strike - 0x8f: 0x13b08, // hreflang - 0x91: 0xd308, // frameset - 0x92: 0x4c507, // listing - 0x93: 0x37f07, // checked - 0x94: 0x34c02, // h3 - 0x95: 0x5805, // defer - 0x96: 0x6c705, // video - 0x97: 0xae01, // q - 0x9a: 0x25806, // spacer - 0x9c: 0x55f08, // ononline - 0x9d: 0x64b0e, // onvolumechange - 0x9f: 0x4b207, // profile - 0xa0: 0x34e05, // ismap - 0xa3: 0x2f305, // meter - 0xa8: 0x1de04, // code - 0xab: 0x18710, // oncanplaythrough - 0xae: 0x62407, // itemref - 0xaf: 0x59e09, // onplaying - 0xb5: 0x43b08, // dropzone - 0xb9: 0x2f02, // li - 0xbb: 0x15f09, // autofocus - 0xbd: 0x5480c, // onmousewheel - 0xc1: 0x26904, // list - 0xc2: 0x2702, // tt - 0xc7: 0x4e306, // center - 0xc9: 0x45907, // onended - 0xcb: 0x35203, // pre - 0xcc: 0x7106, // accept - 0xcf: 0x4e90b, // onloadstart - 0xd1: 0x36208, // itemtype - 0xd3: 0x3d004, // font - 0xd4: 0x1a707, // bgsound - 0xd5: 0x5ba06, // strong - 0xd6: 0x4ff02, // mo - 0xd7: 0x1de08, // codetype - 0xdb: 0x4280b, // ondragstart - 0xdf: 0x1a205, // shape - 0xe3: 0x2f104, // time - 0xe9: 0x27304, // text - 0xea: 0x6b903, // svg - 0xf2: 0xc907, // noembed - 0xf3: 0x4dc06, // typeof - 0xf5: 0x60c09, // onstalled - 0xf6: 0xa006, // canvas - 0xf8: 0x9505, // label - 0xf9: 0x3b103, // rel - 0xfb: 0x4c104, // data - 0xfd: 0x1204, // samp - 0x101: 0x5c00c, // onratechange - 0x103: 0x46007, // onerror - 0x105: 0x3dd0d, // oncontextmenu - 0x106: 0x16a06, // applet - 0x108: 0x350a, // radiogroup - 0x109: 0xde04, // name - 0x10a: 0x1cc06, // button - 0x10b: 0x43405, // clear - 0x10e: 0x6af07, // summary - 0x10f: 0x4d404, // meta - 0x110: 0x54206, // prompt - 0x113: 0x53a09, // onmouseup - 0x116: 0x5e608, // onseeked - 0x11a: 0xe904, // ping - 0x11c: 0x35809, // itemscope - 0x11e: 0x14b08, // oncancel - 0x11f: 0x2dd06, // method - 0x120: 0x20d0d, // annotationXml - 0x123: 0x8309, // accesskey - 0x124: 0x6d207, // visible - 0x127: 0xc304, // rows - 0x135: 0x11203, // div - 0x136: 0x3d10c, // ontimeupdate - 0x137: 0x59608, // property - 0x139: 0x3ff06, // ondrag - 0x13a: 0xcf03, // dfn - 0x13e: 0x6aa05, // style - 0x13f: 0x1530c, // autocomplete - 0x141: 0x3204, // nobr - 0x142: 0x4f409, // onmessage - 0x144: 0x25e0b, // crossorigin - 0x148: 0x61509, // onstorage - 0x149: 0x34603, // img - 0x14a: 0x5cc07, // onreset - 0x14b: 0x2303, // xmp - 0x14e: 0x4c108, // datalist - 0x153: 0x61e08, // onsubmit - 0x155: 0x12006, // footer - 0x15f: 0x2e70a, // novalidate - 0x162: 0x43906, // ondrop - 0x166: 0x39005, // mtext - 0x168: 0x24705, // sizes - 0x16c: 0x28207, // caption - 0x16e: 0x16f05, // title - 0x173: 0x1ed09, // challenge - 0x176: 0x24b08, // sortable - 0x178: 0x23703, // low - 0x17a: 0x12504, // ruby - 0x17b: 0x9303, // del - 0x17c: 0x1d707, // classid - 0x17d: 0xfc03, // kbd - 0x17f: 0x2ed08, // datetime - 0x181: 0x68d07, // keytype - 0x182: 0xc604, // span - 0x183: 0x21a07, // command - 0x18b: 0x1b406, // legend - 0x18c: 0xe005, // media - 0x18d: 0x3c808, // codebase - 0x198: 0x31106, // poster - 0x199: 0x2ac0d, // foreignobject - 0x19d: 0x6de05, // vocab - 0x1a0: 0x28d02, // rp - 0x1a4: 0x1d502, // rt - 0x1a8: 0x4308, // reversed - 0x1aa: 0x13604, // open - 0x1ab: 0x6bc06, // system - 0x1ac: 0x37404, // head - 0x1ad: 0x10405, // alink - 0x1af: 0x33203, // var - 0x1b0: 0xb307, // details - 0x1b1: 0x60a02, // h5 - 0x1b3: 0xda02, // td - 0x1b4: 0xa707, // declare - 0x1ba: 0x10b08, // disabled - 0x1be: 0xac08, // required - 0x1c3: 0x6d905, // vlink - 0x1c4: 0x52f0b, // onmouseover - 0x1c5: 0x3290a, // http-equiv - 0x1cc: 0x14705, // audio - 0x1d1: 0x12d04, // cite - 0x1d5: 0xe00a, // mediagroup - 0x1d6: 0x3a605, // muted - 0x1da: 0x42e05, // start - 0x1de: 0x19002, // th - 0x1df: 0x17408, // autoplay +var _Hash_table = [1 << 9]Hash{ + 0x0: 0x1df08, // textarea + 0x4: 0x32d02, // hr + 0x8: 0x1c207, // picture + 0xb: 0x18905, // value + 0xf: 0x2e408, // tabindex + 0x12: 0x15905, // class + 0x15: 0x37e03, // wbr + 0x18: 0x1a80d, // typemustmatch + 0x1a: 0x1b902, // dl + 0x1d: 0xf903, // rtc + 0x1e: 0x25702, // h4 + 0x22: 0x2ef08, // sortable + 0x24: 0x4208, // template + 0x25: 0x28c0b, // frameborder + 0x28: 0x37a04, // abbr + 0x29: 0x28b06, // iframe + 0x2a: 0x610f, // amp-boilerplate + 0x2c: 0x1e408, // readonly + 0x30: 0x23f06, // action + 0x33: 0x28c05, // frame + 0x35: 0x12c05, // rules + 0x36: 0x30208, // multiple + 0x38: 0x31f03, // bdo + 0x39: 0x1d506, // nowrap + 0x3e: 0x21408, // fieldset + 0x3f: 0x7503, // bdi + 0x46: 0x7f0c, // defaultMuted + 0x49: 0x35205, // video + 0x4c: 0x19808, // seamless + 0x4d: 0x13608, // noresize + 0x4f: 0xb602, // id + 0x51: 0x25d06, // hgroup + 0x52: 0x23102, // dt + 0x55: 0x12805, // color + 0x56: 0x34003, // sup + 0x59: 0x370d, // undeterminate + 0x5a: 0x35608, // optgroup + 0x5b: 0x2d206, // header + 0x5c: 0xb405, // aside + 0x5f: 0x10005, // scope + 0x60: 0x101, // b + 0x61: 0xcb02, // ol + 0x64: 0x32b06, // nohref + 0x65: 0x1da09, // plaintext + 0x66: 0x20804, // slot + 0x67: 0x11004, // axis + 0x68: 0x12803, // col + 0x69: 0x32606, // valign + 0x6c: 0x2d105, // thead + 0x70: 0x34906, // srcset + 0x71: 0x26806, // hidden + 0x76: 0x1bb08, // colgroup + 0x78: 0x34f03, // svg + 0x7b: 0x2cb04, // mark + 0x7e: 0x33104, // lang + 0x81: 0x1cf04, // cols + 0x86: 0x5a07, // address + 0x8b: 0xf404, // main + 0x8c: 0x4302, // em + 0x8f: 0x32d08, // hreflang + 0x93: 0x1b307, // checked + 0x94: 0x25902, // h5 + 0x95: 0x301, // u + 0x96: 0x32705, // align + 0x97: 0x14301, // q + 0x99: 0xd506, // object + 0x9b: 0x28407, // content + 0x9d: 0xc809, // scrolling + 0x9f: 0x36407, // profile + 0xa0: 0x34903, // src + 0xa1: 0xda05, // tfoot + 0xa3: 0x2f705, // meter + 0xa4: 0x37705, // vocab + 0xa6: 0xd04, // body + 0xa8: 0x19204, // code + 0xac: 0x20108, // controls + 0xb0: 0x2ab05, // small + 0xb1: 0x18008, // disabled + 0xb5: 0x5604, // face + 0xb6: 0x501, // p + 0xb9: 0x2302, // li + 0xbb: 0xe409, // autofocus + 0xbf: 0x27304, // html + 0xc2: 0x4d08, // datatype + 0xc6: 0x35d06, // prefix + 0xcb: 0x35d03, // pre + 0xcc: 0x1106, // accept + 0xd1: 0x23b03, // for + 0xd5: 0x29e06, // strong + 0xd6: 0x9c07, // rowspan + 0xd7: 0x25502, // h3 + 0xd8: 0x2cf04, // math + 0xde: 0x16e07, // noshade + 0xdf: 0x19f05, // shape + 0xe1: 0x10006, // scoped + 0xe3: 0x706, // target + 0xe6: 0x21c0a, // figcaption + 0xe9: 0x1df04, // text + 0xea: 0x1c708, // resource + 0xec: 0xee03, // map + 0xf0: 0x29a06, // inlist + 0xf1: 0x16506, // select + 0xf2: 0x1f606, // keygen + 0xf3: 0x5106, // typeof + 0xf6: 0xb006, // canvas + 0xf7: 0x30f06, // option + 0xf8: 0xbe05, // label + 0xf9: 0xbc03, // rel + 0xfb: 0x1f04, // data + 0xfd: 0x6004, // samp + 0x100: 0x110e, // accept-charset + 0x101: 0xeb06, // usemap + 0x103: 0x2bc08, // manifest + 0x109: 0xa204, // name + 0x10a: 0x14806, // button + 0x10b: 0x2b05, // clear + 0x10e: 0x33907, // summary + 0x10f: 0x2e204, // meta + 0x110: 0x33108, // language + 0x112: 0x300a, // background + 0x113: 0x2707, // article + 0x116: 0x23b0a, // formaction + 0x119: 0x1, // a + 0x11b: 0x5, // about + 0x11c: 0xfc09, // itemscope + 0x11e: 0x14d08, // noscript + 0x11f: 0x15907, // classid + 0x120: 0x36203, // xmp + 0x121: 0x19604, // base + 0x123: 0x1c01, // s + 0x124: 0x36b07, // visible + 0x126: 0x37b02, // bb + 0x127: 0x9c04, // rows + 0x12d: 0x2450e, // formnovalidate + 0x131: 0x1f205, // track + 0x135: 0x18703, // div + 0x136: 0xac05, // async + 0x137: 0x31508, // property + 0x13a: 0x16c03, // dfn + 0x13e: 0xf605, // inert + 0x142: 0x10503, // del + 0x144: 0x25302, // h2 + 0x147: 0x2c205, // style + 0x149: 0x29703, // img + 0x14a: 0xc05, // tbody + 0x14b: 0x7603, // dir + 0x14c: 0x2eb05, // xmlns + 0x14e: 0x1f08, // datalist + 0x14f: 0x32d04, // href + 0x150: 0x1f202, // tr + 0x151: 0x13e0a, // blockquote + 0x152: 0x18909, // valuetype + 0x155: 0xdb06, // footer + 0x157: 0x14f06, // script + 0x158: 0x1cf07, // colspan + 0x15d: 0x1730e, // defaultChecked + 0x15f: 0x2490a, // novalidate + 0x164: 0x1a408, // codetype + 0x165: 0x2c506, // legend + 0x16b: 0x1160b, // pauseonexit + 0x16c: 0x21f07, // caption + 0x16f: 0x26c07, // enabled + 0x173: 0x26206, // poster + 0x175: 0x30a05, // muted + 0x176: 0x11205, // ismap + 0x178: 0x2a903, // ins + 0x17a: 0xe004, // ruby + 0x17b: 0x37c02, // br + 0x17c: 0x8a0f, // defaultSelected + 0x17d: 0x7403, // kbd + 0x17f: 0x1c906, // source + 0x182: 0x9f04, // span + 0x184: 0x2d803, // max + 0x18a: 0x5b02, // dd + 0x18b: 0x13a04, // size + 0x18c: 0xa405, // media + 0x18d: 0x19208, // codebase + 0x18f: 0x4905, // embed + 0x192: 0x5104, // type + 0x193: 0xf005, // param + 0x194: 0x25b02, // h6 + 0x197: 0x28304, // icon + 0x198: 0x12607, // bgcolor + 0x199: 0x2ad0f, // allowfullscreen + 0x19a: 0x12004, // time + 0x19b: 0x7803, // rev + 0x19d: 0x34208, // progress + 0x19e: 0x22606, // figure + 0x1a0: 0x6a02, // rp + 0x1a2: 0xa606, // dialog + 0x1a4: 0x2802, // rt + 0x1a7: 0x1e304, // area + 0x1a8: 0x7808, // reversed + 0x1aa: 0x32104, // open + 0x1ac: 0x2d204, // head + 0x1ad: 0x7005, // alink + 0x1af: 0x28003, // var + 0x1b0: 0x15f07, // details + 0x1b1: 0x2401, // i + 0x1b3: 0x1e02, // td + 0x1b4: 0xb707, // declare + 0x1b5: 0x8302, // ul + 0x1ba: 0x2fc06, // method + 0x1bd: 0x13007, // section + 0x1be: 0x22a08, // required + 0x1c2: 0x9805, // defer + 0x1c3: 0x37205, // vlink + 0x1c4: 0x15405, // title + 0x1c5: 0x2770a, // http-equiv + 0x1c6: 0x1fa07, // enctype + 0x1c7: 0x1ec07, // compact + 0x1c8: 0x2d809, // maxlength + 0x1c9: 0x16508, // selected + 0x1cc: 0xd105, // audio + 0x1cd: 0xc208, // longdesc + 0x1d1: 0xfb04, // cite + 0x1da: 0x2505, // start + 0x1de: 0x2d102, // th + 0x1df: 0x10808, // autoplay + 0x1e2: 0x7104, // link 0x1e3: 0x206, // output - 0x1e4: 0x59208, // itemprop - 0x1e5: 0x3e604, // menu - 0x1eb: 0x2b03, // nav - 0x1ec: 0x6b603, // sup - 0x1ed: 0x46707, // onfocus - 0x1ee: 0x7807, // charset - 0x1ef: 0x29f03, // for - 0x1f1: 0x13404, // loop - 0x1f3: 0x24e05, // table - 0x1f5: 0x3f50a, // ondblclick - 0x1f6: 0x5c02, // rb - 0x1f8: 0x33b06, // border - 0x1fb: 0x27609, // translate - 0x200: 0x39108, // textarea - 0x208: 0x2507, // pattern - 0x210: 0x1bd05, // blink - 0x212: 0x1d705, // class - 0x219: 0x4b90c, // onloadeddata - 0x21a: 0x60106, // onshow - 0x21b: 0x6cb07, // onclick - 0x21d: 0x1d503, // rtc - 0x225: 0x3360b, // frameborder - 0x22a: 0x6a407, // address - 0x22c: 0x39608, // readonly - 0x22f: 0x12905, // async - 0x233: 0x710e, // accept-charset - 0x238: 0x43007, // article - 0x23b: 0x5f708, // onselect - 0x23f: 0xfd03, // bdi - 0x241: 0x11d03, // alt - 0x242: 0x55409, // onoffline - 0x246: 0x56f0c, // defaultMuted - 0x247: 0x34105, // image - 0x249: 0x31e06, // script - 0x24d: 0x24308, // noresize - 0x252: 0x60802, // dt - 0x253: 0x2c10d, // onbeforeprint - 0x255: 0x3bc08, // seamless - 0x256: 0x3402, // br - 0x257: 0x1d007, // onabort - 0x25a: 0x66208, // optgroup - 0x260: 0x101, // b - 0x262: 0x5db08, // onscroll - 0x264: 0x13906, // nohref - 0x266: 0x7e05, // tbody - 0x269: 0x2e602, // mn - 0x26c: 0x37305, // thead - 0x270: 0x4a606, // srcset - 0x271: 0x63109, // truespeed - 0x273: 0xed07, // acronym - 0x27e: 0x13f04, // lang - 0x281: 0x20804, // cols - 0x285: 0x29906, // source - 0x28a: 0x35b02, // ms - 0x28b: 0x1904, // main - 0x28c: 0xcb02, // em - 0x28f: 0x66d04, // icon - 0x292: 0x49508, // download - 0x293: 0x11409, // valuetype - 0x295: 0x301, // u - 0x296: 0x2e05, // align - 0x297: 0x1201, // s - 0x299: 0x2b306, // object - 0x29a: 0x59e06, // onplay - 0x29b: 0x4e104, // face - 0x29d: 0x5dd09, // scrolling - 0x29e: 0x3ff09, // ondragend - 0x2a0: 0x3c303, // src - 0x2a2: 0x36a07, // marquee - 0x2a6: 0x7f04, // body - 0x2a9: 0x3df0b, // contextmenu - 0x2ac: 0x22c08, // controls - 0x2b0: 0x23305, // small - 0x2b6: 0x2350f, // allowfullscreen - 0x2b9: 0x3b007, // preload - 0x2bb: 0x66e07, // content - 0x2bf: 0x30804, // html - 0x2c1: 0x49d0a, // onkeypress - 0x2c2: 0xdb07, // dirname - 0x2c6: 0x35206, // prefix - 0x2cd: 0x18709, // oncanplay - 0x2d1: 0x6e104, // abbr - 0x2d3: 0x60605, // width - 0x2d6: 0x6b03, // min - 0x2d8: 0x37104, // math - 0x2da: 0x48709, // oninvalid - 0x2dd: 0x2d90a, // formmethod - 0x2de: 0x50707, // noshade - 0x2df: 0x58403, // wbr - 0x2e1: 0x35c06, // scoped - 0x2e2: 0x5250a, // onmouseout - 0x2e3: 0x2fc06, // target - 0x2e4: 0x5670a, // onpagehide - 0x2e6: 0x24704, // size - 0x2e9: 0x8906, // keygen - 0x2ea: 0x29708, // resource - 0x2ec: 0x16903, // map - 0x2ee: 0x5b308, // progress - 0x2f0: 0x26706, // inlist - 0x2f2: 0x3ea0b, // oncuechange - 0x2f7: 0x69406, // option - 0x2f8: 0x37407, // headers - 0x2fb: 0x31c08, // noscript - 0x2fd: 0x34706, // mglyph - 0x301: 0x16606, // usemap - 0x303: 0x68308, // manifest - 0x30a: 0x17e07, // isindex - 0x30b: 0x1f608, // colgroup - 0x312: 0x5d0a, // background - 0x314: 0x10804, // kind - 0x315: 0x49009, // onkeydown - 0x316: 0x2b90a, // formaction - 0x319: 0x1, // a - 0x31b: 0x5, // about - 0x31e: 0x5b10a, // onprogress - 0x31f: 0x44910, // ondurationchange - 0x321: 0x3cc04, // base - 0x32d: 0x2e30e, // formnovalidate - 0x331: 0x22705, // track - 0x33a: 0x5f906, // select - 0x33b: 0x66906, // public - 0x33e: 0x55a05, // inert - 0x340: 0x26b04, // step - 0x342: 0x33506, // iframe - 0x344: 0x32702, // h2 - 0x346: 0x4fd0b, // onmousedown - 0x347: 0x1fd0b, // placeholder - 0x34b: 0xdb03, // dir - 0x34f: 0x13b04, // href - 0x350: 0x22702, // tr - 0x351: 0x1c20a, // blockquote - 0x358: 0x20807, // colspan - 0x35d: 0x50c0e, // defaultChecked - 0x361: 0x1ad09, // draggable - 0x369: 0xbe06, // onblur - 0x36b: 0x5890b, // pauseonexit - 0x36f: 0x8d07, // enabled - 0x371: 0x30406, // height - 0x373: 0x5d308, // onresize - 0x375: 0x4d808, // datatype - 0x376: 0x57b0a, // onpageshow - 0x378: 0x1b03, // ins - 0x379: 0x4080b, // ondragenter - 0x37a: 0x2ce0b, // formenctype - 0x37f: 0x4ac07, // onkeyup - 0x381: 0x3b707, // onclose - 0x382: 0x31902, // dd - 0x384: 0x38603, // max - 0x386: 0x3cc08, // basefont - 0x38a: 0x27f0a, // figcaption - 0x38b: 0x20d0a, // annotation - 0x38c: 0x25306, // coords - 0x38f: 0xcb05, // embed - 0x392: 0x11904, // type - 0x393: 0x1505, // param - 0x394: 0x30202, // h6 - 0x397: 0x501, // p - 0x398: 0x19807, // bgcolor - 0x39b: 0x4303, // rev - 0x39c: 0x12e06, // itemid - 0x39d: 0x1d07, // sandbox - 0x39e: 0x29306, // figure - 0x3a2: 0xfe06, // dialog - 0x3a3: 0x5a70a, // onpopstate - 0x3a4: 0x1ba03, // big - 0x3a7: 0x39504, // area - 0x3af: 0x6980e, // onbeforeunload - 0x3b1: 0xa01, // i - 0x3b4: 0x37a0a, // spellcheck - 0x3b5: 0x4e02, // ul - 0x3bd: 0xb907, // section - 0x3bf: 0x45108, // onchange - 0x3c2: 0x13f08, // language - 0x3c4: 0x4130b, // ondragleave - 0x3c6: 0x2d207, // enctype - 0x3c7: 0x22107, // compact - 0x3c8: 0x38609, // maxlength - 0x3c9: 0x5f908, // selected - 0x3cd: 0x9908, // longdesc - 0x3d3: 0x58707, // onpause - 0x3d9: 0xc307, // rowspan - 0x3de: 0x4a0f, // defaultSelected - 0x3df: 0x4cc10, // onloadedmetadata - 0x3e2: 0x10504, // link - 0x3e3: 0xd108, // noframes - 0x3e6: 0x48205, // input - 0x3ec: 0x62003, // sub - 0x3ee: 0x39e08, // multiple - 0x3ef: 0x4a07, // default - 0x3f4: 0x2b904, // form - 0x3fb: 0x4b906, // onload - 0x3fc: 0x6b02, // mi - 0x3fd: 0x19602, // h1 - 0x3ff: 0x4740c, // onhashchange + 0x1e5: 0x12204, // menu + 0x1e6: 0x2a405, // input + 0x1eb: 0x32403, // nav + 0x1ec: 0x31d03, // sub + 0x1ee: 0x1807, // charset + 0x1ef: 0x7f07, // default + 0x1f3: 0x2f205, // table + 0x1f4: 0x23b04, // form + 0x1f5: 0x23209, // truespeed + 0x1f6: 0x2f02, // rb + 0x1fb: 0x20b09, // translate + 0x1fd: 0x2e002, // h1 } diff -Nru golang-github-tdewolff-parse-2.3.9/html/lex.go golang-github-tdewolff-parse-2.4.2/html/lex.go --- golang-github-tdewolff-parse-2.3.9/html/lex.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/html/lex.go 2019-12-17 13:35:25.000000000 +0000 @@ -90,6 +90,21 @@ l.r.Restore() } +// Offset returns the current position in the input stream. +func (l *Lexer) Offset() int { + return l.r.Offset() +} + +// Text returns the textual representation of a token. This excludes delimiters and additional leading/trailing characters. +func (l *Lexer) Text() []byte { + return l.text +} + +// AttrVal returns the attribute value when an AttributeToken was returned from Next. +func (l *Lexer) AttrVal() []byte { + return l.attrVal +} + // Next returns the next Token. It returns ErrorToken when an error was encountered. Using Err() one can retrieve the error message. func (l *Lexer) Next() (TokenType, []byte) { l.text = nil @@ -108,15 +123,13 @@ } else if c != '>' && (c != '/' || l.r.Peek(1) != '>') { return AttributeToken, l.shiftAttribute() } - start := l.r.Pos() + l.r.Skip() l.inTag = false if c == '/' { l.r.Move(2) - l.text = l.r.Lexeme()[start:] return StartTagVoidToken, l.r.Shift() } l.r.Move(1) - l.text = l.r.Lexeme()[start:] return StartTagCloseToken, l.r.Shift() } @@ -136,7 +149,8 @@ if l.r.Pos() > 0 { if isEndTag || 'a' <= c && c <= 'z' || 'A' <= c && c <= 'Z' || c == '!' || c == '?' { // return currently buffered texttoken so that we can return tag next iteration - return TextToken, l.r.Shift() + l.text = l.r.Shift() + return TextToken, l.text } } else if isEndTag { l.r.Move(2) @@ -158,7 +172,8 @@ } } else if c == 0 && l.r.Err() != nil { if l.r.Pos() > 0 { - return TextToken, l.r.Shift() + l.text = l.r.Shift() + return TextToken, l.text } return ErrorToken, nil } @@ -166,19 +181,9 @@ } } -// Text returns the textual representation of a token. This excludes delimiters and additional leading/trailing characters. -func (l *Lexer) Text() []byte { - return l.text -} - -// AttrVal returns the attribute value when an AttributeToken was returned from Next. -func (l *Lexer) AttrVal() []byte { - return l.attrVal -} - //////////////////////////////////////////////////////////////// -// The following functions follow the specifications at http://www.w3.org/html/wg/drafts/html/master/syntax.html +// The following functions follow the specifications at https://html.spec.whatwg.org/multipage/parsing.html func (l *Lexer) shiftRawText() []byte { if l.rawTag == Plaintext { @@ -261,6 +266,7 @@ l.r.Move(2) for { if l.r.Peek(0) == 0 && l.r.Err() != nil { + l.text = l.r.Lexeme()[4:] return CommentToken, l.r.Shift() } else if l.at('-', '-', '>') { l.text = l.r.Lexeme()[4:] @@ -277,8 +283,10 @@ l.r.Move(7) for { if l.r.Peek(0) == 0 && l.r.Err() != nil { + l.text = l.r.Lexeme()[9:] return TextToken, l.r.Shift() } else if l.at(']', ']', '>') { + l.text = l.r.Lexeme()[9:] l.r.Move(3) return TextToken, l.r.Shift() } @@ -453,7 +461,7 @@ } } else if c == 0 { if l.r.Err() == nil { - l.err = parse.NewErrorLexer("unexpected null character", l.r) + l.err = parse.NewErrorLexer(l.r, "HTML parse error: unexpected NULL character") } return l.r.Shift() } else { @@ -468,7 +476,7 @@ break } else if c == 0 { if l.r.Err() == nil { - l.err = parse.NewErrorLexer("unexpected null character", l.r) + l.err = parse.NewErrorLexer(l.r, "HTML parse error: unexpected NULL character") } return l.r.Shift() } diff -Nru golang-github-tdewolff-parse-2.3.9/html/lex_test.go golang-github-tdewolff-parse-2.4.2/html/lex_test.go --- golang-github-tdewolff-parse-2.3.9/html/lex_test.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/html/lex_test.go 2019-12-17 13:35:25.000000000 +0000 @@ -212,6 +212,84 @@ } } +func TestTextAndAttrVal(t *testing.T) { + l := NewLexer(bytes.NewBufferString(`
textimage`)) + _, data := l.Next() + test.Bytes(t, data, []byte("")) + test.Bytes(t, l.Text(), nil) + test.Bytes(t, l.AttrVal(), nil) + + _, data = l.Next() + test.Bytes(t, data, []byte("text")) + test.Bytes(t, l.Text(), []byte("text")) + test.Bytes(t, l.AttrVal(), nil) + + _, data = l.Next() + test.Bytes(t, data, []byte("")) + test.Bytes(t, l.Text(), []byte("comment")) + test.Bytes(t, l.AttrVal(), nil) + + _, data = l.Next() + test.Bytes(t, data, []byte("")) + test.Bytes(t, l.Text(), []byte(" doctype")) + test.Bytes(t, l.AttrVal(), nil) + + _, data = l.Next() + test.Bytes(t, data, []byte("")) + test.Bytes(t, l.Text(), []byte("cdata")) + test.Bytes(t, l.AttrVal(), nil) + + _, data = l.Next() + test.Bytes(t, data, []byte("")) + test.Bytes(t, l.Text(), nil) + test.Bytes(t, l.AttrVal(), nil) + + _, data = l.Next() + test.Bytes(t, data, []byte("js")) + test.Bytes(t, l.Text(), nil) + test.Bytes(t, l.AttrVal(), nil) + + _, data = l.Next() + test.Bytes(t, data, []byte("")) + test.Bytes(t, l.Text(), []byte("script")) + test.Bytes(t, l.AttrVal(), nil) + + _, data = l.Next() + test.Bytes(t, data, []byte("image")) + test.Bytes(t, l.Text(), []byte("svg")) + test.Bytes(t, l.AttrVal(), nil) +} + +func TestOffset(t *testing.T) { + l := NewLexer(bytes.NewBufferString(`
text
`)) + test.T(t, l.Offset(), 0) + _, _ = l.Next() + test.T(t, l.Offset(), 4) //
+ _, _ = l.Next() + test.T(t, l.Offset(), 20) // text + _, _ = l.Next() + test.T(t, l.Offset(), 26) //
+} + //////////////////////////////////////////////////////////////// var J int diff -Nru golang-github-tdewolff-parse-2.3.9/html/util.go golang-github-tdewolff-parse-2.4.2/html/util.go --- golang-github-tdewolff-parse-2.3.9/html/util.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/html/util.go 2019-12-17 13:35:25.000000000 +0000 @@ -1,82 +1,23 @@ package html -import "github.com/tdewolff/parse/v2" - var ( singleQuoteEntityBytes = []byte("'") doubleQuoteEntityBytes = []byte(""") ) -var charTable = [256]bool{ - // ASCII - false, false, false, false, false, false, false, false, - false, true, true, true, true, true, false, false, // tab, new line, vertical tab, form feed, carriage return - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - - true, false, true, false, false, false, true, true, // space, ", &, ' - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, true, true, true, false, // <, =, > - - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - - true, false, false, false, false, false, false, false, // ` - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - - // non-ASCII - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, - false, false, false, false, false, false, false, false, -} - // EscapeAttrVal returns the escaped attribute value bytes without quotes. func EscapeAttrVal(buf *[]byte, orig, b []byte, isXML bool) []byte { singles := 0 doubles := 0 unquoted := true entities := false - for i, c := range b { + for _, c := range b { if charTable[c] { - if c == '&' { - entities = true - if quote, n := parse.QuoteEntity(b[i:]); n > 0 { - if quote == '"' { - unquoted = false - doubles++ - } else { - unquoted = false - singles++ - } - } - } else { - unquoted = false - if c == '"' { - doubles++ - } else if c == '\'' { - singles++ - } + unquoted = false + if c == '"' { + doubles++ + } else if c == '\'' { + singles++ } } } @@ -106,18 +47,7 @@ j := 1 start := 0 for i, c := range b { - if c == '&' { - if entityQuote, n := parse.QuoteEntity(b[i:]); n > 0 { - j += copy(t[j:], b[start:i]) - if entityQuote != quote { - t[j] = entityQuote - j++ - } else { - j += copy(t[j:], escapedQuote) - } - start = i + n - } - } else if c == quote { + if c == quote { j += copy(t[j:], b[start:i]) j += copy(t[j:], escapedQuote) start = i + 1 @@ -127,3 +57,1147 @@ t[j] = quote return t[:j+1] } + +var charTable = [256]bool{ + // ASCII + false, false, false, false, false, false, false, false, + false, true, true, false, true, true, false, false, // tab, line feed, form feed, carriage return + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + + true, false, true, false, false, false, false, true, // space, "), ' + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, true, true, true, false, // <, =, > + + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + + true, false, false, false, false, false, false, false, // ` + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + + // non-ASCII + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, + false, false, false, false, false, false, false, false, +} + +// Entities are all named character entities. +var EntitiesMap = map[string][]byte{ + "AElig": []byte("Æ"), + "AMP": []byte("&"), + "Aacute": []byte("Á"), + "Abreve": []byte("Ă"), + "Acirc": []byte("Â"), + "Agrave": []byte("À"), + "Alpha": []byte("Α"), + "Amacr": []byte("Ā"), + "Aogon": []byte("Ą"), + "ApplyFunction": []byte("⁡"), + "Aring": []byte("Å"), + "Assign": []byte("≔"), + "Atilde": []byte("Ã"), + "Backslash": []byte("∖"), + "Barwed": []byte("⌆"), + "Because": []byte("∵"), + "Bernoullis": []byte("ℬ"), + "Breve": []byte("˘"), + "Bumpeq": []byte("≎"), + "Cacute": []byte("Ć"), + "CapitalDifferentialD": []byte("ⅅ"), + "Cayleys": []byte("ℭ"), + "Ccaron": []byte("Č"), + "Ccedil": []byte("Ç"), + "Ccirc": []byte("Ĉ"), + "Cconint": []byte("∰"), + "Cedilla": []byte("¸"), + "CenterDot": []byte("·"), + "CircleDot": []byte("⊙"), + "CircleMinus": []byte("⊖"), + "CirclePlus": []byte("⊕"), + "CircleTimes": []byte("⊗"), + "ClockwiseContourIntegral": []byte("∲"), + "CloseCurlyDoubleQuote": []byte("”"), + "CloseCurlyQuote": []byte("’"), + "Congruent": []byte("≡"), + "Conint": []byte("∯"), + "ContourIntegral": []byte("∮"), + "Coproduct": []byte("∐"), + "CounterClockwiseContourIntegral": []byte("∳"), + "CupCap": []byte("≍"), + "DDotrahd": []byte("⤑"), + "Dagger": []byte("‡"), + "Dcaron": []byte("Ď"), + "Delta": []byte("Δ"), + "DiacriticalAcute": []byte("´"), + "DiacriticalDot": []byte("˙"), + "DiacriticalDoubleAcute": []byte("˝"), + "DiacriticalGrave": []byte("`"), + "DiacriticalTilde": []byte("˜"), + "Diamond": []byte("⋄"), + "DifferentialD": []byte("ⅆ"), + "DotDot": []byte("⃜"), + "DotEqual": []byte("≐"), + "DoubleContourIntegral": []byte("∯"), + "DoubleDot": []byte("¨"), + "DoubleDownArrow": []byte("⇓"), + "DoubleLeftArrow": []byte("⇐"), + "DoubleLeftRightArrow": []byte("⇔"), + "DoubleLeftTee": []byte("⫤"), + "DoubleLongLeftArrow": []byte("⟸"), + "DoubleLongLeftRightArrow": []byte("⟺"), + "DoubleLongRightArrow": []byte("⟹"), + "DoubleRightArrow": []byte("⇒"), + "DoubleRightTee": []byte("⊨"), + "DoubleUpArrow": []byte("⇑"), + "DoubleUpDownArrow": []byte("⇕"), + "DoubleVerticalBar": []byte("∥"), + "DownArrow": []byte("↓"), + "DownArrowBar": []byte("⤓"), + "DownArrowUpArrow": []byte("⇵"), + "DownBreve": []byte("̑"), + "DownLeftRightVector": []byte("⥐"), + "DownLeftTeeVector": []byte("⥞"), + "DownLeftVector": []byte("↽"), + "DownLeftVectorBar": []byte("⥖"), + "DownRightTeeVector": []byte("⥟"), + "DownRightVector": []byte("⇁"), + "DownRightVectorBar": []byte("⥗"), + "DownTee": []byte("⊤"), + "DownTeeArrow": []byte("↧"), + "Downarrow": []byte("⇓"), + "Dstrok": []byte("Đ"), + "Eacute": []byte("É"), + "Ecaron": []byte("Ě"), + "Ecirc": []byte("Ê"), + "Egrave": []byte("È"), + "Element": []byte("∈"), + "Emacr": []byte("Ē"), + "EmptySmallSquare": []byte("◻"), + "EmptyVerySmallSquare": []byte("▫"), + "Eogon": []byte("Ę"), + "Epsilon": []byte("Ε"), + "EqualTilde": []byte("≂"), + "Equilibrium": []byte("⇌"), + "Exists": []byte("∃"), + "ExponentialE": []byte("ⅇ"), + "FilledSmallSquare": []byte("◼"), + "FilledVerySmallSquare": []byte("▪"), + "ForAll": []byte("∀"), + "Fouriertrf": []byte("ℱ"), + "GT": []byte(">"), + "Gamma": []byte("Γ"), + "Gammad": []byte("Ϝ"), + "Gbreve": []byte("Ğ"), + "Gcedil": []byte("Ģ"), + "Gcirc": []byte("Ĝ"), + "GreaterEqual": []byte("≥"), + "GreaterEqualLess": []byte("⋛"), + "GreaterFullEqual": []byte("≧"), + "GreaterGreater": []byte("⪢"), + "GreaterLess": []byte("≷"), + "GreaterSlantEqual": []byte("⩾"), + "GreaterTilde": []byte("≳"), + "HARDcy": []byte("Ъ"), + "Hacek": []byte("ˇ"), + "Hat": []byte("^"), + "Hcirc": []byte("Ĥ"), + "HilbertSpace": []byte("ℋ"), + "HorizontalLine": []byte("─"), + "Hstrok": []byte("Ħ"), + "HumpDownHump": []byte("≎"), + "HumpEqual": []byte("≏"), + "IJlig": []byte("IJ"), + "Iacute": []byte("Í"), + "Icirc": []byte("Î"), + "Ifr": []byte("ℑ"), + "Igrave": []byte("Ì"), + "Imacr": []byte("Ī"), + "ImaginaryI": []byte("ⅈ"), + "Implies": []byte("⇒"), + "Integral": []byte("∫"), + "Intersection": []byte("⋂"), + "InvisibleComma": []byte("⁣"), + "InvisibleTimes": []byte("⁢"), + "Iogon": []byte("Į"), + "Itilde": []byte("Ĩ"), + "Jcirc": []byte("Ĵ"), + "Jsercy": []byte("Ј"), + "Kappa": []byte("Κ"), + "Kcedil": []byte("Ķ"), + "LT": []byte("<"), + "Lacute": []byte("Ĺ"), + "Lambda": []byte("Λ"), + "Laplacetrf": []byte("ℒ"), + "Lcaron": []byte("Ľ"), + "Lcedil": []byte("Ļ"), + "LeftAngleBracket": []byte("⟨"), + "LeftArrow": []byte("←"), + "LeftArrowBar": []byte("⇤"), + "LeftArrowRightArrow": []byte("⇆"), + "LeftCeiling": []byte("⌈"), + "LeftDoubleBracket": []byte("⟦"), + "LeftDownTeeVector": []byte("⥡"), + "LeftDownVector": []byte("⇃"), + "LeftDownVectorBar": []byte("⥙"), + "LeftFloor": []byte("⌊"), + "LeftRightArrow": []byte("↔"), + "LeftRightVector": []byte("⥎"), + "LeftTee": []byte("⊣"), + "LeftTeeArrow": []byte("↤"), + "LeftTeeVector": []byte("⥚"), + "LeftTriangle": []byte("⊲"), + "LeftTriangleBar": []byte("⧏"), + "LeftTriangleEqual": []byte("⊴"), + "LeftUpDownVector": []byte("⥑"), + "LeftUpTeeVector": []byte("⥠"), + "LeftUpVector": []byte("↿"), + "LeftUpVectorBar": []byte("⥘"), + "LeftVector": []byte("↼"), + "LeftVectorBar": []byte("⥒"), + "Leftarrow": []byte("⇐"), + "Leftrightarrow": []byte("⇔"), + "LessEqualGreater": []byte("⋚"), + "LessFullEqual": []byte("≦"), + "LessGreater": []byte("≶"), + "LessLess": []byte("⪡"), + "LessSlantEqual": []byte("⩽"), + "LessTilde": []byte("≲"), + "Lleftarrow": []byte("⇚"), + "Lmidot": []byte("Ŀ"), + "LongLeftArrow": []byte("⟵"), + "LongLeftRightArrow": []byte("⟷"), + "LongRightArrow": []byte("⟶"), + "Longleftarrow": []byte("⟸"), + "Longleftrightarrow": []byte("⟺"), + "Longrightarrow": []byte("⟹"), + "LowerLeftArrow": []byte("↙"), + "LowerRightArrow": []byte("↘"), + "Lstrok": []byte("Ł"), + "MediumSpace": []byte(" "), + "Mellintrf": []byte("ℳ"), + "MinusPlus": []byte("∓"), + "Nacute": []byte("Ń"), + "Ncaron": []byte("Ň"), + "Ncedil": []byte("Ņ"), + "NegativeMediumSpace": []byte("​"), + "NegativeThickSpace": []byte("​"), + "NegativeThinSpace": []byte("​"), + "NegativeVeryThinSpace": []byte("​"), + "NestedGreaterGreater": []byte("≫"), + "NestedLessLess": []byte("≪"), + "NewLine": []byte("\n"), + "NoBreak": []byte("⁠"), + "NonBreakingSpace": []byte(" "), + "NotCongruent": []byte("≢"), + "NotCupCap": []byte("≭"), + "NotDoubleVerticalBar": []byte("∦"), + "NotElement": []byte("∉"), + "NotEqual": []byte("≠"), + "NotExists": []byte("∄"), + "NotGreater": []byte("≯"), + "NotGreaterEqual": []byte("≱"), + "NotGreaterLess": []byte("≹"), + "NotGreaterTilde": []byte("≵"), + "NotLeftTriangle": []byte("⋪"), + "NotLeftTriangleEqual": []byte("⋬"), + "NotLess": []byte("≮"), + "NotLessEqual": []byte("≰"), + "NotLessGreater": []byte("≸"), + "NotLessTilde": []byte("≴"), + "NotPrecedes": []byte("⊀"), + "NotPrecedesSlantEqual": []byte("⋠"), + "NotReverseElement": []byte("∌"), + "NotRightTriangle": []byte("⋫"), + "NotRightTriangleEqual": []byte("⋭"), + "NotSquareSubsetEqual": []byte("⋢"), + "NotSquareSupersetEqual": []byte("⋣"), + "NotSubsetEqual": []byte("⊈"), + "NotSucceeds": []byte("⊁"), + "NotSucceedsSlantEqual": []byte("⋡"), + "NotSupersetEqual": []byte("⊉"), + "NotTilde": []byte("≁"), + "NotTildeEqual": []byte("≄"), + "NotTildeFullEqual": []byte("≇"), + "NotTildeTilde": []byte("≉"), + "NotVerticalBar": []byte("∤"), + "Ntilde": []byte("Ñ"), + "OElig": []byte("Œ"), + "Oacute": []byte("Ó"), + "Ocirc": []byte("Ô"), + "Odblac": []byte("Ő"), + "Ograve": []byte("Ò"), + "Omacr": []byte("Ō"), + "Omega": []byte("Ω"), + "Omicron": []byte("Ο"), + "OpenCurlyDoubleQuote": []byte("“"), + "OpenCurlyQuote": []byte("‘"), + "Oslash": []byte("Ø"), + "Otilde": []byte("Õ"), + "OverBar": []byte("‾"), + "OverBrace": []byte("⏞"), + "OverBracket": []byte("⎴"), + "OverParenthesis": []byte("⏜"), + "PartialD": []byte("∂"), + "PlusMinus": []byte("±"), + "Poincareplane": []byte("ℌ"), + "Precedes": []byte("≺"), + "PrecedesEqual": []byte("⪯"), + "PrecedesSlantEqual": []byte("≼"), + "PrecedesTilde": []byte("≾"), + "Product": []byte("∏"), + "Proportion": []byte("∷"), + "Proportional": []byte("∝"), + "QUOT": []byte("\""), + "Racute": []byte("Ŕ"), + "Rcaron": []byte("Ř"), + "Rcedil": []byte("Ŗ"), + "ReverseElement": []byte("∋"), + "ReverseEquilibrium": []byte("⇋"), + "ReverseUpEquilibrium": []byte("⥯"), + "Rfr": []byte("ℜ"), + "RightAngleBracket": []byte("⟩"), + "RightArrow": []byte("→"), + "RightArrowBar": []byte("⇥"), + "RightArrowLeftArrow": []byte("⇄"), + "RightCeiling": []byte("⌉"), + "RightDoubleBracket": []byte("⟧"), + "RightDownTeeVector": []byte("⥝"), + "RightDownVector": []byte("⇂"), + "RightDownVectorBar": []byte("⥕"), + "RightFloor": []byte("⌋"), + "RightTee": []byte("⊢"), + "RightTeeArrow": []byte("↦"), + "RightTeeVector": []byte("⥛"), + "RightTriangle": []byte("⊳"), + "RightTriangleBar": []byte("⧐"), + "RightTriangleEqual": []byte("⊵"), + "RightUpDownVector": []byte("⥏"), + "RightUpTeeVector": []byte("⥜"), + "RightUpVector": []byte("↾"), + "RightUpVectorBar": []byte("⥔"), + "RightVector": []byte("⇀"), + "RightVectorBar": []byte("⥓"), + "Rightarrow": []byte("⇒"), + "RoundImplies": []byte("⥰"), + "Rrightarrow": []byte("⇛"), + "RuleDelayed": []byte("⧴"), + "SHCHcy": []byte("Щ"), + "SOFTcy": []byte("Ь"), + "Sacute": []byte("Ś"), + "Scaron": []byte("Š"), + "Scedil": []byte("Ş"), + "Scirc": []byte("Ŝ"), + "ShortDownArrow": []byte("↓"), + "ShortLeftArrow": []byte("←"), + "ShortRightArrow": []byte("→"), + "ShortUpArrow": []byte("↑"), + "Sigma": []byte("Σ"), + "SmallCircle": []byte("∘"), + "Square": []byte("□"), + "SquareIntersection": []byte("⊓"), + "SquareSubset": []byte("⊏"), + "SquareSubsetEqual": []byte("⊑"), + "SquareSuperset": []byte("⊐"), + "SquareSupersetEqual": []byte("⊒"), + "SquareUnion": []byte("⊔"), + "Subset": []byte("⋐"), + "SubsetEqual": []byte("⊆"), + "Succeeds": []byte("≻"), + "SucceedsEqual": []byte("⪰"), + "SucceedsSlantEqual": []byte("≽"), + "SucceedsTilde": []byte("≿"), + "SuchThat": []byte("∋"), + "Superset": []byte("⊃"), + "SupersetEqual": []byte("⊇"), + "Supset": []byte("⋑"), + "THORN": []byte("Þ"), + "Tab": []byte(" "), + "Tcaron": []byte("Ť"), + "Tcedil": []byte("Ţ"), + "Therefore": []byte("∴"), + "Theta": []byte("Θ"), + "ThinSpace": []byte(" "), + "Tilde": []byte("∼"), + "TildeEqual": []byte("≃"), + "TildeFullEqual": []byte("≅"), + "TildeTilde": []byte("≈"), + "TripleDot": []byte("⃛"), + "Tstrok": []byte("Ŧ"), + "Uacute": []byte("Ú"), + "Uarrocir": []byte("⥉"), + "Ubreve": []byte("Ŭ"), + "Ucirc": []byte("Û"), + "Udblac": []byte("Ű"), + "Ugrave": []byte("Ù"), + "Umacr": []byte("Ū"), + "UnderBar": []byte("_"), + "UnderBrace": []byte("⏟"), + "UnderBracket": []byte("⎵"), + "UnderParenthesis": []byte("⏝"), + "Union": []byte("⋃"), + "UnionPlus": []byte("⊎"), + "Uogon": []byte("Ų"), + "UpArrow": []byte("↑"), + "UpArrowBar": []byte("⤒"), + "UpArrowDownArrow": []byte("⇅"), + "UpDownArrow": []byte("↕"), + "UpEquilibrium": []byte("⥮"), + "UpTee": []byte("⊥"), + "UpTeeArrow": []byte("↥"), + "Uparrow": []byte("⇑"), + "Updownarrow": []byte("⇕"), + "UpperLeftArrow": []byte("↖"), + "UpperRightArrow": []byte("↗"), + "Upsilon": []byte("Υ"), + "Uring": []byte("Ů"), + "Utilde": []byte("Ũ"), + "Verbar": []byte("‖"), + "VerticalBar": []byte("∣"), + "VerticalLine": []byte("|"), + "VerticalSeparator": []byte("❘"), + "VerticalTilde": []byte("≀"), + "VeryThinSpace": []byte(" "), + "Vvdash": []byte("⊪"), + "Wcirc": []byte("Ŵ"), + "Yacute": []byte("Ý"), + "Ycirc": []byte("Ŷ"), + "Zacute": []byte("Ź"), + "Zcaron": []byte("Ž"), + "ZeroWidthSpace": []byte("​"), + "aacute": []byte("á"), + "abreve": []byte("ă"), + "acirc": []byte("â"), + "acute": []byte("´"), + "aelig": []byte("æ"), + "agrave": []byte("à"), + "alefsym": []byte("ℵ"), + "alpha": []byte("α"), + "amacr": []byte("ā"), + "amp": []byte("&"), + "andslope": []byte("⩘"), + "angle": []byte("∠"), + "angmsd": []byte("∡"), + "angmsdaa": []byte("⦨"), + "angmsdab": []byte("⦩"), + "angmsdac": []byte("⦪"), + "angmsdad": []byte("⦫"), + "angmsdae": []byte("⦬"), + "angmsdaf": []byte("⦭"), + "angmsdag": []byte("⦮"), + "angmsdah": []byte("⦯"), + "angrtvb": []byte("⊾"), + "angrtvbd": []byte("⦝"), + "angsph": []byte("∢"), + "angst": []byte("Å"), + "angzarr": []byte("⍼"), + "aogon": []byte("ą"), + "apos": []byte("'"), + "approx": []byte("≈"), + "approxeq": []byte("≊"), + "aring": []byte("å"), + "ast": []byte("*"), + "asymp": []byte("≈"), + "asympeq": []byte("≍"), + "atilde": []byte("ã"), + "awconint": []byte("∳"), + "backcong": []byte("≌"), + "backepsilon": []byte("϶"), + "backprime": []byte("‵"), + "backsim": []byte("∽"), + "backsimeq": []byte("⋍"), + "barvee": []byte("⊽"), + "barwed": []byte("⌅"), + "barwedge": []byte("⌅"), + "bbrktbrk": []byte("⎶"), + "becaus": []byte("∵"), + "because": []byte("∵"), + "bemptyv": []byte("⦰"), + "bernou": []byte("ℬ"), + "between": []byte("≬"), + "bigcap": []byte("⋂"), + "bigcirc": []byte("◯"), + "bigcup": []byte("⋃"), + "bigodot": []byte("⨀"), + "bigoplus": []byte("⨁"), + "bigotimes": []byte("⨂"), + "bigsqcup": []byte("⨆"), + "bigstar": []byte("★"), + "bigtriangledown": []byte("▽"), + "bigtriangleup": []byte("△"), + "biguplus": []byte("⨄"), + "bigvee": []byte("⋁"), + "bigwedge": []byte("⋀"), + "bkarow": []byte("⤍"), + "blacklozenge": []byte("⧫"), + "blacksquare": []byte("▪"), + "blacktriangle": []byte("▴"), + "blacktriangledown": []byte("▾"), + "blacktriangleleft": []byte("◂"), + "blacktriangleright": []byte("▸"), + "bottom": []byte("⊥"), + "bowtie": []byte("⋈"), + "boxminus": []byte("⊟"), + "boxplus": []byte("⊞"), + "boxtimes": []byte("⊠"), + "bprime": []byte("‵"), + "breve": []byte("˘"), + "brvbar": []byte("¦"), + "bsol": []byte("\\"), + "bsolhsub": []byte("⟈"), + "bullet": []byte("•"), + "bumpeq": []byte("≏"), + "cacute": []byte("ć"), + "capbrcup": []byte("⩉"), + "caron": []byte("ˇ"), + "ccaron": []byte("č"), + "ccedil": []byte("ç"), + "ccirc": []byte("ĉ"), + "ccupssm": []byte("⩐"), + "cedil": []byte("¸"), + "cemptyv": []byte("⦲"), + "centerdot": []byte("·"), + "checkmark": []byte("✓"), + "circeq": []byte("≗"), + "circlearrowleft": []byte("↺"), + "circlearrowright": []byte("↻"), + "circledR": []byte("®"), + "circledS": []byte("Ⓢ"), + "circledast": []byte("⊛"), + "circledcirc": []byte("⊚"), + "circleddash": []byte("⊝"), + "cirfnint": []byte("⨐"), + "cirscir": []byte("⧂"), + "clubsuit": []byte("♣"), + "colon": []byte(":"), + "colone": []byte("≔"), + "coloneq": []byte("≔"), + "comma": []byte(","), + "commat": []byte("@"), + "compfn": []byte("∘"), + "complement": []byte("∁"), + "complexes": []byte("ℂ"), + "congdot": []byte("⩭"), + "conint": []byte("∮"), + "coprod": []byte("∐"), + "copysr": []byte("℗"), + "cudarrl": []byte("⤸"), + "cudarrr": []byte("⤵"), + "cularr": []byte("↶"), + "cularrp": []byte("⤽"), + "cupbrcap": []byte("⩈"), + "cupdot": []byte("⊍"), + "curarr": []byte("↷"), + "curarrm": []byte("⤼"), + "curlyeqprec": []byte("⋞"), + "curlyeqsucc": []byte("⋟"), + "curlyvee": []byte("⋎"), + "curlywedge": []byte("⋏"), + "curren": []byte("¤"), + "curvearrowleft": []byte("↶"), + "curvearrowright": []byte("↷"), + "cwconint": []byte("∲"), + "cylcty": []byte("⌭"), + "dagger": []byte("†"), + "daleth": []byte("ℸ"), + "dbkarow": []byte("⤏"), + "dblac": []byte("˝"), + "dcaron": []byte("ď"), + "ddagger": []byte("‡"), + "ddotseq": []byte("⩷"), + "delta": []byte("δ"), + "demptyv": []byte("⦱"), + "diamond": []byte("⋄"), + "diamondsuit": []byte("♦"), + "digamma": []byte("ϝ"), + "divide": []byte("÷"), + "divideontimes": []byte("⋇"), + "divonx": []byte("⋇"), + "dlcorn": []byte("⌞"), + "dlcrop": []byte("⌍"), + "dollar": []byte("$"), + "doteqdot": []byte("≑"), + "dotminus": []byte("∸"), + "dotplus": []byte("∔"), + "dotsquare": []byte("⊡"), + "doublebarwedge": []byte("⌆"), + "downarrow": []byte("↓"), + "downdownarrows": []byte("⇊"), + "downharpoonleft": []byte("⇃"), + "downharpoonright": []byte("⇂"), + "drbkarow": []byte("⤐"), + "drcorn": []byte("⌟"), + "drcrop": []byte("⌌"), + "dstrok": []byte("đ"), + "dwangle": []byte("⦦"), + "dzigrarr": []byte("⟿"), + "eacute": []byte("é"), + "ecaron": []byte("ě"), + "ecirc": []byte("ê"), + "ecolon": []byte("≕"), + "egrave": []byte("è"), + "elinters": []byte("⏧"), + "emacr": []byte("ē"), + "emptyset": []byte("∅"), + "emptyv": []byte("∅"), + "emsp13": []byte(" "), + "emsp14": []byte(" "), + "eogon": []byte("ę"), + "epsilon": []byte("ε"), + "eqcirc": []byte("≖"), + "eqcolon": []byte("≕"), + "eqsim": []byte("≂"), + "eqslantgtr": []byte("⪖"), + "eqslantless": []byte("⪕"), + "equals": []byte("="), + "equest": []byte("≟"), + "equivDD": []byte("⩸"), + "eqvparsl": []byte("⧥"), + "excl": []byte("!"), + "expectation": []byte("ℰ"), + "exponentiale": []byte("ⅇ"), + "fallingdotseq": []byte("≒"), + "female": []byte("♀"), + "forall": []byte("∀"), + "fpartint": []byte("⨍"), + "frac12": []byte("½"), + "frac13": []byte("⅓"), + "frac14": []byte("¼"), + "frac15": []byte("⅕"), + "frac16": []byte("⅙"), + "frac18": []byte("⅛"), + "frac23": []byte("⅔"), + "frac25": []byte("⅖"), + "frac34": []byte("¾"), + "frac35": []byte("⅗"), + "frac38": []byte("⅜"), + "frac45": []byte("⅘"), + "frac56": []byte("⅚"), + "frac58": []byte("⅝"), + "frac78": []byte("⅞"), + "gacute": []byte("ǵ"), + "gamma": []byte("γ"), + "gammad": []byte("ϝ"), + "gbreve": []byte("ğ"), + "gcirc": []byte("ĝ"), + "geq": []byte("≥"), + "geqq": []byte("≧"), + "geqslant": []byte("⩾"), + "gesdoto": []byte("⪂"), + "gesdotol": []byte("⪄"), + "ggg": []byte("⋙"), + "gnapprox": []byte("⪊"), + "gneq": []byte("⪈"), + "gneqq": []byte("≩"), + "grave": []byte("`"), + "gt": []byte(">"), + "gtquest": []byte("⩼"), + "gtrapprox": []byte("⪆"), + "gtrdot": []byte("⋗"), + "gtreqless": []byte("⋛"), + "gtreqqless": []byte("⪌"), + "gtrless": []byte("≷"), + "gtrsim": []byte("≳"), + "hArr": []byte("⇔"), + "hairsp": []byte(" "), + "hamilt": []byte("ℋ"), + "hardcy": []byte("ъ"), + "harrcir": []byte("⥈"), + "hcirc": []byte("ĥ"), + "hearts": []byte("♥"), + "heartsuit": []byte("♥"), + "hellip": []byte("…"), + "hercon": []byte("⊹"), + "hksearow": []byte("⤥"), + "hkswarow": []byte("⤦"), + "homtht": []byte("∻"), + "hookleftarrow": []byte("↩"), + "hookrightarrow": []byte("↪"), + "horbar": []byte("―"), + "hslash": []byte("ℏ"), + "hstrok": []byte("ħ"), + "hybull": []byte("⁃"), + "hyphen": []byte("‐"), + "iacute": []byte("í"), + "icirc": []byte("î"), + "iexcl": []byte("¡"), + "igrave": []byte("ì"), + "iiiint": []byte("⨌"), + "iiint": []byte("∭"), + "ijlig": []byte("ij"), + "imacr": []byte("ī"), + "image": []byte("ℑ"), + "imagline": []byte("ℐ"), + "imagpart": []byte("ℑ"), + "imath": []byte("ı"), + "imped": []byte("Ƶ"), + "incare": []byte("℅"), + "infintie": []byte("⧝"), + "inodot": []byte("ı"), + "intcal": []byte("⊺"), + "integers": []byte("ℤ"), + "intercal": []byte("⊺"), + "intlarhk": []byte("⨗"), + "intprod": []byte("⨼"), + "iogon": []byte("į"), + "iquest": []byte("¿"), + "isin": []byte("∈"), + "isindot": []byte("⋵"), + "isinsv": []byte("⋳"), + "isinv": []byte("∈"), + "itilde": []byte("ĩ"), + "jcirc": []byte("ĵ"), + "jmath": []byte("ȷ"), + "jsercy": []byte("ј"), + "kappa": []byte("κ"), + "kappav": []byte("ϰ"), + "kcedil": []byte("ķ"), + "kgreen": []byte("ĸ"), + "lacute": []byte("ĺ"), + "laemptyv": []byte("⦴"), + "lagran": []byte("ℒ"), + "lambda": []byte("λ"), + "langle": []byte("⟨"), + "laquo": []byte("«"), + "larrbfs": []byte("⤟"), + "larrhk": []byte("↩"), + "larrlp": []byte("↫"), + "larrsim": []byte("⥳"), + "larrtl": []byte("↢"), + "lbrace": []byte("{"), + "lbrack": []byte("["), + "lbrksld": []byte("⦏"), + "lbrkslu": []byte("⦍"), + "lcaron": []byte("ľ"), + "lcedil": []byte("ļ"), + "lcub": []byte("{"), + "ldquor": []byte("„"), + "ldrdhar": []byte("⥧"), + "ldrushar": []byte("⥋"), + "leftarrow": []byte("←"), + "leftarrowtail": []byte("↢"), + "leftharpoondown": []byte("↽"), + "leftharpoonup": []byte("↼"), + "leftleftarrows": []byte("⇇"), + "leftrightarrow": []byte("↔"), + "leftrightarrows": []byte("⇆"), + "leftrightharpoons": []byte("⇋"), + "leftrightsquigarrow": []byte("↭"), + "leftthreetimes": []byte("⋋"), + "leq": []byte("≤"), + "leqq": []byte("≦"), + "leqslant": []byte("⩽"), + "lesdoto": []byte("⪁"), + "lesdotor": []byte("⪃"), + "lessapprox": []byte("⪅"), + "lessdot": []byte("⋖"), + "lesseqgtr": []byte("⋚"), + "lesseqqgtr": []byte("⪋"), + "lessgtr": []byte("≶"), + "lesssim": []byte("≲"), + "lfloor": []byte("⌊"), + "llcorner": []byte("⌞"), + "lmidot": []byte("ŀ"), + "lmoust": []byte("⎰"), + "lmoustache": []byte("⎰"), + "lnapprox": []byte("⪉"), + "lneq": []byte("⪇"), + "lneqq": []byte("≨"), + "longleftarrow": []byte("⟵"), + "longleftrightarrow": []byte("⟷"), + "longmapsto": []byte("⟼"), + "longrightarrow": []byte("⟶"), + "looparrowleft": []byte("↫"), + "looparrowright": []byte("↬"), + "lotimes": []byte("⨴"), + "lowast": []byte("∗"), + "lowbar": []byte("_"), + "lozenge": []byte("◊"), + "lpar": []byte("("), + "lrcorner": []byte("⌟"), + "lsaquo": []byte("‹"), + "lsqb": []byte("["), + "lsquor": []byte("‚"), + "lstrok": []byte("ł"), + "lt": []byte("<"), + "lthree": []byte("⋋"), + "ltimes": []byte("⋉"), + "ltquest": []byte("⩻"), + "lurdshar": []byte("⥊"), + "luruhar": []byte("⥦"), + "maltese": []byte("✠"), + "mapsto": []byte("↦"), + "mapstodown": []byte("↧"), + "mapstoleft": []byte("↤"), + "mapstoup": []byte("↥"), + "marker": []byte("▮"), + "measuredangle": []byte("∡"), + "micro": []byte("µ"), + "midast": []byte("*"), + "middot": []byte("·"), + "minusb": []byte("⊟"), + "minusd": []byte("∸"), + "minusdu": []byte("⨪"), + "mnplus": []byte("∓"), + "models": []byte("⊧"), + "mstpos": []byte("∾"), + "multimap": []byte("⊸"), + "nLeftarrow": []byte("⇍"), + "nLeftrightarrow": []byte("⇎"), + "nRightarrow": []byte("⇏"), + "nVDash": []byte("⊯"), + "nVdash": []byte("⊮"), + "nabla": []byte("∇"), + "nacute": []byte("ń"), + "napos": []byte("ʼn"), + "napprox": []byte("≉"), + "natural": []byte("♮"), + "naturals": []byte("ℕ"), + "ncaron": []byte("ň"), + "ncedil": []byte("ņ"), + "nearrow": []byte("↗"), + "nequiv": []byte("≢"), + "nesear": []byte("⤨"), + "nexist": []byte("∄"), + "nexists": []byte("∄"), + "ngeq": []byte("≱"), + "ngtr": []byte("≯"), + "niv": []byte("∋"), + "nleftarrow": []byte("↚"), + "nleftrightarrow": []byte("↮"), + "nleq": []byte("≰"), + "nless": []byte("≮"), + "nltrie": []byte("⋬"), + "notinva": []byte("∉"), + "notinvb": []byte("⋷"), + "notinvc": []byte("⋶"), + "notniva": []byte("∌"), + "notnivb": []byte("⋾"), + "notnivc": []byte("⋽"), + "nparallel": []byte("∦"), + "npolint": []byte("⨔"), + "nprcue": []byte("⋠"), + "nprec": []byte("⊀"), + "nrightarrow": []byte("↛"), + "nrtrie": []byte("⋭"), + "nsccue": []byte("⋡"), + "nshortmid": []byte("∤"), + "nshortparallel": []byte("∦"), + "nsimeq": []byte("≄"), + "nsmid": []byte("∤"), + "nspar": []byte("∦"), + "nsqsube": []byte("⋢"), + "nsqsupe": []byte("⋣"), + "nsubseteq": []byte("⊈"), + "nsucc": []byte("⊁"), + "nsupseteq": []byte("⊉"), + "ntilde": []byte("ñ"), + "ntriangleleft": []byte("⋪"), + "ntrianglelefteq": []byte("⋬"), + "ntriangleright": []byte("⋫"), + "ntrianglerighteq": []byte("⋭"), + "num": []byte("#"), + "numero": []byte("№"), + "nvDash": []byte("⊭"), + "nvdash": []byte("⊬"), + "nvinfin": []byte("⧞"), + "nwarrow": []byte("↖"), + "oacute": []byte("ó"), + "ocirc": []byte("ô"), + "odblac": []byte("ő"), + "oelig": []byte("œ"), + "ograve": []byte("ò"), + "olcross": []byte("⦻"), + "omacr": []byte("ō"), + "omega": []byte("ω"), + "omicron": []byte("ο"), + "ominus": []byte("⊖"), + "order": []byte("ℴ"), + "orderof": []byte("ℴ"), + "origof": []byte("⊶"), + "orslope": []byte("⩗"), + "oslash": []byte("ø"), + "otilde": []byte("õ"), + "otimes": []byte("⊗"), + "otimesas": []byte("⨶"), + "parallel": []byte("∥"), + "percnt": []byte("%"), + "period": []byte("."), + "permil": []byte("‰"), + "perp": []byte("⊥"), + "pertenk": []byte("‱"), + "phmmat": []byte("ℳ"), + "pitchfork": []byte("⋔"), + "planck": []byte("ℏ"), + "planckh": []byte("ℎ"), + "plankv": []byte("ℏ"), + "plus": []byte("+"), + "plusacir": []byte("⨣"), + "pluscir": []byte("⨢"), + "plusdo": []byte("∔"), + "plusmn": []byte("±"), + "plussim": []byte("⨦"), + "plustwo": []byte("⨧"), + "pointint": []byte("⨕"), + "pound": []byte("£"), + "prec": []byte("≺"), + "precapprox": []byte("⪷"), + "preccurlyeq": []byte("≼"), + "preceq": []byte("⪯"), + "precnapprox": []byte("⪹"), + "precneqq": []byte("⪵"), + "precnsim": []byte("⋨"), + "precsim": []byte("≾"), + "primes": []byte("ℙ"), + "prnsim": []byte("⋨"), + "profalar": []byte("⌮"), + "profline": []byte("⌒"), + "profsurf": []byte("⌓"), + "propto": []byte("∝"), + "prurel": []byte("⊰"), + "puncsp": []byte(" "), + "qprime": []byte("⁗"), + "quaternions": []byte("ℍ"), + "quatint": []byte("⨖"), + "quest": []byte("?"), + "questeq": []byte("≟"), + "quot": []byte("\""), + "racute": []byte("ŕ"), + "radic": []byte("√"), + "raemptyv": []byte("⦳"), + "rangle": []byte("⟩"), + "raquo": []byte("»"), + "rarrbfs": []byte("⤠"), + "rarrhk": []byte("↪"), + "rarrlp": []byte("↬"), + "rarrsim": []byte("⥴"), + "rarrtl": []byte("↣"), + "rationals": []byte("ℚ"), + "rbrace": []byte("}"), + "rbrack": []byte("]"), + "rbrksld": []byte("⦎"), + "rbrkslu": []byte("⦐"), + "rcaron": []byte("ř"), + "rcedil": []byte("ŗ"), + "rcub": []byte("}"), + "rdldhar": []byte("⥩"), + "rdquor": []byte("”"), + "real": []byte("ℜ"), + "realine": []byte("ℛ"), + "realpart": []byte("ℜ"), + "reals": []byte("ℝ"), + "rfloor": []byte("⌋"), + "rightarrow": []byte("→"), + "rightarrowtail": []byte("↣"), + "rightharpoondown": []byte("⇁"), + "rightharpoonup": []byte("⇀"), + "rightleftarrows": []byte("⇄"), + "rightleftharpoons": []byte("⇌"), + "rightrightarrows": []byte("⇉"), + "rightsquigarrow": []byte("↝"), + "rightthreetimes": []byte("⋌"), + "risingdotseq": []byte("≓"), + "rmoust": []byte("⎱"), + "rmoustache": []byte("⎱"), + "rotimes": []byte("⨵"), + "rpar": []byte(")"), + "rppolint": []byte("⨒"), + "rsaquo": []byte("›"), + "rsqb": []byte("]"), + "rsquor": []byte("’"), + "rthree": []byte("⋌"), + "rtimes": []byte("⋊"), + "rtriltri": []byte("⧎"), + "ruluhar": []byte("⥨"), + "sacute": []byte("ś"), + "scaron": []byte("š"), + "scedil": []byte("ş"), + "scirc": []byte("ŝ"), + "scnsim": []byte("⋩"), + "scpolint": []byte("⨓"), + "searrow": []byte("↘"), + "semi": []byte(";"), + "seswar": []byte("⤩"), + "setminus": []byte("∖"), + "sfrown": []byte("⌢"), + "shchcy": []byte("щ"), + "shortmid": []byte("∣"), + "shortparallel": []byte("∥"), + "sigma": []byte("σ"), + "sigmaf": []byte("ς"), + "sigmav": []byte("ς"), + "simeq": []byte("≃"), + "simplus": []byte("⨤"), + "simrarr": []byte("⥲"), + "slarr": []byte("←"), + "smallsetminus": []byte("∖"), + "smeparsl": []byte("⧤"), + "smid": []byte("∣"), + "softcy": []byte("ь"), + "sol": []byte("/"), + "solbar": []byte("⌿"), + "spades": []byte("♠"), + "spadesuit": []byte("♠"), + "spar": []byte("∥"), + "sqsube": []byte("⊑"), + "sqsubset": []byte("⊏"), + "sqsubseteq": []byte("⊑"), + "sqsupe": []byte("⊒"), + "sqsupset": []byte("⊐"), + "sqsupseteq": []byte("⊒"), + "square": []byte("□"), + "squarf": []byte("▪"), + "srarr": []byte("→"), + "ssetmn": []byte("∖"), + "ssmile": []byte("⌣"), + "sstarf": []byte("⋆"), + "straightepsilon": []byte("ϵ"), + "straightphi": []byte("ϕ"), + "strns": []byte("¯"), + "subedot": []byte("⫃"), + "submult": []byte("⫁"), + "subplus": []byte("⪿"), + "subrarr": []byte("⥹"), + "subset": []byte("⊂"), + "subseteq": []byte("⊆"), + "subseteqq": []byte("⫅"), + "subsetneq": []byte("⊊"), + "subsetneqq": []byte("⫋"), + "succ": []byte("≻"), + "succapprox": []byte("⪸"), + "succcurlyeq": []byte("≽"), + "succeq": []byte("⪰"), + "succnapprox": []byte("⪺"), + "succneqq": []byte("⪶"), + "succnsim": []byte("⋩"), + "succsim": []byte("≿"), + "supdsub": []byte("⫘"), + "supedot": []byte("⫄"), + "suphsol": []byte("⟉"), + "suphsub": []byte("⫗"), + "suplarr": []byte("⥻"), + "supmult": []byte("⫂"), + "supplus": []byte("⫀"), + "supset": []byte("⊃"), + "supseteq": []byte("⊇"), + "supseteqq": []byte("⫆"), + "supsetneq": []byte("⊋"), + "supsetneqq": []byte("⫌"), + "swarrow": []byte("↙"), + "szlig": []byte("ß"), + "target": []byte("⌖"), + "tcaron": []byte("ť"), + "tcedil": []byte("ţ"), + "telrec": []byte("⌕"), + "there4": []byte("∴"), + "therefore": []byte("∴"), + "theta": []byte("θ"), + "thetasym": []byte("ϑ"), + "thetav": []byte("ϑ"), + "thickapprox": []byte("≈"), + "thicksim": []byte("∼"), + "thinsp": []byte(" "), + "thkap": []byte("≈"), + "thksim": []byte("∼"), + "thorn": []byte("þ"), + "tilde": []byte("˜"), + "times": []byte("×"), + "timesb": []byte("⊠"), + "timesbar": []byte("⨱"), + "topbot": []byte("⌶"), + "topfork": []byte("⫚"), + "tprime": []byte("‴"), + "triangle": []byte("▵"), + "triangledown": []byte("▿"), + "triangleleft": []byte("◃"), + "trianglelefteq": []byte("⊴"), + "triangleq": []byte("≜"), + "triangleright": []byte("▹"), + "trianglerighteq": []byte("⊵"), + "tridot": []byte("◬"), + "triminus": []byte("⨺"), + "triplus": []byte("⨹"), + "tritime": []byte("⨻"), + "trpezium": []byte("⏢"), + "tstrok": []byte("ŧ"), + "twoheadleftarrow": []byte("↞"), + "twoheadrightarrow": []byte("↠"), + "uacute": []byte("ú"), + "ubreve": []byte("ŭ"), + "ucirc": []byte("û"), + "udblac": []byte("ű"), + "ugrave": []byte("ù"), + "ulcorn": []byte("⌜"), + "ulcorner": []byte("⌜"), + "ulcrop": []byte("⌏"), + "umacr": []byte("ū"), + "uogon": []byte("ų"), + "uparrow": []byte("↑"), + "updownarrow": []byte("↕"), + "upharpoonleft": []byte("↿"), + "upharpoonright": []byte("↾"), + "upsih": []byte("ϒ"), + "upsilon": []byte("υ"), + "upuparrows": []byte("⇈"), + "urcorn": []byte("⌝"), + "urcorner": []byte("⌝"), + "urcrop": []byte("⌎"), + "uring": []byte("ů"), + "utilde": []byte("ũ"), + "uwangle": []byte("⦧"), + "varepsilon": []byte("ϵ"), + "varkappa": []byte("ϰ"), + "varnothing": []byte("∅"), + "varphi": []byte("ϕ"), + "varpi": []byte("ϖ"), + "varpropto": []byte("∝"), + "varrho": []byte("ϱ"), + "varsigma": []byte("ς"), + "vartheta": []byte("ϑ"), + "vartriangleleft": []byte("⊲"), + "vartriangleright": []byte("⊳"), + "vee": []byte("∨"), + "veebar": []byte("⊻"), + "vellip": []byte("⋮"), + "verbar": []byte("|"), + "vert": []byte("|"), + "vprop": []byte("∝"), + "vzigzag": []byte("⦚"), + "wcirc": []byte("ŵ"), + "wedge": []byte("∧"), + "wedgeq": []byte("≙"), + "weierp": []byte("℘"), + "wreath": []byte("≀"), + "xvee": []byte("⋁"), + "xwedge": []byte("⋀"), + "yacute": []byte("ý"), + "ycirc": []byte("ŷ"), + "zacute": []byte("ź"), + "zcaron": []byte("ž"), + "zeetrf": []byte("ℨ"), + "zigrarr": []byte("⇝"), +} + +var TextRevEntitiesMap = map[byte][]byte{ + '<': []byte("<"), +} diff -Nru golang-github-tdewolff-parse-2.3.9/html/util_test.go golang-github-tdewolff-parse-2.4.2/html/util_test.go --- golang-github-tdewolff-parse-2.3.9/html/util_test.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/html/util_test.go 2019-12-17 13:35:25.000000000 +0000 @@ -13,20 +13,17 @@ }{ {`xyz`, `xyz`}, {``, ``}, - {`x&z`, `x&z`}, {`x/z`, `x/z`}, {`x'z`, `"x'z"`}, {`x"z`, `'x"z'`}, {`'x"z'`, `'x"z'`}, - {`'x'"'z'`, `"x'"'z"`}, - {`"x"'"z"`, `'x"'"z'`}, - {`"x'z"`, `"x'z"`}, - {`'x"z'`, `'x"z'`}, - {`'x">'`, `'x">'`}, - {`You're encouraged to log in; however, it's not mandatory. [o]`, `"You're encouraged to log in; however, it's not mandatory. [o]"`}, + {`'x'"'z'`, `"x'"'z"`}, + {`"x"'"z"`, `'x"'"z'`}, + {`"x'z"`, `"x'z"`}, + {`'x'z'`, `"x'z"`}, {`a'b=""`, `'a'b=""'`}, {`x= 0xC0 { - if r, n := l.PeekRune(0); r == '\u2028' || r == '\u2029' { - nNewline = n + var r rune + if r, n = l.PeekRune(0); r == '\u2028' || r == '\u2029' { + newline = true } - } else { - l.Move(1) } - if nNewline > 0 { - if offset < l.Pos()+nNewline { - // move onto offset position, let next iteration handle it - l.Move(offset - l.Pos()) - continue - } - l.Move(nNewline) + if 1 < n && offset < l.Pos()+n { + // move onto offset position, let next iteration handle it + l.Move(offset - l.Pos()) + continue + } + l.Move(n) + + if newline { line++ offset -= l.Pos() l.Skip() diff -Nru golang-github-tdewolff-parse-2.3.9/position_test.go golang-github-tdewolff-parse-2.4.2/position_test.go --- golang-github-tdewolff-parse-2.3.9/position_test.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/position_test.go 2019-12-17 13:35:25.000000000 +0000 @@ -35,6 +35,7 @@ {1, "x\u2028x", 1, 2}, {2, "x\u2028x", 1, 3}, {3, "x\u2028x", 1, 4}, + {2, "x\u2318x", 1, 3}, } for _, tt := range newlineTests { t.Run(fmt.Sprint(tt.buf, " ", tt.offset), func(t *testing.T) { diff -Nru golang-github-tdewolff-parse-2.3.9/strconv/float.go golang-github-tdewolff-parse-2.4.2/strconv/float.go --- golang-github-tdewolff-parse-2.3.9/strconv/float.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/strconv/float.go 2019-12-17 13:35:25.000000000 +0000 @@ -1,6 +1,8 @@ package strconv -import "math" +import ( + "math" +) var float64pow10 = []float64{ 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, @@ -83,8 +85,7 @@ return f * math.Pow10(int(expExp)), i } -const log2 = 0.301029995 -const int64maxlen = 18 +const log2 = 0.3010299956639812 func float64exp(f float64) int { exp2 := 0 @@ -100,11 +101,10 @@ return int(exp10) } +// AppendFloat appends a float to `b` with precision `prec`. It returns the new slice and whether succesful or not. Precision is the number of decimals to display, thus prec + 1 == number of significant digits. func AppendFloat(b []byte, f float64, prec int) ([]byte, bool) { if math.IsNaN(f) || math.IsInf(f, 0) { return b, false - } else if prec >= int64maxlen { - return b, false } neg := false @@ -112,8 +112,8 @@ f = -f neg = true } - if prec == -1 { - prec = int64maxlen - 1 + if prec < 0 || 17 < prec { + prec = 17 // maximum number of significant digits in double } prec -= float64exp(f) // number of digits in front of the dot f *= math.Pow10(prec) diff -Nru golang-github-tdewolff-parse-2.3.9/strconv/float_test.go golang-github-tdewolff-parse-2.4.2/strconv/float_test.go --- golang-github-tdewolff-parse-2.3.9/strconv/float_test.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/strconv/float_test.go 2019-12-17 13:35:25.000000000 +0000 @@ -28,9 +28,11 @@ // {"4.9406564584124e-308", 4.9406564584124e-308) } for _, tt := range floatTests { - f, n := ParseFloat([]byte(tt.f)) - test.That(t, n == len(tt.f), "parsed", n, "characters instead for", tt.f) - test.That(t, f == tt.expected, "return", tt.expected, "for", tt.f) + t.Run(fmt.Sprint(tt.f), func(t *testing.T) { + f, n := ParseFloat([]byte(tt.f)) + test.T(t, n, len(tt.f)) + test.T(t, f, tt.expected) + }) } } @@ -73,12 +75,18 @@ {math.NaN(), 0, ""}, {math.Inf(1), 0, ""}, {math.Inf(-1), 0, ""}, - {0, 19, ""}, - {.000923361977200859392, -1, "9.23361977200859392e-4"}, + {0, 19, "0"}, + {0.000923361977200859392, -1, "9.23361977200859392e-4"}, + {1234, 2, "1.23e3"}, + {12345, 2, "1.23e4"}, + {12.345, 2, "12.3"}, + {12.345, 3, "12.34"}, } for _, tt := range floatTests { - f, _ := AppendFloat([]byte{}, tt.f, tt.prec) - test.String(t, string(f), tt.expected, "for", tt.f) + t.Run(fmt.Sprint(tt.f), func(t *testing.T) { + f, _ := AppendFloat([]byte{}, tt.f, tt.prec) + test.String(t, string(f), tt.expected) + }) } b := make([]byte, 0, 22) diff -Nru golang-github-tdewolff-parse-2.3.9/strconv/int_test.go golang-github-tdewolff-parse-2.4.2/strconv/int_test.go --- golang-github-tdewolff-parse-2.3.9/strconv/int_test.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/strconv/int_test.go 2019-12-17 13:35:25.000000000 +0000 @@ -1,6 +1,7 @@ package strconv import ( + "fmt" "math" "math/rand" "testing" @@ -27,14 +28,16 @@ {"a", 0}, } for _, tt := range intTests { - i, _ := ParseInt([]byte(tt.i)) - test.That(t, i == tt.expected, "return", tt.expected, "for", tt.i) + t.Run(fmt.Sprint(tt.i), func(t *testing.T) { + i, _ := ParseInt([]byte(tt.i)) + test.T(t, i, tt.expected) + }) } } func TestLenInt(t *testing.T) { lenIntTests := []struct { - number int64 + i int64 expected int }{ {0, 1}, @@ -64,7 +67,9 @@ {1000000000000000000, 19}, } for _, tt := range lenIntTests { - test.That(t, LenInt(tt.number) == tt.expected, "return", tt.expected, "for", tt.number) + t.Run(fmt.Sprint(tt.i), func(t *testing.T) { + test.T(t, LenInt(tt.i), tt.expected) + }) } } diff -Nru golang-github-tdewolff-parse-2.3.9/strconv/price_test.go golang-github-tdewolff-parse-2.4.2/strconv/price_test.go --- golang-github-tdewolff-parse-2.3.9/strconv/price_test.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/strconv/price_test.go 2019-12-17 13:35:25.000000000 +0000 @@ -1,6 +1,7 @@ package strconv import ( + "fmt" "testing" "github.com/tdewolff/test" @@ -26,10 +27,11 @@ } for _, tt := range priceTests { - price := AppendPrice(make([]byte, 0, 4), tt.price, tt.dec, ',', '.') - test.String(t, string(price), tt.expected, "for", tt.price) + t.Run(fmt.Sprint(tt.price), func(t *testing.T) { + price := AppendPrice(make([]byte, 0, 4), tt.price, tt.dec, ',', '.') + test.String(t, string(price), tt.expected, "for", tt.price) + }) } // coverage - } diff -Nru golang-github-tdewolff-parse-2.3.9/.travis.yml golang-github-tdewolff-parse-2.4.2/.travis.yml --- golang-github-tdewolff-parse-2.3.9/.travis.yml 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/.travis.yml 2019-12-17 13:35:25.000000000 +0000 @@ -1,6 +1,6 @@ language: go go: - - 1.12.x + - 1.13.x env: - GO111MODULE=on before_install: diff -Nru golang-github-tdewolff-parse-2.3.9/util.go golang-github-tdewolff-parse-2.4.2/util.go --- golang-github-tdewolff-parse-2.3.9/util.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/util.go 2019-12-17 13:35:25.000000000 +0000 @@ -1,5 +1,10 @@ package parse +import ( + "bytes" + "strconv" +) + // Copy returns a copy of the given byte slice. func Copy(src []byte) (dst []byte) { dst = make([]byte, len(src)) @@ -161,37 +166,260 @@ // ReplaceMultipleWhitespace replaces character series of space, \n, \t, \f, \r into a single space or newline (when the serie contained a \n or \r). func ReplaceMultipleWhitespace(b []byte) []byte { - j := 0 - prevWS := false - hasNewline := false - for i, c := range b { - if IsWhitespace(c) { - prevWS = true - if IsNewline(c) { - hasNewline = true + j, k := 0, 0 // j is write position, k is start of next text section + for i := 0; i < len(b); i++ { + if IsWhitespace(b[i]) { + start := i + newline := IsNewline(b[i]) + i++ + for ; i < len(b) && IsWhitespace(b[i]); i++ { + if IsNewline(b[i]) { + newline = true + } } - } else { - if prevWS { - prevWS = false - if hasNewline { - hasNewline = false - b[j] = '\n' + if newline { + b[start] = '\n' + } else { + b[start] = ' ' + } + if 1 < i-start { // more than one whitespace + if j == 0 { + j = start + 1 } else { - b[j] = ' ' + j += copy(b[j:], b[k:start+1]) } - j++ + k = i } - b[j] = b[i] - j++ } } - if prevWS { - if hasNewline { - b[j] = '\n' + if j == 0 { + return b + } else if j == 1 { // only if starts with whitespace + b[k-1] = b[0] + return b[k-1:] + } else if k < len(b) { + j += copy(b[j:], b[k:]) + } + return b[:j] +} + +// replaceEntities will replace in b at index i, assuming that b[i] == '&' and that i+3= '0' && b[j] <= '9' || b[j] >= 'a' && b[j] <= 'f' || b[j] >= 'A' && b[j] <= 'F'); j++ { + if b[j] <= '9' { + c = c<<4 + int(b[j]-'0') + } else if b[j] <= 'F' { + c = c<<4 + int(b[j]-'A') + 10 + } else if b[j] <= 'f' { + c = c<<4 + int(b[j]-'a') + 10 + } + } + if j <= i+3 || 10000 <= c { + return b, j - 1 + } + if c < 128 { + r = []byte{byte(c)} + } else { + r = append(r, '&', '#') + r = strconv.AppendInt(r, int64(c), 10) + r = append(r, ';') + } } else { - b[j] = ' ' + c := 0 + for ; j < len(b) && c < 128 && b[j] >= '0' && b[j] <= '9'; j++ { + c = c*10 + int(b[j]-'0') + } + if j <= i+2 || 128 <= c { + return b, j - 1 + } + r = []byte{byte(c)} } - j++ + } else { + for ; j < len(b) && j-i-1 <= MaxEntityLength && b[j] != ';'; j++ { + } + if j <= i+1 || len(b) <= j { + return b, j - 1 + } + + var ok bool + r, ok = entitiesMap[string(b[i+1:j])] + if !ok { + return b, j + } + } + + // j is at semicolon + n := j + 1 - i + if j < len(b) && b[j] == ';' && 2 < n { + if len(r) == 1 { + if q, ok := revEntitiesMap[r[0]]; ok { + if len(q) == len(b[i:j+1]) && bytes.Equal(q, b[i:j+1]) { + return b, j + } + r = q + } else if r[0] == '&' { + // check if for example & is followed by something that could potentially be an entity + k := j + 1 + if k < len(b) && b[k] == '#' { + k++ + } + for ; k < len(b) && k-j <= MaxEntityLength && (b[k] >= '0' && b[k] <= '9' || b[k] >= 'a' && b[k] <= 'z' || b[k] >= 'A' && b[k] <= 'Z'); k++ { + } + if k < len(b) && b[k] == ';' { + return b, k + } + } + } + + copy(b[i:], r) + copy(b[i+len(r):], b[j+1:]) + b = b[:len(b)-n+len(r)] + return b, i + len(r) - 1 + } + return b, i +} + +// ReplaceEntities replaces all occurrences of entites (such as ") to their respective unencoded bytes. +func ReplaceEntities(b []byte, entitiesMap map[string][]byte, revEntitiesMap map[byte][]byte) []byte { + for i := 0; i < len(b); i++ { + if b[i] == '&' && i+3 < len(b) { + b, i = replaceEntities(b, i, entitiesMap, revEntitiesMap) + } + } + return b +} + +// ReplaceMultipleWhitespaceAndEntities is a combination of ReplaceMultipleWhitespace and ReplaceEntities. It is faster than executing both sequentially. +func ReplaceMultipleWhitespaceAndEntities(b []byte, entitiesMap map[string][]byte, revEntitiesMap map[byte][]byte) []byte { + j, k := 0, 0 // j is write position, k is start of next text section + for i := 0; i < len(b); i++ { + if IsWhitespace(b[i]) { + start := i + newline := IsNewline(b[i]) + i++ + for ; i < len(b) && IsWhitespace(b[i]); i++ { + if IsNewline(b[i]) { + newline = true + } + } + if newline { + b[start] = '\n' + } else { + b[start] = ' ' + } + if 1 < i-start { // more than one whitespace + if j == 0 { + j = start + 1 + } else { + j += copy(b[j:], b[k:start+1]) + } + k = i + } + } + if i+3 < len(b) && b[i] == '&' { + b, i = replaceEntities(b, i, entitiesMap, revEntitiesMap) + } + } + if j == 0 { + return b + } else if j == 1 { // only if starts with whitespace + b[k-1] = b[0] + return b[k-1:] + } else if k < len(b) { + j += copy(b[j:], b[k:]) } return b[:j] } + +func DecodeURL(b []byte) []byte { + for i := 0; i < len(b); i++ { + if b[i] == '%' && i+2 < len(b) { + j := i + 1 + c := 0 + for ; j < i+3 && (b[j] >= '0' && b[j] <= '9' || b[j] >= 'a' && b[j] <= 'z' || b[j] >= 'A' && b[j] <= 'Z'); j++ { + if b[j] <= '9' { + c = c<<4 + int(b[j]-'0') + } else if b[j] <= 'F' { + c = c<<4 + int(b[j]-'A') + 10 + } else if b[j] <= 'f' { + c = c<<4 + int(b[j]-'a') + 10 + } + } + if j == i+3 && c < 128 { + b[i] = byte(c) + b = append(b[:i+1], b[i+3:]...) + } + } else if b[i] == '+' { + b[i] = ' ' + } + } + return b +} + +var URLEncodingTable = [256]bool{ + // ASCII + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + + false, false, true, true, true, true, true, false, // space, !, ' + false, false, false, true, true, false, false, true, // (, ), *, -, . + false, false, false, false, false, false, false, false, // 0, 1, 2, 3, 4, 5, 6, 7 + false, false, true, true, true, true, true, true, // 8, 9 + + true, false, false, false, false, false, false, false, // A, B, C, D, E, F, G + false, false, false, false, false, false, false, false, // H, I, J, K, L, M, N, O + false, false, false, false, false, false, false, false, // P, Q, R, S, T, U, V, W + false, false, false, true, true, true, true, false, // X, Y, Z, _ + + true, false, false, false, false, false, false, false, // a, b, c, d, e, f, g + false, false, false, false, false, false, false, false, // h, i, j, k, l, m, n, o + false, false, false, false, false, false, false, false, // p, q, r, s, t, u, v, w + false, false, false, true, true, true, false, true, // x, y, z, ~ + + // non-ASCII + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, + true, true, true, true, true, true, true, true, +} + +func EncodeURL(b []byte, table [256]bool) []byte { + for i := 0; i < len(b); i++ { + c := b[i] + if table[c] { + b = append(b, 0, 0) + copy(b[i+3:], b[i+1:]) + b[i+0] = '%' + b[i+1] = "0123456789ABCDEF"[c>>4] + b[i+2] = "0123456789ABCDEF"[c&15] + } else if c == ' ' { + b[i] = '+' + } + } + return b +} diff -Nru golang-github-tdewolff-parse-2.3.9/util_test.go golang-github-tdewolff-parse-2.4.2/util_test.go --- golang-github-tdewolff-parse-2.3.9/util_test.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/util_test.go 2019-12-17 13:35:25.000000000 +0000 @@ -3,13 +3,14 @@ import ( "bytes" "math/rand" + "net/url" "regexp" "testing" "github.com/tdewolff/test" ) -func helperRand(n, m int, chars []byte) [][]byte { +func helperRandChars(n, m int, chars string) [][]byte { r := make([][]byte, n) for i := range r { for j := 0; j < m; j++ { @@ -19,12 +20,28 @@ return r } +func helperRandStrings(n, m int, ss []string) [][]byte { + r := make([][]byte, n) + for i := range r { + for j := 0; j < m; j++ { + r[i] = append(r[i], []byte(ss[rand.Intn(len(ss))])...) + } + } + return r +} + //////////////////////////////////////////////////////////////// var wsSlices [][]byte +var entitySlices [][]byte +var encodedUrlSlices [][]byte +var urlSlices [][]byte func init() { - wsSlices = helperRand(100, 20, []byte("abcdefg \n\r\f\t")) + wsSlices = helperRandChars(10000, 50, "abcdefg \n\r\f\t") + entitySlices = helperRandStrings(100, 5, []string{""", "'", "'", " ", " ", "test"}) + encodedUrlSlices = helperRandStrings(100, 5, []string{"%20", "%3D", "test"}) + urlSlices = helperRandStrings(100, 5, []string{"~", "\"", "<", "test"}) } func TestCopy(t *testing.T) { @@ -55,21 +72,191 @@ test.That(t, !IsAllWhitespace([]byte("\t \r\n\fx"))) } +func TestTrim(t *testing.T) { + test.Bytes(t, TrimWhitespace([]byte("a")), []byte("a")) + test.Bytes(t, TrimWhitespace([]byte(" a")), []byte("a")) + test.Bytes(t, TrimWhitespace([]byte("a ")), []byte("a")) + test.Bytes(t, TrimWhitespace([]byte(" ")), []byte("")) +} + func TestReplaceMultipleWhitespace(t *testing.T) { + test.Bytes(t, ReplaceMultipleWhitespace([]byte(" a")), []byte(" a")) + test.Bytes(t, ReplaceMultipleWhitespace([]byte("a ")), []byte("a ")) + test.Bytes(t, ReplaceMultipleWhitespace([]byte("a b ")), []byte("a b ")) + test.Bytes(t, ReplaceMultipleWhitespace([]byte(" a b ")), []byte(" a b ")) + test.Bytes(t, ReplaceMultipleWhitespace([]byte(" a b ")), []byte(" a b ")) + test.Bytes(t, ReplaceMultipleWhitespace([]byte(" a b ")), []byte(" a b ")) + test.Bytes(t, ReplaceMultipleWhitespace([]byte(" a")), []byte(" a")) + test.Bytes(t, ReplaceMultipleWhitespace([]byte("a b")), []byte("a b")) +} + +func TestReplaceMultipleWhitespaceRandom(t *testing.T) { wsRegexp := regexp.MustCompile("[ \t\f]+") wsNewlinesRegexp := regexp.MustCompile("[ ]*[\r\n][ \r\n]*") for _, e := range wsSlices { reference := wsRegexp.ReplaceAll(e, []byte(" ")) reference = wsNewlinesRegexp.ReplaceAll(reference, []byte("\n")) - test.Bytes(t, ReplaceMultipleWhitespace(e), reference, "must remove all multiple whitespace but keep newlines") + test.Bytes(t, ReplaceMultipleWhitespace(Copy(e)), reference, "in '"+string(e)+"'") } } -func TestTrim(t *testing.T) { - test.Bytes(t, TrimWhitespace([]byte("a")), []byte("a")) - test.Bytes(t, TrimWhitespace([]byte(" a")), []byte("a")) - test.Bytes(t, TrimWhitespace([]byte("a ")), []byte("a")) - test.Bytes(t, TrimWhitespace([]byte(" ")), []byte("")) +func TestReplaceEntities(t *testing.T) { + entitiesMap := map[string][]byte{ + "varphi": []byte("ϕ"), + "varpi": []byte("ϖ"), + "quot": []byte("\""), + "apos": []byte("'"), + "amp": []byte("&"), + } + revEntitiesMap := map[byte][]byte{ + '\'': []byte("'"), + } + var entityTests = []struct { + entity string + expected string + }{ + {""", `"`}, + {"'", `'`}, + {""", `"`}, + {"'", `'`}, + {" ", ` `}, + {""", `"`}, + {"'", `'`}, + {"⏧", `⏧`}, + {"⏧", `⏧`}, + {"⏧", `⏧`}, + {"⏧", `⏧`}, + {"✏", `✏`}, + {"✐", `✐`}, + {"'"", `'"`}, + {""", `"`}, + {""", `"`}, + {"&apos", `&apos`}, + {"&", `&`}, + {"'", `'`}, + {"&amp;", `&amp;`}, + {"&#34;", `&#34;`}, + {"&a mp;", `&a mp;`}, + {"&DiacriticalAcute;", `&DiacriticalAcute;`}, + {"&CounterClockwiseContourIntegral;", `&CounterClockwiseContourIntegral;`}, + {"&CounterClockwiseContourIntegralL;", `&CounterClockwiseContourIntegralL;`}, + {"ϕ", "ϕ"}, + {"ϖ", "ϖ"}, + {"&varnone;", "&varnone;"}, + } + for _, tt := range entityTests { + t.Run(tt.entity, func(t *testing.T) { + b := ReplaceEntities([]byte(tt.entity), entitiesMap, revEntitiesMap) + test.T(t, string(b), tt.expected, "in '"+tt.entity+"'") + }) + } +} + +func TestReplaceEntitiesRandom(t *testing.T) { + entitiesMap := map[string][]byte{ + "quot": []byte("\""), + "apos": []byte("'"), + } + revEntitiesMap := map[byte][]byte{ + '\'': []byte("'"), + } + + quotRegexp := regexp.MustCompile(""") + aposRegexp := regexp.MustCompile("('|')") + for _, e := range entitySlices { + reference := quotRegexp.ReplaceAll(e, []byte("\"")) + reference = aposRegexp.ReplaceAll(reference, []byte("'")) + test.Bytes(t, ReplaceEntities(Copy(e), entitiesMap, revEntitiesMap), reference, "in '"+string(e)+"'") + } +} + +func TestReplaceMultipleWhitespaceAndEntities(t *testing.T) { + entitiesMap := map[string][]byte{ + "varphi": []byte("ϕ"), + } + var entityTests = []struct { + entity string + expected string + }{ + {" ϕ " \n ", " ϕ \"\n"}, + } + for _, tt := range entityTests { + t.Run(tt.entity, func(t *testing.T) { + b := ReplaceMultipleWhitespaceAndEntities([]byte(tt.entity), entitiesMap, nil) + test.T(t, string(b), tt.expected, "in '"+tt.entity+"'") + }) + } +} + +func TestReplaceMultipleWhitespaceAndEntitiesRandom(t *testing.T) { + entitiesMap := map[string][]byte{ + "quot": []byte("\""), + "apos": []byte("'"), + } + revEntitiesMap := map[byte][]byte{ + '\'': []byte("'"), + } + + wsRegexp := regexp.MustCompile("[ ]+") + quotRegexp := regexp.MustCompile(""") + aposRegexp := regexp.MustCompile("('|')") + for _, e := range entitySlices { + reference := wsRegexp.ReplaceAll(e, []byte(" ")) + reference = quotRegexp.ReplaceAll(reference, []byte("\"")) + reference = aposRegexp.ReplaceAll(reference, []byte("'")) + test.Bytes(t, ReplaceMultipleWhitespaceAndEntities(Copy(e), entitiesMap, revEntitiesMap), reference, "in '"+string(e)+"'") + } +} + +func TestDecodeURL(t *testing.T) { + var urlTests = []struct { + url string + expected string + }{ + {"%20%3F%7E", " ?~"}, + {"%80", "%80"}, + {"%2B%2b", "++"}, + {"%' ", "%' "}, + {"a+b", "a b"}, + } + for _, tt := range urlTests { + t.Run(tt.url, func(t *testing.T) { + b := DecodeURL([]byte(tt.url)) + test.T(t, string(b), tt.expected, "in '"+tt.url+"'") + }) + } +} + +func TestDecodeURLRandom(t *testing.T) { + for _, e := range encodedUrlSlices { + reference, _ := url.QueryUnescape(string(e)) + test.Bytes(t, DecodeURL(Copy(e)), []byte(reference), "in '"+string(e)+"'") + } +} + +func TestEncodeURL(t *testing.T) { + var urlTests = []struct { + url string + expected string + }{ + {"AZaz09-_.!~*'()", "AZaz09-_.!~*'()"}, + {"<>", "%3C%3E"}, + {"\u2318", "%E2%8C%98"}, + {"a b", "a+b"}, + } + for _, tt := range urlTests { + t.Run(tt.url, func(t *testing.T) { + b := EncodeURL([]byte(tt.url), URLEncodingTable) + test.T(t, string(b), tt.expected, "in '"+tt.url+"'") + }) + } +} + +func TestEncodeURLRandom(t *testing.T) { + for _, e := range urlSlices { + reference := url.QueryEscape(string(e)) + test.Bytes(t, EncodeURL(Copy(e), URLEncodingTable), []byte(reference), "in '"+string(e)+"'") + } } //////////////////////////////////////////////////////////////// @@ -90,7 +277,7 @@ } } -func BenchmarkReplace(b *testing.B) { +func BenchmarkReplaceMultipleWhitespace(b *testing.B) { for i := 0; i < b.N; i++ { for _, e := range wsSlices { ReplaceMultipleWhitespace(e) diff -Nru golang-github-tdewolff-parse-2.3.9/xml/lex.go golang-github-tdewolff-parse-2.4.2/xml/lex.go --- golang-github-tdewolff-parse-2.3.9/xml/lex.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/xml/lex.go 2019-12-17 13:35:25.000000000 +0000 @@ -92,6 +92,21 @@ l.r.Restore() } +// Offset returns the current position in the input stream. +func (l *Lexer) Offset() int { + return l.r.Offset() +} + +// Text returns the textual representation of a token. This excludes delimiters and additional leading/trailing characters. +func (l *Lexer) Text() []byte { + return l.text +} + +// AttrVal returns the attribute value when an AttributeToken was returned from Next. +func (l *Lexer) AttrVal() []byte { + return l.attrVal +} + // Next returns the next Token. It returns ErrorToken when an error was encountered. Using Err() one can retrieve the error message. func (l *Lexer) Next() (TokenType, []byte) { l.text = nil @@ -107,25 +122,22 @@ } if c == 0 { if l.r.Err() == nil { - l.err = parse.NewErrorLexer("unexpected null character", l.r) + l.err = parse.NewErrorLexer(l.r, "XML parse error: unexpected NULL character") } return ErrorToken, nil } else if c != '>' && (c != '/' && c != '?' || l.r.Peek(1) != '>') { return AttributeToken, l.shiftAttribute() } - start := l.r.Pos() + l.r.Skip() l.inTag = false if c == '/' { l.r.Move(2) - l.text = l.r.Lexeme()[start:] return StartTagCloseVoidToken, l.r.Shift() } else if c == '?' { l.r.Move(2) - l.text = l.r.Lexeme()[start:] return StartTagClosePIToken, l.r.Shift() } else { l.r.Move(1) - l.text = l.r.Lexeme()[start:] return StartTagCloseToken, l.r.Shift() } } @@ -134,7 +146,8 @@ c = l.r.Peek(0) if c == '<' { if l.r.Pos() > 0 { - return TextToken, l.r.Shift() + l.text = l.r.Shift() + return TextToken, l.text } c = l.r.Peek(1) if c == '/' { @@ -163,10 +176,11 @@ return StartTagToken, l.shiftStartTag() } else if c == 0 { if l.r.Pos() > 0 { - return TextToken, l.r.Shift() + l.text = l.r.Shift() + return TextToken, l.text } if l.r.Err() == nil { - l.err = parse.NewErrorLexer("unexpected null character", l.r) + l.err = parse.NewErrorLexer(l.r, "XML parse error: unexpected NULL character") } return ErrorToken, nil } @@ -174,16 +188,6 @@ } } -// Text returns the textual representation of a token. This excludes delimiters and additional leading/trailing characters. -func (l *Lexer) Text() []byte { - return l.text -} - -// AttrVal returns the attribute value when an AttributeToken was returned from Next. -func (l *Lexer) AttrVal() []byte { - return l.attrVal -} - //////////////////////////////////////////////////////////////// // The following functions follow the specifications at http://www.w3.org/html/wg/drafts/html/master/syntax.html diff -Nru golang-github-tdewolff-parse-2.3.9/xml/lex_test.go golang-github-tdewolff-parse-2.4.2/xml/lex_test.go --- golang-github-tdewolff-parse-2.3.9/xml/lex_test.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/xml/lex_test.go 2019-12-17 13:35:25.000000000 +0000 @@ -160,7 +160,20 @@ col int }{ {"a\x00b", 2}, - {"", 3}, + {"<\x00 b='5'>", 2}, + {"", 3}, + {"", 4}, + {"", 5}, + {"", 6}, + {"", 7}, + {"", 3}, + {"", 4}, + {"text`)) + _, data := l.Next() + test.Bytes(t, data, []byte("")) + test.Bytes(t, l.Text(), nil) + test.Bytes(t, l.AttrVal(), nil) + + _, data = l.Next() + test.Bytes(t, data, []byte("text")) + test.Bytes(t, l.Text(), []byte("text")) + test.Bytes(t, l.AttrVal(), nil) + + _, data = l.Next() + test.Bytes(t, data, []byte("")) + test.Bytes(t, l.Text(), []byte("comment")) + test.Bytes(t, l.AttrVal(), nil) + + _, data = l.Next() + test.Bytes(t, data, []byte("")) + test.Bytes(t, l.Text(), []byte(" doctype")) + test.Bytes(t, l.AttrVal(), nil) + + _, data = l.Next() + test.Bytes(t, data, []byte("")) + test.Bytes(t, l.Text(), []byte("cdata")) + test.Bytes(t, l.AttrVal(), nil) +} + +func TestOffset(t *testing.T) { + l := NewLexer(bytes.NewBufferString(`
text
`)) + test.T(t, l.Offset(), 0) + _, _ = l.Next() + test.T(t, l.Offset(), 4) //
+ _, _ = l.Next() + test.T(t, l.Offset(), 20) // text + _, _ = l.Next() + test.T(t, l.Offset(), 26) //
+} + //////////////////////////////////////////////////////////////// func ExampleNewLexer() { diff -Nru golang-github-tdewolff-parse-2.3.9/xml/util.go golang-github-tdewolff-parse-2.4.2/xml/util.go --- golang-github-tdewolff-parse-2.3.9/xml/util.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/xml/util.go 2019-12-17 13:35:25.000000000 +0000 @@ -1,7 +1,5 @@ package xml -import "github.com/tdewolff/parse/v2" - var ( ltEntityBytes = []byte("<") ampEntityBytes = []byte("&") @@ -9,20 +7,19 @@ doubleQuoteEntityBytes = []byte(""") ) +// Entities are all named character entities. +var EntitiesMap = map[string][]byte{ + "apos": []byte("'"), + "gt": []byte(">"), + "quot": []byte("\""), +} + // EscapeAttrVal returns the escape attribute value bytes without quotes. func EscapeAttrVal(buf *[]byte, b []byte) []byte { singles := 0 doubles := 0 - for i, c := range b { - if c == '&' { - if quote, n := parse.QuoteEntity(b[i:]); n > 0 { - if quote == '"' { - doubles++ - } else { - singles++ - } - } - } else if c == '"' { + for _, c := range b { + if c == '"' { doubles++ } else if c == '\'' { singles++ @@ -49,18 +46,7 @@ j := 1 start := 0 for i, c := range b { - if c == '&' { - if entityQuote, n := parse.QuoteEntity(b[i:]); n > 0 { - j += copy(t[j:], b[start:i]) - if entityQuote != quote { - t[j] = entityQuote - j++ - } else { - j += copy(t[j:], escapedQuote) - } - start = i + n - } - } else if c == quote { + if c == quote { j += copy(t[j:], b[start:i]) j += copy(t[j:], escapedQuote) start = i + 1 diff -Nru golang-github-tdewolff-parse-2.3.9/xml/util_test.go golang-github-tdewolff-parse-2.4.2/xml/util_test.go --- golang-github-tdewolff-parse-2.3.9/xml/util_test.go 2019-08-22 18:19:17.000000000 +0000 +++ golang-github-tdewolff-parse-2.4.2/xml/util_test.go 2019-12-17 13:35:25.000000000 +0000 @@ -11,15 +11,14 @@ attrVal string expected string }{ - {"xyz", "\"xyz\""}, - {"", "\"\""}, - {"x&z", "\"x&z\""}, - {"x'z", "\"x'z\""}, - {"x\"z", "'x\"z'"}, - {"a'b=\"\"", "'a'b=\"\"'"}, - {"'x'\"'z'", "\"x'"'z\""}, - {"\"x"'"z\"", "'x\"'\"z'"}, - {"a'b=\"\"", "'a'b=\"\"'"}, + {`xyz`, `"xyz"`}, + {``, `""`}, + {`x'z`, `"x'z"`}, + {`x"z`, `'x"z'`}, + {`a'b=""`, `'a'b=""'`}, + {`'x'"'z'`, `"x'"'z"`}, + {`"x"'"z"`, `'x"'"z'`}, + {`a'b=""`, `'a'b=""'`}, } var buf []byte for _, tt := range attrValTests { @@ -47,6 +46,7 @@ {"", ""}, {"", " a "}, {"", ""}, + {"", " a ]]&gt; b "}, } var buf []byte for _, tt := range CDATAValTests {