You are viewing limited content. For full access, please sign in.

Question

Question

Submitted form takes over 120 seconds to display

asked on April 26, 2015 Show version history

I have a very simple form that I'm displaying to the user after submission, but it takes forever to appear. I ran a JavaScript CPU profile and found out that there's a "GenerateLink" function in the LF.utils namespace that's running some crazy regular expressions. Below is a screenshot:

The form itself is pretty simple. The only thing unusual about it is that it has a hidden multiline field that has several hundred thousand characters (it's basically base64 image data). I'm 99% certain that the GenerateLink function tries to parse this text, because larger images result in longer base64 data, which in turn causes the function to take longer.

Is there a way around this? What does GenerateLink do? I'd appreciate some input from the forms team.

The purpose of having the base64 data in that field is to display uploaded images to the user.

0 0

Replies

replied on April 26, 2015 Show version history

Hi Ege,

LF.utils.GenerateLink is used to find possible web url and email address, and then make it a link to show on the submitted form.

I tried a hidden multiline field with base64 image data as default value, but it took less than 1 second for the LF.utils.GenerateLink to finish.

The issue may be related with your field value. Can you try whether this issue exists on only one kind of field value or any value? Can you share us your field value?

Besides, did you set custom JavaScript on this form?

0 0
replied on April 27, 2015

Hi Rui,

Shorter base64 values seem to work fine, but longer ones cause it to take a long time. The one I was working with last night had about 200,000 characters in it because the encoded images were large (not in size, but in pixels, e.g. 1600x1200).

I'm attaching a text file with an example value. You'll note that it's almost 150KB of text, so naturally any complex regex will take a long time to process it. The format is JSON and the value is base64. You can reproduce the issue easily by creating a simple form with a multiline field, pasting the value into it and submitting it.

As a side note, if the GenerateLink function searches for possible URLs and email addresses to display them as links (blue, underlined) on the submitted form, it seems to me that it shouldn't run on hidden fields. Would you not agree?

Does GenerateLink run on the entire HTML, or only field values? I'm thinking maybe I can place the base64 values into a hidden dropdown field instead, or something, to get around it.

exampleBase64.txt (146.36 KB)
0 0
replied on April 27, 2015 Show version history

Hi Ege,

GenerateLink runs on field values. The kinds of fields that WILL be affected with GenerateLink are: single line, multi-line, number and email.

So you can choose one that is not among the above.

I would suggest using signature field. It's not easy to modify dropdown field value.

And I agree that GenerateLink should not affect hidden fields. I'll send this to developers and see what they will say.

1 0
replied on May 12, 2015

Signature fields do not seem to pass on the values that are manually entered into the value attribute of the field.

0 0
replied on May 12, 2015 Show version history

Okay, I was able to use an address field. Interestingly enough, address fields don't play well with double quotes: any double quote entered and everything after it gets stripped out when the form is submitted. To get around it, I convert double quotes to single quote first, and then back to double quote to be able to parse the JSON during viewing.

EDIT: Never mind, address fields also get subject to the GenerateLink function. :(

0 0
replied on August 21, 2015

I'd like to bump this. It's causing major headaches for all of our Forms customers, because they use similar functionality with regards to embedding photos into the stored version of the forms.

Can Laserfiche verify that this is going to be fixed in version 10?

If not, is it safe to remove the GenerateLink function from the javascript that comes from the server (utils.js)?

0 0
replied on January 12, 2017

This issue has been fixed in Forms 10.2.

0 1
replied on January 20, 2017 Show version history

I don't believe so. I just tested the originally mentioned process with 10.2 and the same thing happens. Because you guys are still using insanely inefficient regular expressions inside utils.js to detect if a given piece of text is a URL or an email address. Here, I'll even include the offending function in question:

LF.utils.GenerateLink=function(text,newWindow){
	var weburl=new RegExp("^"+"(?:(?:https?|ftp)://)"+"(?:\\S+(?::\\S*)?@)?"+"(?:"+"(?!10(?:\\.\\d{1,3}){3})"+"(?!127(?:\\.\\d{1,3}){3})"+"(?!169\\.254(?:\\.\\d{1,3}){2})"+"(?!192\\.168(?:\\.\\d{1,3}){2})"+"(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})"+"(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])"+"(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}"+"(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))"+"|"+"(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)"+"(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*"+"(?:\\.(?:[a-z\\u00a1-\\uffff]{2,}))"+")"+"(?::\\d{2,5})?"+"(?:/[^\\s]*)?"+"$","i");
	var email=/(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])/gi;
	return text.replace(weburl,function(link){
		if(newWindow){
			return'<a href="'+link+'" target="_blank">'+link+'</a>';
		}
		return'<a href="'+link+'">'+link+'</a>';
	}).replace(email,function(link){
		return'<a href="mailto:'+link+'">'+link+'</a>';
	})
;}

All those crazy regexes... just to you can detect a URL or email address on the form so that you can highlight it as a link on the generated form image? Seems like total overkill.

The GenerateLink() function in 9.2 tried to detect just email addresses. This function also tries to detect URLs. So the situation is twice as bad now.

0 0
replied on February 6, 2017

Can you open an support cases with the exported process so that we can fix the exact issue. What we've fixed in 10.2 is to let GenerateLink not affect hidden fields, so maybe your fields actually are not hidden?

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.