Skip to content

Add test for iconv_mime_encode() for preference input-charset and output-charset #8766

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

Closed
wants to merge 6 commits into from
Closed

Conversation

juan-morales
Copy link
Contributor

The test is for enhancing the code coverage on function iconv_mime_encode().

At the moment coverage looks like:

image

After the test looks like:

image

This is the first time ever I do this, and hopefully I am following the process correctly.

Thanks in advance.

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

Thank you for the PR!

@cmb69
Copy link
Member

cmb69 commented Jun 13, 2022

@kocsismate, had it been considered to throw ValueErrors for these conditions (there are several related ones in the iconv.c):

php-src/ext/iconv/iconv.c

Lines 1996 to 1998 in bbc0c4c

if (Z_STRLEN_P(pzval) >= ICONV_CSNMAXLEN) {
php_error_docref(NULL, E_WARNING, "Encoding parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;

Might have been a good idea, if we also would have exposed ICONV_CSNMAXLEN; users could then check the length upfront, if they're even handling user input.

@juan-morales
Copy link
Contributor Author

@kocsismate, had it been considered to throw ValueErrors for these conditions (there are several related ones in the iconv.c):

php-src/ext/iconv/iconv.c

Lines 1996 to 1998 in bbc0c4c

if (Z_STRLEN_P(pzval) >= ICONV_CSNMAXLEN) {
php_error_docref(NULL, E_WARNING, "Encoding parameter exceeds the maximum allowed length of %d characters", ICONV_CSNMAXLEN);
RETURN_FALSE;

Might have been a good idea, if we also would have exposed ICONV_CSNMAXLEN; users could then check the length upfront, if they're even handling user input.

While working on the test I thought exactly that, ... that would be good to expose such a constant to user context.

@juan-morales
Copy link
Contributor Author

I enhanced the test to cover a little bit more. I think is good to keep them in same test as is testing basically identically things in the same function.

Before test
image

After test
image

@juan-morales juan-morales changed the title Add test for iconv_mime_encode() for preference input-charset Add test for iconv_mime_encode() for preference input-charset and output-charset Jun 13, 2022
Copy link
Contributor Author

@juan-morales juan-morales left a comment

Choose a reason for hiding this comment

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

all changes done

@juan-morales juan-morales requested a review from cmb69 June 13, 2022 21:18
Copy link
Contributor Author

@juan-morales juan-morales left a comment

Choose a reason for hiding this comment

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

@cmb69 the change still looks with the "Changes requested" label ... can you take a look? I think is because of your review. I also dont know if that is important or not to consider my change to be merge.

Thanks in advance.

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

Thank you!

@cmb69 cmb69 closed this in 3a29c2e Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants