-
Notifications
You must be signed in to change notification settings - Fork 241
Description
Description:
When attempting to add ED2K links through the web interface, links containing special characters (e.g., accented characters in UTF-8 encoding) are not consistently added to aMule.
Steps to Reproduce:
- Add the following ED2K links via the web interface:
ed2k://|file|a|3699376|5560EEEDF50398B9628FD0DD402C86E7|/
ed2k://|file|ò|3895300|E233C05B84990904A82224784DDE87A5|/
ed2k://|file|b|3721844|5CEB1B9A4603CEE8FF4D7A0FE4DA2AEE|/
- Observe that the file "b" is not added to the download list.
Expected Behavior:
All three links should be added to the download list, regardless of special characters.
Actual Behavior:
The link containing the special character "ò" causes the subsequent link (file "b") to fail to be added.
Debugging Information:
Upon inspecting the footer.php file, the issue appears to be in the following code snippet:
if (strlen($link) > 0) {
$links = split("ed2k://", $link);
foreach ($links as $linkn) {
amule_do_ed2k_download_cmd("ed2k://" . $linkn, $target_cat_idx);
}
}The split() function is causing the problem. When processing the links, it returns the following strings:
"|file|a|3699376|5560EEEDF50398B9628FD0DD402C86E7|/""|file|ò|3895300|E233C05B84990904A82224784DDE87A5|/""/|file|b|3721844|5CEB1B9A4603CEE8FF4D7A0FE4DA2AEE|/"<--- Issue here
The third string incorrectly includes a leading /, which causes the link to fail.
Root Cause:
The split() function does not handle special characters (e.g., accented characters) correctly, leading to malformed strings when splitting the input.
Proposed Solution:
Replace the deprecated split() function with explode(), which is more reliable and handles UTF-8 characters properly. For example:
if (strlen($link) > 0) {
$links = explode("ed2k://", $link);
foreach ($links as $linkn) {
if (!empty($linkn)) {
amule_do_ed2k_download_cmd("ed2k://" . $linkn, $target_cat_idx);
}
}
}This should resolve the issue with special characters and ensure all links are added correctly.
note: the problem was reported on elbowz/mobileMule#14