Really long URL gets cut off
mark_anthony - February 19, 2009 - 13:15
| Project: | Link |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | dropcube |
| Status: | needs review |
Description
I have a really long URL, 294 characters; even longer when I convert symbols into URL safe characters. It gets truncated to 255 characters.

#1
Same problem here. For example,
http://th.wikipedia.org/wiki/%E0%B9%82%E0%B8%A3%E0%B8%87%E0%B9%80%E0%B8%...
is truncated and thus made useless. It should link to a website with a url in Thai language, and in Thai it's not really that long a URL. The limit should be set to at least 512 characters or preferably more.
#2
I'm having this issue too.
Apparently Explorer won't accept URLs longer than 2048 so maybe that could be the cut-off ...
#3
The 'database columns' case in
link_field_settings()tells CCK how big to make the url field -- it's set to 255.I only found this issue because folks are asking for longer urls in the userlink queue, and I was checking here to see what link does since it should be the de-facto standard (and since userlink should be built on top of CCK/Link).
Is 255 really big enough?
#4
Here is a patch to update the URL length to 2048. You will have to manually update any existing database columns from 255 to 2048 but this patch will cause any new fields created to be the new length. It also allows the longer URLs to be entered via the form when creating new content.
#5
#6
I suspect this patch won't get accepted without a corresponding hook_update_N() in the .install file.
#7
Unfortunately I can't see how to tell which database columns have been generated by this module and need to be automatically updated. Presumably someone who knows the module better would know. Can anyone help with this?
#8
I'm having the same problem.
So, What about accepting this patch?
New update link_update_6001 introduced in 6.x-2.6-beta1 updates all link fields with new length.
#9
vgarvardt, I'm confused about how
link_update_6001()updates link fields with new length. Sorry if I'm missing something.I've re-rolled the patch in #4 against 6.x-2.6-beta1, and included a new link.install function:
link_update_6200()to update the url column lengths to 2048.I used
link_update_6001()as a model for doing so. Not sure if there's a simpler way to choose the url column... I'm grateful for corrections!#10
Yes, this patch works fine.
It would be great if this patch will be applied in the next release.
Thanks.
#11
The patch looks good, an it works. Also tested the upgrade function, and all links fields are converted correctly to the new database type. Some minor comments about the patch:
+++ link.install 14 Jun 2009 18:07:05 -0000@@ -86,3 +86,32 @@
+function link_update_6200() {
Would be good to add some PHPdocs to the function, to indicate the changes being done.
+++ link.module 14 Jun 2009 18:07:06 -0000@@ -461,11 +466,12 @@
+ $url_max_length = sprintf('%d', URL_MAX_LENGTH);
$field = $form['#field_info'][$element['#field_name']];
Not required to explicitly typecast this.
+++ link.module 14 Jun 2009 18:07:06 -0000@@ -461,11 +466,12 @@
- '#maxlength' => '255',
+ '#maxlength' => $url_max_length,
Constant should be used directly.
The attached patch fixed the above.
Also, it renames the constant URL_MAX_LENGTH to LINK_URL_MAX_LENGTH, which is in the module namespace, like the other constants the module defines.
#12
tested this patch on two of our websites that were affected by the bug -- worked fine. Patch looks good to me too. Hoping this gets into 6.x-2.7 -- let me know if there's anything else I can do
#13
setting as RTBC. let me know if you need anything else to commit this.
#14
Updated patch against the 6.x-2.x branch.