mochiweb_html no function clause matching

52 views
Skip to first unread message

jm

unread,
May 15, 2009, 9:09:11 PM5/15/09
to moch...@googlegroups.com

When feeding mochiweb_html:parse(Body) the html from
http://en.wikipedia.org/ which starts off,


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
...
...

I get this error:

** exception error: no function clause matching
mochiweb_html:tokenize_attributes(<<"<!DOCTYPE html PUBLIC \"-//W3C//DTD
XHTML 1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitio"...>>,

{whitespace," ",{decoder,31,16,3235}},

[{<<"type">>,error}])
in function mochiweb_html:tokenize/2
in call from mochiweb_html:tokens/3
in call from mochiweb_html:parse/1

However, it feeding it pages such as http://google.com/ or some other
pages it works. I also tested with http://uk.yahoo.com/?p=us and this
generates a similar error. Is there an easy way to fix this?

Would I be right in guessing that it's the "<!" throwing it?

Jeff.

Bob Ippolito

unread,
May 17, 2009, 4:12:15 PM5/17/09
to moch...@googlegroups.com

That's not the right guess, because it's supposed to support <!DOCTYPE
-- you can see it in some of the tests.

I'm looking into it now.

-bob

Bob Ippolito

unread,
May 17, 2009, 4:23:14 PM5/17/09
to moch...@googlegroups.com

It turns out that it's because there is a script tag with an
extraneous whitespace character in the attribute (at least the
wikipedia example that you gave)

<script type= "text/javascript">

If that space is eliminated, the current parser has no problem with
that page. It shouldn't be hard to write a test for and fix this.

1> mochiweb_html:parse("<script type=\"text/javascript\"></script>").
{<<"script">>,[{<<"type">>,<<"text/javascript">>}],[<<>>]}
2> mochiweb_html:parse("<script type= \"text/javascript\"></script>").


** exception error: no function clause matching

mochiweb_html:tokenize_attributes(<<"<script type=
\"text/javascript\"></script>">>,
{whitespace," ",
{decoder,1,14,13}},


[{<<"type">>,error}])
in function mochiweb_html:tokenize/2
in call from mochiweb_html:tokens/3
in call from mochiweb_html:parse/1

-bob

Bob Ippolito

unread,
May 17, 2009, 4:30:41 PM5/17/09
to moch...@googlegroups.com

jm

unread,
May 18, 2009, 1:16:41 AM5/18/09
to moch...@googlegroups.com

Bob Ippolito wrote:
> Fixed in http://code.google.com/p/mochiweb/source/detail?r=101
>
>
>

Yeap. That fixes it. I actually discovered this while using
mochiweb_html from mochixpath. Can you fold this new version of
mochiweb_html into mochixpath for future users of that package?

Thanks,
Jeff.

Bob Ippolito

unread,
May 18, 2009, 11:53:59 AM5/18/09
to moch...@googlegroups.com

mochixpath isn't part of our source tree, someone else wrote that.

-bob

Reply all
Reply to author
Forward
0 new messages