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

Link tag with invalid content (resulting on 404) must result in error? #157

Open
reinaldocoelho opened this issue Jul 18, 2018 · 2 comments

Comments

@reinaldocoelho
Copy link
Contributor

reinaldocoelho commented Jul 18, 2018

I need to process some HTML files out of my control, and sometimes I found itens like that <link href='/test/mycss.css'> but without origin or base tag to find the origin of request.

How is the right way to ignore this and process the other content of my HTML?
And can we have an config to ignore 404 and remove this content on validate?

I try to create my own base URI to ignore all content but when I set the baseUri on PreMailer this removes the url getting only the base and give the same error.

Follow the simple test:

[TestMethod]
public void ContainsLinkCssElement_NotCssFile()
{
            Uri fullUrl = new Uri("http://localhost");
            string input = @"<html>
	<head>
	<style type='text/css'>p { margin: 0; }</style>
	</head>
	<body>
		<div style='font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000'>
			<div><link rel=""stylesheet"" href=""/myfolder/css/myown.css?v=120410005131"">Test Message</div>
		</div>
	</body>
</html>";
			PreMailer sut = new PreMailer(input, fullUrl);
			sut.MoveCssInline();
}

Follow the proposal who solve my issue (is valid?):

		[TestMethod]
		public void ContainsLinkCssElement_NotCssFile()
		{
            Uri fullUrl = new Uri("http://localhost/mybaseuri/resultalwaysok");
            string input = @"<html>
	<head>
	<style type='text/css'>p { margin: 0; }</style>
	</head>
	<body>
		<div style='font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000'>
			<div><link rel=""stylesheet"" href=""/myfolder/css/myown.css?v=120410005131"">Test Message</div>
		</div>
	</body>
</html>";
			PreMailer sut = new PreMailer(input, fullUrl);
			sut.MoveCssInline();
		}

Thanks.

@robhoward
Copy link
Contributor

I just ran into the same issue. One of my customers tried to request an invalid font (https://fonts.googleapis.com/css?family=Segoe) which returns a 400 error and throws an unhandled WebException.

I'm going to submit a pr that handles webexceptions in LinkTagCssSource and adds to the InlineResult.Warnings collection:

"PreMailer.Net is unable to fetch the requested URL: https://fonts.googleapis.com/css?family=Segoe"

@ErlendSB
Copy link

In case this was missed: #350 (comment)
It seems like this functionality is not yet added.

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

No branches or pull requests

3 participants