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

Uncaught SyntaxError: Octal literals are not allowed in strict mode. #2209

Closed
heeton opened this Issue Oct 6, 2012 · 6 comments

Comments

Projects
None yet
5 participants
@heeton

heeton commented Oct 6, 2012

I'm getting this error in Chrome (and a slightly different varient in Safari) on OSX. Any ideas?

@yurydelendik

This comment has been minimized.

Show comment
Hide comment
@yurydelendik

yurydelendik Oct 6, 2012

Contributor

Could you copy full error message and its location? http://mozilla.github.com/pdf.js/web/viewer.html works for me

Contributor

yurydelendik commented Oct 6, 2012

Could you copy full error message and its location? http://mozilla.github.com/pdf.js/web/viewer.html works for me

@heeton

This comment has been minimized.

Show comment
Hide comment
@heeton

heeton Oct 6, 2012

Ok, It seems to arise only when compressing the JS file with sprockets (rails 3.2 asset pipeline in my case). I've just tried requiring it directly from here, and it works without the error.

Feel free to close the request if you don't think it needs exploring.

heeton commented Oct 6, 2012

Ok, It seems to arise only when compressing the JS file with sprockets (rails 3.2 asset pipeline in my case). I've just tried requiring it directly from here, and it works without the error.

Feel free to close the request if you don't think it needs exploring.

@czaber

This comment has been minimized.

Show comment
Hide comment
@czaber

czaber Nov 26, 2012

In case somebody need this, there is a little hack to prevent uglifyjs from changing '\x00\x31' into '\01' which turns out to be octal literal forbidden by "use strict";.

diff --git a/pdf.js b/pdf.js
index 966f307..d60045b 100644
--- a/pdf.js
+++ b/pdf.js
@@ -1,3 +1,4 @@
+"use strict";
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 /* Copyright 2012 Mozilla Foundation
@@ -17617,6 +17618,7 @@ var Font = (function FontClosure() {
       winDescent = -typoDescent;
     }

+    var x31 = '\x31'; // to prevent converting by uglifier
     return '\x00\x03' + // version
            '\x02\x24' + // xAvgCharWidth
            '\x01\xF4' + // usWeightClass
@@ -17630,7 +17632,7 @@ var Font = (function FontClosure() {
            '\x02\xBB' + // ySuperScriptYSize
            '\x00\x00' + // ySuperScriptXOffset
            '\x01\xDF' + // ySuperScriptYOffset
-           '\x00\x31' + // yStrikeOutSize
+           '\x00'+x31 + // yStrikeOutSize
            '\x01\x02' + // yStrikeOutPosition
            '\x00\x00' + // sFamilyClass
            '\x00\x00\x06' +

czaber commented Nov 26, 2012

In case somebody need this, there is a little hack to prevent uglifyjs from changing '\x00\x31' into '\01' which turns out to be octal literal forbidden by "use strict";.

diff --git a/pdf.js b/pdf.js
index 966f307..d60045b 100644
--- a/pdf.js
+++ b/pdf.js
@@ -1,3 +1,4 @@
+"use strict";
 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
 /* Copyright 2012 Mozilla Foundation
@@ -17617,6 +17618,7 @@ var Font = (function FontClosure() {
       winDescent = -typoDescent;
     }

+    var x31 = '\x31'; // to prevent converting by uglifier
     return '\x00\x03' + // version
            '\x02\x24' + // xAvgCharWidth
            '\x01\xF4' + // usWeightClass
@@ -17630,7 +17632,7 @@ var Font = (function FontClosure() {
            '\x02\xBB' + // ySuperScriptYSize
            '\x00\x00' + // ySuperScriptXOffset
            '\x01\xDF' + // ySuperScriptYOffset
-           '\x00\x31' + // yStrikeOutSize
+           '\x00'+x31 + // yStrikeOutSize
            '\x01\x02' + // yStrikeOutPosition
            '\x00\x00' + // sFamilyClass
            '\x00\x00\x06' +
@panSarin

This comment has been minimized.

Show comment
Hide comment
@panSarin

panSarin Feb 25, 2013

@heeton:

Could u explain what u mean by : "I've just tried requiring it directly from here, and it works without the error."

There are my files:
layout:
http://pastie.org/6333077

pdf_viewer.js:
http://pastie.org/6333080

And compiled widgets/pdfjs/worker_loader.js that generate error Octal literals are not allowed in strict mode.
http://pastie.org/6333096

and i dont have idea how should i change pathes to require files "directly from here" . It would be nice if u give me some hint ;]

panSarin commented Feb 25, 2013

@heeton:

Could u explain what u mean by : "I've just tried requiring it directly from here, and it works without the error."

There are my files:
layout:
http://pastie.org/6333077

pdf_viewer.js:
http://pastie.org/6333080

And compiled widgets/pdfjs/worker_loader.js that generate error Octal literals are not allowed in strict mode.
http://pastie.org/6333096

and i dont have idea how should i change pathes to require files "directly from here" . It would be nice if u give me some hint ;]

@heeton

This comment has been minimized.

Show comment
Hide comment
@heeton

heeton Feb 25, 2013

@panSarin: instead of

= javascript_include_tag "pdf_viewer"

include the javascript normally, to avoid the rails pipeline

<script src="/javascripts/pdf_viewer.js"></script>

heeton commented Feb 25, 2013

@panSarin: instead of

= javascript_include_tag "pdf_viewer"

include the javascript normally, to avoid the rails pipeline

<script src="/javascripts/pdf_viewer.js"></script>
@vermilion1

This comment has been minimized.

Show comment
Hide comment
@vermilion1

vermilion1 Jun 26, 2013

@czaber thanks for your solution.

vermilion1 commented Jun 26, 2013

@czaber thanks for your solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment