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

"Safe Mode" for template parsing? #1102

Open
justingit opened this issue Jun 28, 2022 · 1 comment
Open

"Safe Mode" for template parsing? #1102

justingit opened this issue Jun 28, 2022 · 1 comment

Comments

@justingit
Copy link
Owner

Templates - like email messages with embedded tags, that also have errors in those tags cause chaos when you try to send them out as a mailing list message. A problem happens, but it's sometimes hard to know exactly where the error is.

Perhaps what we need is a safe mode for parsing templates, where the code that could fail is wrapped up in an eval(). This isn't done now for performance reasons, but maybe it makes sense in a safe mode to wrap it in an eval to get the line where the error in the template tag is found.

Oftentimes, the email message also has its data on all one line, so we should try to break that up for debugging purposes,

Simplified code:


		
		    ${$args->{-data}} =~ s/\>/>\n/gi;
		
		try { 
		    
		    $template = HTML::Template::MyExpr->new(
	    		%Global_Template_Options, 
	    		scalarref => $args->{-data},
	    		filter    => $filters, 
    		);
		} catch { 
		    croak $_ . ' => raw template: ' . ${$args->{-data}};
		};

At the very least, that would help us see what template/message is causing the issue and give us a clue as to where.

@justingit
Copy link
Owner Author

This wasn't implemented; opening back up!

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

No branches or pull requests

1 participant