Multiple URLs in one line not handled by CSSHandler

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
12/8/2014 2:00:18 PM
Gravatar
Total Posts 5

Multiple URLs in one line not handled by CSSHandler

When multiple URLs appear in a single line in your CSS, the CSSHandler does not properly handle the path replacement. For example, if you have the line:

src: url('fonts/Franklin-Gothic-Book/15BF9F_1.eot?#iefix') format('embedded-opentype'), url('fonts/Franklin-Gothic-Book/15BF9F_1.woff') format('woff'), ....

the CSSHandler will only replace the path in the first URL  it comes to, instead of replacing all the paths. The result in this case is that the fonts are not downloaded in any browser except IE (because the one that IE uses was listed first). The workaround to this issue is to always make sure that you break up your URLs to be on multiple lines, but this is inconvenient because whenever you do a format of your CSS (Ctrl-k, Ctrl-d), Visual Studio moves them to a single line as above.

It appears that this is a known issue, because there is some commented out code in CSSHandler.cs that apparently was put in to handle this but then commented out (lines 440-466). One of the comments in this section says "this is kind of hacky, would be better if we could solve it by better regex."

I believe that this can be fixed by simply add a ? after the "<path>(.*" in the regex, like so:

Instead of: @"url\((\""|\')?(?<path>(.*))?(\""|\')?\)"

Should be: @"url\((\""|\')?(?<path>(.*?))?(\""|\')?\)"

This will force it to find each match on the line, instead of treating it as one match for the whole line. I tested this change and it seemed to work, although I must admit that I don't know with absolute certainty that this wouldn't have some other unforeseen consequences.

12/9/2014 9:43:45 AM
Gravatar
Total Posts 18444

Re: Multiple URLs in one line not handled by CSSHandler

Hi Todd,

I've committed your change to our source code repository and kept the old regex expression in comments in case any side effects are found later, but your fix seems ok so far. Since we just made a release it will be a while before the next one and that should provide plenty of time to discover any unexpected side effects if there are any.

Thanks,

Joe

You must sign in to post in the forums. This thread is closed to new posts.