Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ED2K links with accented characters fail to be added via web interface #394

Open
elbowz opened this issue Jan 22, 2025 · 0 comments
Open

Comments

@elbowz
Copy link

elbowz commented Jan 22, 2025

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:

  1. Add the following ED2K links via the web interface:
ed2k://|file|a|3699376|5560EEEDF50398B9628FD0DD402C86E7|/
ed2k://|file|ò|3895300|E233C05B84990904A82224784DDE87A5|/
ed2k://|file|b|3721844|5CEB1B9A4603CEE8FF4D7A0FE4DA2AEE|/
  1. 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:

  1. "|file|a|3699376|5560EEEDF50398B9628FD0DD402C86E7|/"
  2. "|file|ò|3895300|E233C05B84990904A82224784DDE87A5|/"
  3. "/|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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant