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

Validate the Preferences when fetching them from storage #9936

Merged
merged 2 commits into from
Jul 29, 2018

Conversation

Snuffleupagus
Copy link
Collaborator

  • Stop re-loading the Preferences in PDFViewerApplication.open, and remove the BasePreferences.reload method

    Given that the various Preferences are currently, and have been for quite some time, only used when initializing PDFViewerApplication re-loading them when a new PDF file is opened in the viewer is essentially a no-op.

    Furthermore, with the only usage of BasePreferences.reload now gone, the value of that method seems questionable at best. In the event that the functionality is actually needed again, similar to the ViewHistory, it'd probably make more sense to simply replace PDFViewerApplication.preferences with a new BasePreferences instance instead (using e.g. DefaultExternalServices.createPreferences).

  • Validate the Preferences when fetching them from storage

    When updating Preferences using the set method, the input is carefully validated. However, no validation is (currently) done when a BasePreferences instance is created, which probably isn't that great. Hence this patch that simply ignores, to not unnecessarily break loading of the viewer itself, any invalid Preferences.

…emove the `BasePreferences.reload` method

Given that the various Preferences are currently, and have been for quite some time, only used when initializing `PDFViewerApplication` re-loading them when a new PDF file is opened in the viewer is essentially a no-op.

Furthermore, with the only usage of `BasePreferences.reload` now gone, the value of that method seems questionable at best. In the event that the functionality is actually needed again, similar to the `ViewHistory`, it'd probably make more sense to simply replace `PDFViewerApplication.preferences` with a new `BasePreferences` instance instead (using e.g. `DefaultExternalServices.createPreferences`).
When updating Preferences using the `set` method, the input is carefully validated. However, no validation is (currently) done when a `BasePreferences` instance is created, which probably isn't that great. Hence this patch that simply ignores, to not unnecessarily break loading of the viewer itself, any invalid Preferences.
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/88368acc38ea502/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/88368acc38ea502/output.txt

Total script time: 2.90 mins

Published

@timvandermeij timvandermeij merged commit d19e13e into mozilla:master Jul 29, 2018
@timvandermeij
Copy link
Contributor

Looks good. Thank you for improving this!

@Snuffleupagus Snuffleupagus deleted the BasePreferences-validate branch July 30, 2018 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants