From ccd7dc40c8af1a3aad22f32b0c6cf45a80b2c477 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Sat, 16 Jul 2016 13:13:39 +0300 Subject: [PATCH 1/4] Add test for CSS URL re-writing of network-path references Catches bug found in meteor/meteor#7416 caused by regression in 1b34866de2dd8415bfa2ddbda1d8fcba00e33499 --- packages/minifier-css/urlrewriting-tests.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/minifier-css/urlrewriting-tests.js b/packages/minifier-css/urlrewriting-tests.js index 804e81786e..8626267909 100644 --- a/packages/minifier-css/urlrewriting-tests.js +++ b/packages/minifier-css/urlrewriting-tests.js @@ -78,6 +78,7 @@ Tinytest.add("minifier-css - url rewriting with media queries (ast rule recursio t("'/image.png'", "'image.png'", 'single quoted url'); t('"./../image.png"', '"packages/image.png"', 'quoted parent directory'); t('http://i.imgur.com/fBcdJIh.gif', 'http://i.imgur.com/fBcdJIh.gif', 'complete URL'); + t('//i.imgur.com/fBcdJIh.gif', '//i.imgur.com/fBcdJIh.gif', 'network-path reference'); t('"http://i.imgur.com/fBcdJIh.gif"', '"http://i.imgur.com/fBcdJIh.gif"', 'complete quoted URL'); t('data:image/png;base64,iVBORw0K=', 'data:image/png;base64,iVBORw0K=', 'data URI'); t('http://', 'http://', 'malformed URL'); @@ -90,6 +91,7 @@ Tinytest.add("minifier-css - url rewriting with media queries (ast rule recursio t('"/image.png"', '"image.png"', 'double quoted url'); t("'/image.png'", "'image.png'", 'single quoted url'); t('http://i.imgur.com/fBcdJIh.gif', 'http://i.imgur.com/fBcdJIh.gif', 'complete URL'); + t('//i.imgur.com/fBcdJIh.gif', '//i.imgur.com/fBcdJIh.gif', 'network-path reference'); t('"http://i.imgur.com/fBcdJIh.gif"', '"http://i.imgur.com/fBcdJIh.gif"', 'complete quoted URL'); t('data:image/png;base64,iVBORw0K=', 'data:image/png;base64,iVBORw0K=', 'data URI'); t('http://', 'http://', 'malformed URL'); From fddaedeb083afe528cde91798960d8e2d4cfdc5e Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Sat, 16 Jul 2016 13:46:29 +0300 Subject: [PATCH 2/4] Don't rewrite network path references in CSS URLs. Fixes regression caused in 1.3.4.1 which caused network path reference URLs (i.e. //img.domain.com/path/font.eot) used in CSS `url()`'s' to be stripped of their leading slashes causing them to become relative URL paths. Closes meteor/meteor#7416 --- packages/minifier-css/minifier.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/minifier-css/minifier.js b/packages/minifier-css/minifier.js index bd88ede21d..0994ee6fc8 100644 --- a/packages/minifier-css/minifier.js +++ b/packages/minifier-css/minifier.js @@ -136,8 +136,9 @@ var rewriteRules = function (rules, mergedCssPath) { // We don't rewrite URLs starting with a protocol definition such as - // http, https, or data. - if (resource.protocol !== null) { + // http, https, or data, or those with network-path references + // i.e. //img.domain.com/cat.gif + if (resource.protocol !== null || resource.href.startsWith('//')) { continue; } From e02893fa43018f8a01403ef3d87fb60b6d5472a2 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Sat, 16 Jul 2016 16:54:48 +0300 Subject: [PATCH 3/4] Add missing History entry for 1.3.4.2 release regarding #5837 This change should be mentioned as it those who were manually prefixing their relative CSS paths with the same path as their ROOT_URL will need to remove the path. Relates to meteor/meteor#7416 --- History.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/History.md b/History.md index cb34f72080..b074169bee 100644 --- a/History.md +++ b/History.md @@ -53,6 +53,9 @@ * `App.appendToConfig` allows adding custom tags to config.xml. [#7307](https://github.com/meteor/meteor/pull/7307) +* When using `ROOT_URL` with a path, relative CSS URLs are rewriten + accordingly. [#5837](https://github.com/meteor/meteor/issues/5837) + * Fixed bugs: [#7149](https://github.com/meteor/meteor/issues/7149) [#7296](https://github.com/meteor/meteor/issues/7296) From 34969a1eb774a1806454cc47131fa545c358f757 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Sat, 16 Jul 2016 16:57:48 +0300 Subject: [PATCH 4/4] History entry for #7416 --- History.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/History.md b/History.md index b074169bee..1056f21d3a 100644 --- a/History.md +++ b/History.md @@ -1,5 +1,9 @@ ## v.NEXT +* Fix for regression caused by #5837 which incorrectly rewrote + network-path references (i.e. //domain.com/image.gif) in CSS URLs + [#7416](https://github.com/meteor/meteor/issues/7416) + ## v1.3.4.4 * Fixed [#7374](https://github.com/meteor/meteor/issues/7374).