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

lemmax - March 1, 2009 - 12:36

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

pauline_perren - March 2, 2009 - 23:39

I'm having this issue too.
Apparently Explorer won't accept URLs longer than 2048 so maybe that could be the cut-off ...

#3

marcp - March 10, 2009 - 03:36

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

pauline_perren - March 17, 2009 - 02:36

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.

AttachmentSize
link_URL_length_fix.patch 1.68 KB

#5

jeffschuler - March 17, 2009 - 04:31
Status:active» needs review

#6

marcp - March 17, 2009 - 14:12
Status:needs review» needs work

I suspect this patch won't get accepted without a corresponding hook_update_N() in the .install file.

#7

pauline_perren - March 18, 2009 - 02:12

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

vgarvardt - May 29, 2009 - 11:48

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

jeffschuler - June 14, 2009 - 19:36
Status:needs work» needs review

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!

AttachmentSize
376818_wInst.patch 2.97 KB

#10

vgarvardt - July 3, 2009 - 18:59

Yes, this patch works fine.
It would be great if this patch will be applied in the next release.
Thanks.

#11

dropcube - September 13, 2009 - 16:48
Version:6.x-2.5» 6.x-2.6

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.

AttachmentSize
longer-urls-376818.patch 3.63 KB

#12

andrewlevine - September 25, 2009 - 17:14

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

andrewlevine - October 9, 2009 - 21:08
Status:needs review» reviewed & tested by the community

setting as RTBC. let me know if you need anything else to commit this.

#14

dropcube - November 5, 2009 - 05:00
Version:6.x-2.6» 6.x-2.x-dev
Component:User interface» Code
Assigned to:Anonymous» dropcube
Status:reviewed & tested by the community» needs review

Updated patch against the 6.x-2.x branch.

AttachmentSize
longer-urls-376818-14.patch 3.67 KB
 
 

Drupal is a registered trademark of Dries Buytaert.