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

[py] disable strict time stamps in Firefox profile #15141

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

Delta456
Copy link
Contributor

@Delta456 Delta456 commented Jan 23, 2025

User description

Thanks for contributing to Selenium!
A PR well described will help maintainers to quickly review and merge it

Before submitting your PR, please check our contributing guidelines.
Avoid large PRs, help reviewers by making them as simple and short as possible.

Description

Fixes #15138

Motivation and Context

  • Allow zipping profiles with files and directories stamped earlier than 1980

Types of changes

  • 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

  • I have read the contributing document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

PR Type

Bug fix


Description

  • Fixed install_addon method to handle timestamps before 1980.

  • Updated zipfile.ZipFile usage to disable strict timestamps.

  • Resolved issue with zipping Firefox profiles containing old timestamps.


Changes walkthrough 📝

Relevant files
Bug fix
webdriver.py
Disable strict timestamps in `install_addon` method           

py/selenium/webdriver/firefox/webdriver.py

  • Modified zipfile.ZipFile to include strict_timestamps=False.
  • Ensured compatibility with files having timestamps before 1980.
  • Adjusted install_addon method for improved error handling.
  • +1/-1     

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    🎫 Ticket compliance analysis ✅

    15138 - PR Code Verified

    Compliant requirements:

    • Fix Firefox addon installation error when files have timestamps before 1980
    • Change zipfile.ZipFile to use strict_timestamps=False parameter
    • Fix should be applied to install_addon() method in webdriver.py

    Requires further human verification:

    • Verify that Firefox addons with pre-1980 timestamps can now be installed successfully
    ⏱️ Estimated effort to review: 1 🔵⚪⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ No major issues detected

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Possible issue
    Add error handling for zip creation

    Add error handling around the zipfile creation to catch potential file access or
    permission errors that could occur during addon installation.

    py/selenium/webdriver/firefox/webdriver.py [134-138]

    -with zipfile.ZipFile(fp, "w", zipfile.ZIP_DEFLATED, strict_timestamps=False) as zipped:
    -    for base, _, files in os.walk(path):
    -        for fyle in files:
    -            filename = os.path.join(base, fyle)
    -            zipped.write(filename, filename[path_root:])
    +try:
    +    with zipfile.ZipFile(fp, "w", zipfile.ZIP_DEFLATED, strict_timestamps=False) as zipped:
    +        for base, _, files in os.walk(path):
    +            for fyle in files:
    +                filename = os.path.join(base, fyle)
    +                zipped.write(filename, filename[path_root:])
    +except (OSError, zipfile.BadZipFile) as e:
    +    raise WebDriverException(f"Failed to create addon zip file: {e}")
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: Adding error handling for zip file operations is crucial for robustness, as file system operations can fail due to permissions or I/O issues. The suggestion properly catches relevant exceptions and provides meaningful error messages.

    8

    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.

    [🐛 Bug]: Firefox ZIP timestamps, part 2
    1 participant