Skip to content

Fixes for Orion Browser #3610 #4432

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions content_scripts/vimium.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* the style of our Vimium dialogs.
*
* The z-indexes of Vimium elements are very large, because we always want them to show on top. We
* know that Chrome supports z-index values up to about 2^31. The values we use are large numbers
* know that Chrome supports z-index values up to about 2,147,483,648. The values we use are large numbers
* approaching that bound. However, we must leave headroom for link hints. Hint marker z-indexes
* start at 2140000001.
*/
Expand Down Expand Up @@ -33,7 +33,7 @@ tr.vimiumReset {
cursor: auto;
display: inline;
float: none;
font-family : "Helvetica Neue", "Helvetica", "Arial", sans-serif;
font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
font-size: inherit;
font-style: normal;
font-variant: normal;
Expand Down
13 changes: 12 additions & 1 deletion lib/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,23 @@ const Settings = {
const shouldMigrate = settings["settingsVersion"] == null;
if (!shouldMigrate) return settings;

// Safari struggles to parse anything that isn't a stringified JSON object when using JSON.parse().
// This ensures that only stringified JSON objects get passed into the parser.
const isValidJSON = (str) => {
try {
JSON.parse(str);
return true;
} catch (e) {
return false;
}
};

// Migration for v2.0.0: decode all values so that they're not JSON string encoded.
const newSettings = {};
for (const [k, v] of Object.entries(settings)) {
// Most pre-2.0 settings were strings, but the global marks were stored as native values. See
// #4323. So check the setting value's type before migrating.
if (typeof v === "string") {
if (typeof v === "string" && isValidJSON(v)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This code will call JSON.parse(str) twice on every successful call instead of putting the try-catch directly where it's necessary.

newSettings[k] = JSON.parse(v);
} else {
newSettings[k] = v;
Expand Down