[SNIPPET] Non english characters in links

Modifications for phpBB3.
Try the Mods here and share Your own Mods
Forum rules
You dont have to use ModX or make your mod AutoMod compatible. A simple textfile is fine
But if you post Mods here You also have to give support

[SNIPPET] Non english characters in links

Post by Stoker »

To make phpBB support non english characters.
Original Source: http://area51.phpbb.com/phpBB/viewtopic ... 42#p203967
Code corrected by Leinad4Mind

open includes/functions.php
Find:

Code: Select all

return "[a-z]$scheme*:/{2}(?:(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})+|[0-9.]+|\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\])(?::\d*)?(?:/(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?";
Replace with:

Code: Select all

return "[a-z]$scheme*:/{2}(?:(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})+|[0-9.]+|\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\])(?::\d*)?(?:/(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?";

Find:

Code: Select all

return "www\.(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})+(?::\d*)?(?:/(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?";
Replace with:

Code: Select all

return "www\.(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})+(?::\d*)?(?:/(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?";

Find:

Code: Select all

return "www\.(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})+(?::\d*)?(?:/(?:[a-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[a-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?";
Replace with:

Code: Select all

return "(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*(?:/(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?";

[SNIPPET] Non english characters in links

Post by Leinad4Mind »

Thanks, it work perfectly! I was really needing this :) And I was kinda lazy to write those regular expressions :D

EDIT:

After some intense teste. And as I have other mods as: "Forum Link to Topic Title" and "Prime_Links" and ABBC3_BBCode...

I've some problems with those lines ^^'. And your last modification are not correct. AFAIK...

I've needed to put a new ones:

Code: Select all

return "[a-z]$scheme*:/{2}(?:(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})+|[0-9.]+|\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\])(?::\d*)?(?:/(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?";

Code: Select all

return "www\.(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})+(?::\d*)?(?:/(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?";

Code: Select all

return "(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*(?:/(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[\x80-\xFFa-z0-9\-._~!$&'($inline*+,;=:@/?|]+|%[\dA-F]{2})*)?";
And now it works 100% for me 8-)

:ugeek:

[SNIPPET] Non english characters in links

Post by Stoker »

I can confirm that your code is working :thumb:
First post updated.

[SNIPPET] Non english characters in links

Post by Leinad4Mind »

Hi there Stoker. My code is not working at full x'D.

Example:

I was on ACP, Editing a BBCODE...

And after editing when I click on Sending, it appears the following error:
SQL ERROR [ mysqli ]

Incorrect string value: '\x80-\xFFa-z...' for column 'first_pass_match' at row 1 [1366]

SQL



BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/includes/db/dbal.php
LINE: 757
CALL: trigger_error()

FILE: [ROOT]/includes/db/mysqli.php
LINE: 182
CALL: dbal->sql_error()

FILE: [ROOT]/includes/acp/acp_bbcodes.php
LINE: 243
CALL: dbal_mysqli->sql_query()

FILE: [ROOT]/includes/functions_module.php
LINE: 509
CALL: acp_bbcodes->main()

FILE: [ROOT]/adm/index.php
LINE: 78
CALL: p_master->load_active()
If you could help, on this...

(I've already replace to the old code that was commented, and I've edit my bbcode. But it would be nice to fix this. And this is anything to do with my bbcode example, is just the way the error appear to me, neither it depends the type of edit. It's just the reg. expr. that have some problem...)

Cheers! :thumb:

EDIT: If anyone could take a look on this, would be great. Cheers