Skip to content
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

[DRAFT] fix(core): support multiple base64 RFCs in Artifact serialization #1870

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

greghopkins
Copy link
Contributor

@greghopkins greghopkins commented Aug 23, 2023

BrowserStack is returning some screenshot data in base64 with the older RFC 2045 style (see the variants summary table), which includes mandatory newlines every 76 characters.

More generally, in this style, whitespace (including newline) is ignored/irrelevant:

$ echo "this is my cool string" | base64
dGhpcyBpcyBteSBjb29sIHN0cmluZwo=

$ echo -e "dGhpcyBpc\\nyBteSBjb29sIH   N0cmluZwo=" | base64 -D
this is my cool string

@jan-molak I'm not quite sure the best way to suggest to handle this... I see some options:

  1. Sanitize the input strings by removing all whitespace
  2. Modify the regex in looksLikeBase64Encoded() which is what I started to do in this PR
  3. Something else?

Thoughts?

@greghopkins
Copy link
Contributor Author

@jan-molak The main issue with what's proposed here is this assertion:

photo.map(value => expect(value.toString('base64')).to.equal(photo.base64EncodedValue));

base64EncodedValue is a member variable that includes any extra whitespace. value.toString('base64') produces the "normalized" version that includes no whitespace, failing.

@jan-molak
Copy link
Member

Hello @greghopkins! Nice catch. Hmm, I think I'd be leaning more towards sanitising the input rather than relaxing the constraint.

This would require us to change:

To avoid code duplication we could introduce a protected method in the base Page class like Page.base64Rfc2045ToBase64(...) to sanitise the result of this.browser.takeScreenshot(), or add such converter to core/io instead.

What do you think?

@jan-molak jan-molak marked this pull request as draft August 25, 2023 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants