Closed Bug 566101 Opened 12 years ago Closed 12 years ago

[k] IndexError: string index out of range


( :: Forum, task, P1)


(Not tracked)



(Reporter: stephend, Assigned: paulc)




Traceback on

Traceback (most recent call last):

  File "/data/virtualenvs/kitsune/src/django/django/core/handlers/", line 101, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/data/www/", line 92, in posts
    'posts': posts_, 'form': form})

  File "/data/virtualenvs/kitsune/src/jingo/jingo/", line 61, in render
    rendered = render_to_string(request, template, context)

  File "/data/virtualenvs/kitsune/src/jingo/jingo/", line 80, in render_to_string
    ret = template.render(**context)

  File "/data/virtualenvs/kitsune/lib64/python2.6/site-packages/jinja2/", line 669, in render
    return self.environment.handle_exception(exc_info, True)

  File "/data/www/", line 5, in top-level template code
    {% set crumbs = [(url('forums.forums'), _('Forums')),

  File "/data/www/", line 2, in top-level template code
    {% extends "layout/base.html" %}

  File "/data/www/", line 40, in top-level template code
    {% block content_area %}

  File "/data/www/", line 8, in block "content_area"
    {% block content %}

  File "/data/www/", line 29, in block "content"
    {{ post.content_parsed }}

  File "/data/virtualenvs/kitsune/lib64/python2.6/site-packages/jinja2/", line 350, in getattr
    return getattr(obj, attribute)

  File "/data/www/", line 120, in content_parsed
    return jinja2.Markup(parser.parse(self.content, False))

  File "/data/www/", line 56, in parse
    return self.wikimarkup.parse(text, showToc)

  File "/data/virtualenvs/kitsune/src/py-wikimarkup/wikimarkup/", line 2278, in parse
    return p.parse(text)

  File "/data/virtualenvs/kitsune/src/py-wikimarkup/wikimarkup/", line 1676, in parse
    text = self.removeHtmlTags(text)

  File "/data/virtualenvs/kitsune/src/py-wikimarkup/wikimarkup/", line 595, in removeHtmlTags
    text = self.removeHtmlComments(text)

  File "/data/virtualenvs/kitsune/src/py-wikimarkup/wikimarkup/", line 706, in removeHtmlComments
    while text[spaceEnd] == u' ':

IndexError: string index out of range
Obviously, this should be a 404. We should try to fix this in the paginator if possible. I'll grab it and give it a shot on Tuesday.
Assignee: nobody → james
Summary: [k] IndexError: string index out of rage → [k] IndexError: string index out of range
The issue is not that the page doesn't exist. It seems like something got posted that the markup parser isn't handling too well. We probably need to get the data (replies for page 2)?
In bug 567382 comment 1 I've asked IT to dump the forums_post table for us before resyncing support-stage-new's database after yesterday's push.
Let me know if you want me to take this.
It looks like an opening <!-- without a closing --> is at fault here.

Playing with it locally, it seems like we can skip the wikiparser's removeHtmlComments completely and rely on Bleach, since html5lib seems to drop comments completely, especially unclosed ones.

!BUT! this also means we need to make sure that min_length is still respected even after the markup is processed (gotta parse it on save, check the length, and save the raw, unparsed version).
Assignee: james → paulc
Priority: -- → P1
Removed the unnecessary call to removeHtmlComments from the parser. That doesn't actually fix this bug but it's related, so meh:

The fix for this bug was actually in bleach - for that, see bug 568317.
Closed: 12 years ago
Resolution: --- → FIXED
Verified FIXED.
You need to log in before you can comment on or make changes to this bug.