Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

font-url fails with URLs that contain ? or # in production #3045

Closed
shaicoleman opened this Issue · 9 comments

8 participants

@shaicoleman

The font-url method doesn't properly handle URLs that use the FontSpring syntax, e.g. the ones produced from FontSquirrel.
e.g.
src: font-url('aller_rg-webfont.eot?#iefix') format('embedded-opentype'),

The following URLs aren't parsed correctly as they have ? or # afterwards. This is needed to work around handle IE7/8 issues and for older iOS browsers.

sass-rails delegates url generation to rails, so this is not an issue with sass-rails.
See rails/sass-rails#49

@spastorino
Owner

@jj05 can you confirm if this is working in Rails 3.2 using 3-2-stable branch + sass-rails 3-2-stable branch?.
The issue was closed in sass-rails

@spastorino
Owner

I've pushed rails/sass-rails@68536e3 and 439d340 too. Please comment again on the ticket if you still has issues

@spastorino spastorino closed this
@franzk

I tested this with a fresh minimal rails app (ruby 1.9.3p194, rails 3.2.9, sass-rails 3.2.5) and I can confirm that it's still not working.

The following scss

.test1a {
  content: image-url("testimage.png");
}

.test1b {
  content: image-url("testimage.png#iefix");
}

.test2a {
  content: font-url("testfont.eot");
}

.test2b {
  content: font-url("testfont.eot#foo");
}

produces

.test1a{content:url(/assets/testimage-e19cc14e7b458337c25b4a0b230d6cac.png)}
.test1b{content:url(/assets/testimage.png#iefix)}
.test2a{content:url(/assets/testfont-5f9bf001d945baa3287193f70ac71c68.eot)}
.test2b{content:url(/assets/testfont.eot#foo)}

I committed a fix for this (franzk/rails@bd279d9) - but it will break things for assets that truly contain # or ? in their paths. Another option is the following workaround which clearly defines what is path and what is appendix:

...
.test2b {
  content: url(unquote("#{font-path('testfont.eot')}#foo"));
}
@steveklabnik
Collaborator

Can you push the test app to github please?

@steveklabnik steveklabnik reopened this
@franzk franzk referenced this issue from a commit in franzk/rails
franzk Minimal changes to reproduce rails/rails#3045 543a075
@franzk

I have pushed a branch test-app-for-fix-asset-path-appendix to my rails fork.

https://github.com/franzk/rails/commits/test-app-for-fix-asset-path-appendix

@senny
Owner

Is this still an with Rails 4.0.0.beta1?

@stouset

@franzk From the output you pasted, assets that truly contain a ? or # in them are already broken (in that stamping isn't applied to them).

I think the odds that anyone is doing this in practice is effectively zero.

@leafac leafac referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@leafac

I updated the test Rails app to reproduce this issue against the current master and it works.

The app.

The Sass.

The compiled CSS.

I think this issue can be closed now.

@guilleiguaran

@leafac thank you for test this!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.