launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #00872
[Merge] lp:~sinzui/launchpad/question-title-0 into lp:launchpad/devel
Curtis Hovey has proposed merging lp:~sinzui/launchpad/question-title-0 into lp:launchpad/devel.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
#583623 impossible length titles cause oopes
https://bugs.launchpad.net/bugs/583623
This is my branch to prevent users from entering long question summaries.
lp:~sinzui/launchpad/question-title-0
Diff size: 84
Launchpad bug:
https://bugs.launchpad.net/bugs/583623
Test command: ./bin/test -vv -t TestQuestionAddView
Pre-implementation: no one
Target release: 10.09
Prevent users from entering long question summaries
----------------------------------------------------
OOPS-1601O1172 was caused when the user pasted an error log into the title
field. The field should restrict the title to a reasonable
Discovering a reasonable length took some time, looking at question titles
in the db, and at bug titles (because we want bugs to be convertible to
questions). Changing the field definition has a secondary complication--we
would need to update all the existing questions that have titles that are
too long. Since we really want comments to work on way in Launchpad, a
better approach is to ensure the view does not let the user provide too
much information.
Rules
-----
The simplest fix for this issue is to use displayMaxWidth=250 in the
QuestionAddView to tell the browser to ignore characters after 250.
custom_widget('title', TextWidget, displayWidth=40, displayMaxWidth=250)
But in the case where users are posting from a non-lp form (I am speculating)
we can add a constraint to the view to return a field error too. This is also
easier to test than browser compliance.
QA
--
* On staging, as a question with more than 250 characters.
* Verify the page says the question summary cannot exceed 250 characters.
Lint
----
Linting changed files:
lib/lp/answers/browser/question.py
lib/lp/answers/browser/tests/test_question.py
Test
----
I renamed the existing module to test_views since it it is loading doctests
for question and faq views.
* lib/lp/answers/browser/tests/test_question.py
* Added tests for the max length of the title field.
Implementation
--------------
* lib/lp/answers/browser/question.py
* Added a validation rule to report an error if the question title is
exceeds 250 characters.
* Added displayMaxWidth to the html element so that users can see that
the excessive content is ignored.
--
https://code.launchpad.net/~sinzui/launchpad/question-title-0/+merge/34608
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~sinzui/launchpad/question-title-0 into lp:launchpad/devel.
Follow ups