Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#4276 closed (fixed)

django.contrib.webdesign's {% lorem N w %} fails where N >= 20

Reported by: Trent Mick <trentm@…> Owned by: adrian
Component: Contrib apps Version: master
Severity: Keywords: webdesign lorem ipsum
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

The code path handling inserting 20 or more lorem ipsum words (django/contrib/webdesign/lorem_ipsum.py: def words) ends up passing a negative number as the second argument to random.sample().

As well, the function would also fail if the requested word count was greater than len(WORDS). I have a patch that corrects this.

Attachments (1)

lorem_words.diff (1002 bytes) - added by Trent Mick <trentm@…> 8 years ago.
patch to fix the issues described

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by Trent Mick <trentm@…>

patch to fix the issues described

comment:1 Changed 8 years ago by Trent Mick <trentm@…>

Note as well that the django/contrib/webdesign files should have the svn:eol-style=native property added to them:

cd django/contrib/webdesign
find . -name "*.py" | xargs svn ps svn:eol-style native

Cheers

comment:2 Changed 8 years ago by mtredinnick

(In [5189]) Added native eol-style settings to necessary files. Refs #4276.

comment:3 follow-up: Changed 8 years ago by mtredinnick

Was the problem case you are referring to something like this:

{% lorem 32 w %}

I'm going to commit a slightly simpler patch that fixes this and close the ticket. If there's another example that fails, could you reopen and give the example. It's hard to write a test for this code, since the output is random, but I'd at least like to make sure we're fixing the right problem here.

comment:4 Changed 8 years ago by mtredinnick

  • Resolution set to fixed
  • Status changed from new to closed

(In [5190]) Fixed #4276 -- Fixed a crash in the lorem tag when more than 20 words were
requested.

comment:5 in reply to: ↑ 3 Changed 8 years ago by mtredinnick

Replying to mtredinnick:

Was the problem case you are referring to something like this:

{% lorem 32 w %}

Doh! That was the case mentioned in the ticket title. I was concentrating on the summary too much. Nothing to see here. Move along. :-(

Note: See TracTickets for help on using tickets.
Back to Top