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

Encoding image 'srcset' value including the intrinsic width #712

Merged
merged 1 commit into from
Aug 1, 2022

Conversation

yasarkunduz
Copy link
Contributor

Description

When the image attribute srcset value contains an unsupported character(https://www.rfc-editor.org/rfc/rfc3986#section-2) then the url will be encoded. In this case the value contains a space and the image intrinsic width which will cause a broken image after encoding.

Motivation and Context

This resolves the problem with encoding image url excluding the intrinsic width.

Types of changes

  • Replay fix (fixes a replay specific issue)
  • [x ] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • [ x] I have added or updated tests to cover my changes.
  • [ x] All new and existing tests passed.

@ikreymer ikreymer merged commit 32e9020 into webrecorder:main Aug 1, 2022
@@ -177,7 +177,7 @@ def _rewrite_srcset(self, value, mod=''):
return ''

values = (url.strip() for url in re.split(self.SRCSET_REGEX, value) if url)
values = [self._rewrite_url(v.strip()) for v in values]
values = [self._rewrite_url(v.split(' ')[0].strip()) + (' ' + ' '.join(v.split(' ')[1:])).rstrip() for v in values if v]
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to see a comment here for what is going on here, and why it is needed.

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.

3 participants