r68767 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68766‎ | r68767 | r68768 >
Date:09:18, 30 June 2010
Author:jojo
Status:ok (Comments)
Tags:
Comment:
cut too-long chapter titles preventing people from abusing them as content
Modified paths:
  • /trunk/extensions/Collection/js/collection.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Collection/js/collection.js
@@ -54,6 +54,8 @@
5555 var script_url = wgServer +
5656 ((wgScript == null) ? (wgScriptPath + "/index.php") : wgScript);
5757
 58+var chapter_max_len = 200;
 59+
5860 /******************************************************************************/
5961
6062 function getMWServeStatus() {
@@ -101,6 +103,7 @@
102104 function create_chapter() {
103105 var name = prompt(gettext('#newChapterText'));
104106 if (name) {
 107+ name = name.substring(0, chapter_max_len);
105108 req('AddChapter', [name], refresh_list);
106109 }
107110 return false;
@@ -109,6 +112,7 @@
110113 function rename_chapter(index, old_name) {
111114 var new_name = prompt(gettext('#renameChapterText'), old_name);
112115 if (new_name) {
 116+ new_name = new_name.substring(0, chapter_max_len);
113117 req('RenameChapter', [index, new_name], refresh_list);
114118 }
115119 return false;

Comments

#Comment by Nikerabbit (talk | contribs)   09:39, 30 June 2010

Why is the abuse a problem?

#Comment by Jbeigel (talk | contribs)   09:41, 30 June 2010

Some people paste complete paragraphs into these JS prompts. The chapter titles get rendered in a big font size and cause trouble when rendering the collection – at the very least the result will be unpleasing and most probably not what the user intended anyway.

#Comment by Nikerabbit (talk | contribs)   09:47, 30 June 2010

Any idea why they do that? Is the input of correct size? Does it have a proper label? Can you set maximum length to the input field itself so that users notice when it gets full?

#Comment by Jbeigel (talk | contribs)   09:53, 30 June 2010

There is no <input>: it's a call to prompt() which is triggered when a user wants to add or rename a chapter. The prompt() contains localized text as label. AFAIK there is no way to restrict the maximum number of characters for prompt(). There is no security problem or anything like that w/ long chapter titles, so the quick-fix was to implement this in the JS code which should suffice for the relevant use-cases.

#Comment by Jbeigel (talk | contribs)   09:58, 30 June 2010

BTW: a 200 character title for a chapter will result in approx. 14 lines in a rendered PDF.

Status & tagging log