hackers-painters / katana-parser

A CSS parsing library in pure C99
http://hackers-painters.github.io/katana-parser
MIT License
180 stars 40 forks source link

How to parse URL strings? #25

Open gogo9th opened 4 years ago

gogo9th commented 4 years ago

Hi,

I Find Katana parser really useful and thanks for developing this tool for us. I just realized the following is not parsable:

@font-face { font-weight: 700; src: url(https://fonts.gstatic.com/s/ytsans/v8/46kqlb3ta3zqoJU2dfPhb0xg0mlY.woff2); }

Is there any way for us to include styles that start with @?

gogo9th commented 4 years ago

I solved the above issue, but Katana seems to have a bug: it cannot parse the stylesheet below:

My error is:

================================================================= ==4484==ERROR: AddressSanitizer: global-buffer-overflow on address 0x7f7dd54d6023 at pc 0x7f7dd5761733 bp 0x7ffc6b417700 sp 0x7ffc6b416ea8 READ of size 4 at 0x7f7dd54d6023 thread T0

0 0x7f7dd5761732 (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x79732)

#1 0x7f7dd549477e in katana_string_to_characters src/foundation.c:113
#2 0x7f7dd54bf6e3 in katana_new_number_value src/parser.c:656
#3 0x7f7dd54b6289 in katanaparse src/katana.tab.c:2809
#4 0x7f7dd54bd622 in katana_parse_in src/parser.c:232
#5 0x560bcf5192f6 in dump_stylesheet examples/dump_stylesheet.c:27
#6 0x560bcf51a1bb in main examples/dump_stylesheet.c:124
#7 0x7f7dd50b2b96 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b96)
#8 0x560bcf519099 in _start (/root/katana-parser/a+0x1099)
gogo9th commented 4 years ago

src/katana.tab.c: 2808 --- number.raw = (KatanaParserString){"to", 4}; +++ number.raw = (KatanaParserString){"to", 2};

But there is still an error for this:

.rp_userbox-container::before { }

@supports (align: auto) { }

~