Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

JoomlaTune Support Forum    JComments component    Bug-reports    Topic: serious Layout Bug
Pages: [1]   Go Down
  Print  
Author Topic: serious Layout Bug  (Read 2185 times)
0 Members and 1 Guest are viewing this topic.
mark25
Newbie
*

Karma: 0
Offline Offline

Posts: 5


« on: May 31, 2010, 17:57:57 »

I use the newest version of JC an Joomla 1.5

There is an important bug in JC:

If a user types too many letters without any interruption or blank fields, then the whole layout of the site is disruptet.


This way, a user can sabotage a site (happend also to me)


Example: If a user wants to attack my site, then he can type simply something like this:

...

after a certain amount of points the site gets extended to the right, shifting the right column to "outer space".

The same effect happens if u typ something like:

ajsdfjskljdfkjdkajdfklfjaskdfhjksadhfjkashdfjksdhkjhaskjhdfasdhfasdhkjkljkjkjlökjkljasdajhjsadhkjsdhjkhfdshsf


PROBLEM: JC Comments does not force a break after a certain amount of characters. Consequence: layout is destroyed


Same effect also, if many videos in one field are embedded.


Is there any solution? (Note: the problem did not happen with joomla 1.x and the old version of JC)

Apart from this, your module is really working great!!





Logged
smart
Administrator
Hero Member
*****

Karma: 146
Offline Offline

Gender: Male
Posts: 2579



WWW
« Reply #1 on: May 31, 2010, 18:30:48 »

If a user types too many letters without any interruption or blank fields, then the whole layout of the site is disruptet.
You could setup this in JComments settings (Restrictions tab, 'Break up words with more letters than' parameter).
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
mark25
Newbie
*

Karma: 0
Offline Offline

Posts: 5


« Reply #2 on: May 31, 2010, 21:50:48 »

Hi, these restrictions are only working with letters

NOT wit numbers 1223455 etc
and NOT with special signs like points, comma, etx .,-#*+

If u use points or comma or even simple numbers the break is not forced and layout of site is then damaged.
Logged
smart
Administrator
Hero Member
*****

Karma: 146
Offline Offline

Gender: Male
Posts: 2579



WWW
« Reply #3 on: June 01, 2010, 03:38:58 »

More effective solution is replacing code (in jcomments.class.php):

Code: (php)
/**
* Inserts a separator in a very long continuous sequences of characters
* @static
* @param  $text string The input string.
* @param  $maxLength int The maximum length of sequence.
* @param  $customBreaker string The custom string to be used as breaker.
* @return string Returns the altered string.
*/
function fixLongWords( $text, $maxLength, $customBreaker = '')
{
$maxLength = (int) min(65535, $maxLength);

if ($maxLength > 5) {
ob_start();
if ($customBreaker == '') {
if (!empty($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) {
$breaker = '<span style="margin: 0 -0.65ex 0 -1px;padding:0;"> </span>';
} else {
$breaker = '<span style="font-size:0;padding:0;margin:0;"> </span>';
}
} else {
$breaker = $customBreaker;
}

$plainText = $text;
$plainText = preg_replace('#<img[^\>]+/>#isU', '', $plainText);
$plainText = preg_replace('#<a.*?>(.*?)</a>#isU', '', $plainText);
$plainText = preg_replace('#<object.*?>(.*?)</object>#isU', '', $plainText);
$plainText = preg_replace('#<code.*?>(.*?)</code>#isU', '', $plainText);
$plainText = preg_replace('#<embed.*?>(.*?)</embed>#isU', '', $plainText);
$plainText = preg_replace('#(^|\s|\>|\()((http://|https://|news://|ftp://|www.)\w+[^\s\[\]\<\>\"\'\)]+)#i', '', $plainText);

$matches = array();
$matchCount = preg_match_all('#([^\s<>\'\"/\.\x133\x151\\-\?&%=\n\r\%]{'.$maxLength.'})#i' . JCOMMENTS_PCRE_UTF8, $plainText, $matches);
for ($i = 0; $i < $matchCount; $i++) {
$text = preg_replace("#(".preg_quote($matches[1][$i], '#').")#i" . JCOMMENTS_PCRE_UTF8, "\\1".$breaker, $text);
}
$text = preg_replace('#('.preg_quote($breaker, '#').'\s)#i' . JCOMMENTS_PCRE_UTF8, " ", $text);
unset($matches);
ob_end_clean();
}
return $text;
}
with
Code: (php)
/**
* @param  $str The input string.
* @param  $width The column width.
* @param  $break The line is broken using the optional break parameter.
* @param bool $cut If the cut is set to TRUE, the string is always wrapped at the specified width. So if you have a word that is larger than the given width, it is broken apart.
* @return string
*/
function wordwrap($str, $width, $break, $cut = false)
{
if (JCOMMENTS_JVERSION == '1.5') {
if (!$cut) {
$regexp = '#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){'.$width.',}\b#U';
} else {
$regexp = '#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){'.$width.'}#';
}

$i = 1;
$j = ceil(JCommentsText::strlen($str) / $width);
$return = '';

while ($i < $j) {
preg_match($regexp, $str, $matches);
$return .= $matches[0] . $break;
$str = JString::substr($str, JCommentsText::strlen($matches[0]));
$i++;
}
return $return . $str;
} else {
return wordwrap($str, $width, $break, $cut);
}
}

/**
* Inserts a separator in a very long continuous sequences of characters
* @static
* @param  $text string The input string.
* @param  $maxLength int The maximum length of sequence.
* @param  $customBreaker string The custom string to be used as breaker.
* @return string Returns the altered string.
*/
function fixLongWords( $text, $maxLength, $customBreaker = '')
{
$maxLength = (int) min(65535, $maxLength);

if ($maxLength > 5) {
ob_start();
if ($customBreaker == '') {
if (!empty($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) {
$breaker = '<span style="margin: 0 -0.65ex 0 -1px;padding:0;"> </span>';
} else {
$breaker = '<span style="font-size:0;padding:0;margin:0;"> </span>';
}
} else {
$breaker = $customBreaker;
}

$plainText = $text;
$plainText = preg_replace('#<br\s?/?>#is'. JCOMMENTS_PCRE_UTF8, '', $plainText);
$plainText = preg_replace('#<img[^\>]+/>#is'. JCOMMENTS_PCRE_UTF8, '', $plainText);
$plainText = preg_replace('#<a.*?>(.*?)</a>#is'. JCOMMENTS_PCRE_UTF8, '', $plainText);
$plainText = preg_replace('#<span class="quote">(.*?)</span>#is', '', $plainText);
$plainText = preg_replace('#<pre.*?>(.*?)</pre>#is'. JCOMMENTS_PCRE_UTF8, '', $plainText);
$plainText = preg_replace('#<blockquote.*?>(.*?)</blockquote>#is'. JCOMMENTS_PCRE_UTF8, '\\1 ', $plainText);
$plainText = preg_replace('#<code.*?>(.*?)</code>#is'. JCOMMENTS_PCRE_UTF8, '', $plainText);
$plainText = preg_replace('#<embed.*?>(.*?)</embed>#is'. JCOMMENTS_PCRE_UTF8, '', $plainText);
$plainText = preg_replace('#<object.*?>(.*?)</object>#is'. JCOMMENTS_PCRE_UTF8, '', $plainText);
$plainText = preg_replace('#(^|\s|\>|\()((http://|https://|news://|ftp://|www.)\w+[^\s\[\]\<\>\"\'\)]+)#i'. JCOMMENTS_PCRE_UTF8, '', $plainText);

$words = explode(' ', $plainText);

foreach($words as $word) {
if (JCommentsText::strlen($word) > $maxLength) {
$text = str_replace($word, JCommentsText::wordwrap($word, $maxLength, $breaker, true), $text);
}
}
ob_end_clean();
}
return $text;
}

« Last Edit: June 11, 2010, 14:02:22 by smart » Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
mark25
Newbie
*

Karma: 0
Offline Offline

Posts: 5


« Reply #4 on: June 02, 2010, 15:01:54 »

Hi,

the bug with the layout-error is now solved. But now there is a another Problem:

The System does not accept "return" button.

If u press "return" command, (which is in html "<br>") the script accepts only "<b"
Consequence: the rest of the text is bold, also in the comments below

Example:

 abgeschossen! r />Merkel damit am Ende

Systemtota lzerlegung geht jetzt sowas von schnell, daß selbst ich das Staunen bekomme!
Logged
smart
Administrator
Hero Member
*****

Karma: 146
Offline Offline

Gender: Male
Posts: 2579



WWW
« Reply #5 on: June 08, 2010, 01:18:11 »

I've updated my previous post and make fix more correct.
Logged

If you use JComments, please post a rating and a review at the Joomla! Extensions Directory
Pages: [1]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    Bug-reports    Topic: serious Layout Bug
 
Jump to: