Administrator
- Join Date:
- Sep 2009
- Location:
- Stuart, FL
- Posts:
- 14,119
- Plugin Contributions:
- 56
Multi-line TEXT attribute size is not checked
If a TEXT attribute is defined as multi-line, e.g. Rows: 10, Display Size: 40, Maximum length = 400, the character-checking javascript will limit the number of characters input to the maximum length if javascript is enabled (duh) and the customer has keyed-in the characters.
I've seen at least one site where some kiddies are ***pasting ***over-sized contents (like 8MB of gibberish) into the TEXT attribute. This yields an error from the javascript, but the text-size is not reduced ... leading to false out-of-memory logs being issued within the shopping cart page.
As a pro-active measure, I created an extra_cart_action script containing:
<?php
// -----
// Extra-cart-action to detect (and remove) any TEXT attributes that are longer than the allowable value. This is usually
// caused by script-kiddies pasting large amounts of data into a TEXT-attribute's textarea box.
//
if (isset ($_GET['action']) && $_GET['action'] == 'add_product' && isset ($_POST['id']) && is_array ($_POST['id'])) {
foreach ($_POST['id'] as $key => $value) {
$debug = '';
if (strpos ($key, TEXT_PREFIX) === 0) {
$check = $db->Execute ("SELECT products_options_length FROM " . TABLE_PRODUCTS_OPTIONS . " WHERE products_options_id = " . (int)str_replace (TEXT_PREFIX, '', $key) . " LIMIT 1");
if ($check->EOF || strlen ($value) > $check->fields['products_options_length']) {
unset ($_POST['id'][$key]);
}
}
}
reset ($_POST['id']);
}
Note that I "killed" the attribute value rather than truncating it to the proper length because my feeling is/was that the only reason that this overage should occur is when the form's being fussed with.