Skip to content
This repository was archived by the owner on Dec 6, 2018. It is now read-only.

Commit

Permalink
Resolved vulnerability with using unsanitized strings
Browse files Browse the repository at this point in the history
  • Loading branch information
lincolnfrog committed Mar 15, 2018
1 parent dbbd24b commit 284aad8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ This package lives in the npm index.

**Current builds are not working on Windows ([#261](https://github.com/googlevr/vrview/issues/261))**

Relevant commands:
```shell
$ npm run build # builds the iframe embed and JS API (full and minified versions).

# Building

This project uses `browserify` to manage dependencies and build. `watchify` is
especially convenient to preserve the write-and-reload model of development.
This package lives in the npm index.

Relevant commands:
```shell
$ npm run build # builds the iframe embed and JS API (full and minified versions).
Expand All @@ -77,3 +67,7 @@ $ npm run watch-api # auto-builds the JS API code whenever any source changes.
```
As of 2017/06/13, the pre-built js artifacts have been removed from source
control. You must run `npm run build` prior to trying any of the examples.

# Release Notes
## 2.0.2
Close vulnerability with unsanitized user strings being injected into DOM
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vrview",
"version": "2.0.1",
"version": "2.0.2",
"description": "Embed VR content into your webpage.",
"main": "index.js",
"dependencies": {
Expand Down
10 changes: 7 additions & 3 deletions src/embed/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,20 @@ function onRenderError(message) {
showError('Render: ' + message);
}

function showError(message, opt_title) {
function showError(message) {
// Hide loading indicator.
loadIndicator.hide();

// Sanitize `message` as it could contain user supplied
// values. Re-add the space character as to not modify the
// error messages used throughout the codebase.
message = encodeURI(message).replace(/%20/g, ' ');

var error = document.querySelector('#error');
error.classList.add('visible');
error.querySelector('.message').innerHTML = message;

var title = (opt_title !== undefined ? opt_title : 'Error');
error.querySelector('.title').innerHTML = title;
error.querySelector('.title').innerHTML = 'Error';
}

function hideError() {
Expand Down
6 changes: 3 additions & 3 deletions src/embed/scene-info.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ function SceneInfo(opt_params) {
muted: opt_params.muted
};

this.image = params.image;
this.preview = params.preview;
this.video = params.video;
this.image = params.image !== undefined ? encodeURI(params.image) : undefined;
this.preview = params.preview !== undefined ? encodeURI(params.preview) : undefined;
this.video = params.video !== undefined ? encodeURI(params.video) : undefined;
this.defaultYaw = THREE.Math.degToRad(params.defaultYaw || 0);

this.isStereo = Util.parseBoolean(params.isStereo);
Expand Down

0 comments on commit 284aad8

Please sign in to comment.