LeaVerou/rgba.php

new colour syntax not working

Opened this issue · 14 comments

The older ways of specifying colours work for me but the new way does not.

Eg.
background: url('rgba.php/rgba(0,0,0,0.6)');

returns:
Color name /rgba(0 unknown.

Same here.
PHP Version: 5.3.1

Thanks for reporting this bug.
Is it present in older versions too?

I can't figure out how to check if it is present in older versions (Git n00b here). If I could find a link to an older version I'd be happy to test it. Thanks.

kbjr commented

i believe i know the cause of this. different systems handle PATH_INFO differently, and i think that is what you are seeing. PHP isnt seeing "rgba" (its seeing the "/" instead) so it tries to parse it as a color name. seeing as i wrote the code causing the problem, i will write a fix.

Actually, what I did before (that wasn't working) was copy the source code directly from the github page. Downloading the .zip package and using the source code in there solves the issue, seeing as they are both coded differently.

kbjr commented

oh, nevermind then. i guess i didn't break it :D

I too downloaded the zip package, with which the error did occur. I was running a version of MAMP which included PHP 5.2.11. I just upgraded to the latest version of MAMP which includes PHP 5.3.5 and I still get the same error.

Sorry for closing and reopening. Like I said: n00b.

kbjr commented

alright, so there should be a section of the code around line 85 that looks like this:

else {
    $color_array = explode(',', $_SERVER['PATH_INFO']);
    if (count($color_array == 2)) {

drop in there a

var_dump($color_array);
die();

before the if and tell me what you get.

Thanks kbjr. This is what I got back:
array(4) { [0]=> string(7) "/rgba(0" [1]=> string(1) "0" [2]=> string(1) "0" [3]=> string(4) "0.6)" }

kbjr commented

weird... add before the die() a couple more lines:

$a = count($color_array);
var_dump($a);
var_dump(($a == 2));
kbjr commented

nevermind, i found the bug myself. i'll fix it and send lea a pull request.

That returned:
int(4) bool(false)

Legend!