nzakas / cssembed

A tool for embedding data URIs in CSS files.
http://www.nczonline.net/
389 stars 30 forks source link

url parameter parsing #37

Closed Dither closed 12 years ago

Dither commented 12 years ago

Isn't checking for ', " and optionally for \ more consistent this way:

                while (pos > -1){
                    pos += 4;
                    builder.append(line.substring(start, pos));
                    npos = line.indexOf(")", pos);
                    //eliminate all quotes and backslashes in url (there shouldn't be any)
                    String url = line.substring(pos, npos).trim().replaceAll("[\'\"\\\\]", "");

                    //check for duplicates
                    if (foundMedia.containsKey(url)){
                        if (verbose){
                            System.err.println("[WARNING] Duplicate URL '" + url + "' found at line " + lineNum + ", previously declared at line " + foundMedia.get(url) + ".");
                        }                        
                    }

Also there is v2.3.7 of Base64 library already.

nzakas commented 12 years ago

I'm sorry, I'm not sure what you're trying to say. Can you try explaining a bit more?

Dither commented 12 years ago

I mean that those characters in the regexp shouldn't be in url() at all so why to check for a strict fromat. This is just a one small expression instead of several huge if/else blocks and it can probably parse some misformatted strings like url(\"aaaa"), url('aaa'') etc.