Advertisement:

Author Topic: MWAHAHAHA! I found one!  (Read 3212 times)

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,046
  • Master of BBC Abuse
MWAHAHAHA! I found one!
« on: April 15, 2012, 08:47:08 PM »
Applies to 1.1.x and 2.0.x and 2.1 alpha. Hey, at least we're consistent, right. ;)

Anyway, although personal text has a 50 character limit on it, for some reason the custom title has never had any limit. You can just keep merrily typing in characters until your database freaks. This seems to not be a good thing, since IMO the custom title should be short and sweet, given it's location. Fix is easy.

1.1.x - Profile.template.php

Find:
Code: [Select]
<td><input type="text" name="usertitle" size="50" value="' . $context['member']['title'] . '" /></td>
Replace:
Code: [Select]
<td><input type="text" name="usertitle" size="50" maxlength="50" value="' . $context['member']['title'] . '" /></td>
2.0.x and 2.1 Alpha - Profile-Modify.php

Find:
Code: [Select]
'usertitle' => array(
'type' => 'text',
'label' => $txt['custom_title'],
'log_change' => true,

Replace:
Code: [Select]
'usertitle' => array(
'type' => 'text',
'label' => $txt['custom_title'],
'log_change' => true,
'input_attr' => array('maxlength="50"'),

Personally I'd be inclined to restrict the title to 32 characters, but whatever. 50 is consistent with the current input size.
"My idea of heaven consists of all the things I would go to Hell for."

I need another coding language like I need tertiary syphilis.

Antechinus modzRantyheinous themez - PSD pack for 2.0.x default theme

Online Colin

  • Customizer
  • SMF Hero
  • *
  • Posts: 4,776
  • Gender: Male
  • SMF Customizer
Re: MWAHAHAHA! I found one!
« Reply #1 on: April 15, 2012, 08:48:11 PM »
LOL, how did you even find that :). Good one though.

Offline IchBin™

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,918
  • Gender: Male
  • I don't speak German.
    • IchBin.us
Re: MWAHAHAHA! I found one!
« Reply #2 on: April 15, 2012, 08:54:56 PM »
Should be limited at the database table though. It's a varchar(255). But yes, I agree that it could be limited at the frontend like that. But more importantly cut it off in the source.
Brad "IchBin™" Grow        TinyPortal        Themes
Coding Guidelines       

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,046
  • Master of BBC Abuse
Re: MWAHAHAHA! I found one!
« Reply #3 on: April 15, 2012, 08:57:37 PM »
Oh I was testing new theme ideas for 2.1 alpha, and played around with the custom title while testing to see how layout might possibly break. Went "WTF?" when I realised the custom title could just keep going ad infinitum.

Actually it may have a 256 character limit, depending on the type of db field it is. Haven't looked at that, but fixing it in Sources makes sense anyway.

Ok, well we can change the db field too if that's preferable. I was just fixing my own site since I was tired of the occasional wally posting a bloody sonnet up there. :D

ETA: Actually it may be better to leave the limit in the files. More accessible for some people, if they want to change it, and all the others are limited in the arrays anyway.
"My idea of heaven consists of all the things I would go to Hell for."

I need another coding language like I need tertiary syphilis.

Antechinus modzRantyheinous themez - PSD pack for 2.0.x default theme

Offline emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 11,874
  • Gender: Male
  • Because Orange is Orange
Re: MWAHAHAHA! I found one!
« Reply #4 on: April 16, 2012, 05:51:20 AM »
And let's not forget the related one: http://dev.simplemachines.org/mantis/view.php?id=4919 :P

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,046
  • Master of BBC Abuse
Re: MWAHAHAHA! I found one!
« Reply #5 on: April 16, 2012, 07:06:15 AM »
Ok, I wont forget it. :P
"My idea of heaven consists of all the things I would go to Hell for."

I need another coding language like I need tertiary syphilis.

Antechinus modzRantyheinous themez - PSD pack for 2.0.x default theme

Offline emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 11,874
  • Gender: Male
  • Because Orange is Orange
Re: MWAHAHAHA! I found one!
« Reply #6 on: April 17, 2012, 05:27:15 AM »
Okay, yet another edit: we already have the "size" attribute for the field, why don't we use that one instead?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,046
  • Master of BBC Abuse
Re: MWAHAHAHA! I found one!
« Reply #7 on: April 17, 2012, 10:01:31 AM »
EH? You mean for the Sources array or you mean in the varchar itself? Either way, I agree. Go for it. :D

Earlier I was thinking that if anyone wanted to change it, having it in the file might be more accessible from some people. Then I thought about it a bit more, and realised editing Sources files is a nightmare for n00bz anyway and it may well be less frightening if they just rock on down to phpMyAdmin and change the varchar.
"My idea of heaven consists of all the things I would go to Hell for."

I need another coding language like I need tertiary syphilis.

Antechinus modzRantyheinous themez - PSD pack for 2.0.x default theme

Offline emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 11,874
  • Gender: Male
  • Because Orange is Orange
Re: MWAHAHAHA! I found one!
« Reply #8 on: April 18, 2012, 12:02:59 PM »
What I mean is that in the definition of the "field", for example:
Code: [Select]
'website_title' => array(
'type' => 'text',
'label' => $txt['website_title'],
'subtext' => $txt['include_website_url'],
'size' => 50,
'permission' => 'profile_extra',
'link_with' => 'website',
),
there is already a 'size' attribute.
This 'size' is used to define the input box size, the only reason I didn't yet apply the change is that this size will affect many fields at the same time (including passwords).
I would avoid adding yet another attribute just to set the limits of the field, so I'm wondering if it is better to continue use the size for the input box and set the limits to the double of that amount (i.e. website title has size 50, it will be cut at 100 chars) or use the size to define the string limit and set the size of the input box to the half of it (i.e. set size for website_title to 100 and then cut the $_POST to 100 and draw the input at 50 (=100/2))

...for compatibility the first is better I think.

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Offline Antechinus

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 22,046
  • Master of BBC Abuse
Re: MWAHAHAHA! I found one!
« Reply #9 on: April 18, 2012, 05:48:54 PM »
:D Hoenstly, I'd just add a bloody limit to the fields that need them and be done with it. 32 is more than enough for a custom title IMO.
"My idea of heaven consists of all the things I would go to Hell for."

I need another coding language like I need tertiary syphilis.

Antechinus modzRantyheinous themez - PSD pack for 2.0.x default theme

Offline emanuele

  • Developer
  • SMF Super Hero
  • *
  • Posts: 11,874
  • Gender: Male
  • Because Orange is Orange
Re: MWAHAHAHA! I found one!
« Reply #10 on: July 25, 2012, 03:09:19 PM »
Bump this one to remember I did a commit about it.

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.