Skip to content

[TASK] Add more tests for parsing of invalid colors #359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2024

Conversation

mathroc
Copy link
Contributor

@mathroc mathroc commented Mar 22, 2022

We are getting warnings with some CSS code even on lenient mode on php 8.1 (but the same also happens on php 8.0)

Warning: Uninitialized string offset 5 in /app/src/Value/Color.php on line 56

@mathroc
Copy link
Contributor Author

mathroc commented Mar 22, 2022

Hi! I wanted to showcase an issue but the tests aren't running automatically here. Does someone need to start them manually?

if you want to reproduce locally, this script causes the warning on php 8+:

<?php

use Sabberworm\CSS\Parser;

include 'vendor/autoload.php';

$oParser = new Parser("a { color: #fffff;}", Settings::create());
$oParser->parse();

@oliverklee oliverklee deleted the branch MyIntervals:main February 7, 2024 11:36
@oliverklee oliverklee closed this Feb 7, 2024
@oliverklee oliverklee reopened this Feb 7, 2024
@oliverklee oliverklee changed the base branch from master to main February 7, 2024 22:34
@JakeQZ
Copy link
Collaborator

JakeQZ commented Feb 26, 2024

This should be fixed by #485, though I'd like to include your additional tests...

@JakeQZ JakeQZ added bug cleanup testing PRs/issues adding additional tests only, or primarily testing-focused rebase needed labels Feb 26, 2024
@JakeQZ
Copy link
Collaborator

JakeQZ commented Feb 26, 2024

@oliverklee or @mathroc, can you rebase this please.

I am just getting errors from git (perhaps due to the name change from master to main), which I cannot resolve:

d:\git_files\contribs\PHP-CSS-Parser>git rebase master
Current branch master is up to date.

d:\git_files\contribs\PHP-CSS-Parser>git checkout main
error: pathspec 'main' did not match any file(s) known to git

d:\git_files\contribs\PHP-CSS-Parser>git rebase origin/main
fatal: invalid upstream 'origin/main'

d:\git_files\contribs\PHP-CSS-Parser>git rebase main
fatal: invalid upstream 'main'

@JakeQZ
Copy link
Collaborator

JakeQZ commented Feb 26, 2024

the tests aren't running automatically here. Does someone need to start them manually?

GitHub doesn't allow them for first-time contributors until manually approved, as they have reportedly been used as a crypto-mining vector. I have a Hotmail account for which most genuine email is dunked in the 'Spam' folder, whereas actual spam is not. Draw your own conclusions. (Note that GitHub is owned by Microsoft, and as such, is not an open-source platform - it is merely a platform hosting open-souce software.)

@mathroc
Copy link
Contributor Author

mathroc commented Feb 26, 2024

Hi! I'm not on my laptop so I sync'ed the branch with the GitHub UI (hence the merge commit) I can rebase it properly later if needed.

still need a maintainer to approve running the unit tests

@JakeQZ JakeQZ changed the title Trying to reproduce a bug on php 8+ related to lenient parsing of invalid colors (at least) [TASK] Add more tests for parsing of invalid colors Feb 26, 2024
Copy link
Collaborator

@JakeQZ JakeQZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sync'ed the branch with the GitHub UI (hence the merge commit) I can rebase it properly later if needed.

Thanks. The GitHub UI sync seems to have been sufficient. (I still don't know why I couldn't get the fork to rebase.)

I've now been able to confirm that these new tests would fail without the fix in #485, and pass with the fix in place.

I like the completeness of the test file, containing invalid color values with 1, 2, 4 and 5 characters.

Could you rename the test methods (to avoid the second one simply having the number 2 appeneded to the name)? And resolve the PHP-CS-Fixer error?

Thanks again.

Copy link
Collaborator

@JakeQZ JakeQZ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good now. Thanks for contributing <3

@JakeQZ JakeQZ merged commit 4108ca8 into MyIntervals:main Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cleanup testing PRs/issues adding additional tests only, or primarily testing-focused
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants