You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ma...@apache.org on 2018/11/29 15:03:00 UTC

[incubator-netbeans] branch release100 updated (6242f29 -> 8e8763d)

This is an automated email from the ASF dual-hosted git repository.

matthiasblaesing pushed a change to branch release100
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git.


    from 6242f29  Provide localized error description
     new 52e3035  Add Rhino javascript interpreter library
     new c308357  Switch to Rhino as PAC evaluator
     new 8e8763d  Merge branch 'rhino_pac_release100' into release100

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 nbbuild/cluster.properties                         |   1 +
 nbbuild/licenses/MPL-2.0                           | 373 ++++++++++++++++++++
 platform/core.network/arch.xml                     |  12 +-
 platform/core.network/nbproject/project.xml        |   9 +
 .../proxy/pac/datetime/PacUtilsDateTime.java       |  13 +-
 .../proxy/pac/impl/ClassFilterPacHelpers.java      |  42 ---
 .../proxy/pac/impl/NbPacScriptEvaluator.java       | 283 +++++++--------
 .../test/unit/data/pacFiles/wpad space.dat         |  22 --
 .../core/network/proxy/pac/PacEngineTest.java      |  23 ++
 platform/libs.rhino/build.xml                      |  24 ++
 platform/libs.rhino/external/binaries-list         |  17 +
 .../libs.rhino/external/rhino-1.7.10-license.txt   | 380 +++++++++++++++++++++
 platform/libs.rhino/manifest.mf                    |   4 +
 platform/libs.rhino/nbproject/project.properties   |  21 ++
 platform/libs.rhino/nbproject/project.xml          |  39 +++
 .../src/org/netbeans/libs/rhino/Bundle.properties  |  22 ++
 16 files changed, 1043 insertions(+), 242 deletions(-)
 create mode 100644 nbbuild/licenses/MPL-2.0
 delete mode 100644 platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/ClassFilterPacHelpers.java
 delete mode 100644 platform/core.network/test/unit/data/pacFiles/wpad space.dat
 create mode 100644 platform/libs.rhino/build.xml
 create mode 100644 platform/libs.rhino/external/binaries-list
 create mode 100644 platform/libs.rhino/external/rhino-1.7.10-license.txt
 create mode 100644 platform/libs.rhino/manifest.mf
 create mode 100644 platform/libs.rhino/nbproject/project.properties
 create mode 100644 platform/libs.rhino/nbproject/project.xml
 create mode 100644 platform/libs.rhino/src/org/netbeans/libs/rhino/Bundle.properties


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[incubator-netbeans] 01/03: Add Rhino javascript interpreter library

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

matthiasblaesing pushed a commit to branch release100
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git

commit 52e3035f9991f1f682b1c34ef659ffc88eb43a5b
Author: Matthias Bläsing <mb...@doppel-helix.eu>
AuthorDate: Thu Nov 22 12:45:36 2018 +0100

    Add Rhino javascript interpreter library
---
 nbbuild/cluster.properties                         |   1 +
 nbbuild/licenses/MPL-2.0                           | 373 ++++++++++++++++++++
 platform/libs.rhino/build.xml                      |  24 ++
 platform/libs.rhino/external/binaries-list         |  17 +
 .../libs.rhino/external/rhino-1.7.10-license.txt   | 380 +++++++++++++++++++++
 platform/libs.rhino/manifest.mf                    |   4 +
 platform/libs.rhino/nbproject/project.properties   |  21 ++
 platform/libs.rhino/nbproject/project.xml          |  39 +++
 .../src/org/netbeans/libs/rhino/Bundle.properties  |  22 ++
 9 files changed, 881 insertions(+)

diff --git a/nbbuild/cluster.properties b/nbbuild/cluster.properties
index 7ee9105..21a3aac 100644
--- a/nbbuild/cluster.properties
+++ b/nbbuild/cluster.properties
@@ -229,6 +229,7 @@ nb.cluster.platform=\
         libs.junit4,\
         libs.junit5,\
         libs.osgi,\
+        libs.rhino,\
         libs.testng,\
         masterfs,\
         masterfs.linux,\
diff --git a/nbbuild/licenses/MPL-2.0 b/nbbuild/licenses/MPL-2.0
new file mode 100644
index 0000000..a612ad9
--- /dev/null
+++ b/nbbuild/licenses/MPL-2.0
@@ -0,0 +1,373 @@
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+    means each individual or legal entity that creates, contributes to
+    the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+    means the combination of the Contributions of others (if any) used
+    by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+    means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+    means Source Code Form to which the initial Contributor has attached
+    the notice in Exhibit A, the Executable Form of such Source Code
+    Form, and Modifications of such Source Code Form, in each case
+    including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+    means
+
+    (a) that the initial Contributor has attached the notice described
+        in Exhibit B to the Covered Software; or
+
+    (b) that the Covered Software was made available under the terms of
+        version 1.1 or earlier of the License, but not also under the
+        terms of a Secondary License.
+
+1.6. "Executable Form"
+    means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+    means a work that combines Covered Software with other material, in
+    a separate file or files, that is not Covered Software.
+
+1.8. "License"
+    means this document.
+
+1.9. "Licensable"
+    means having the right to grant, to the maximum extent possible,
+    whether at the time of the initial grant or subsequently, any and
+    all of the rights conveyed by this License.
+
+1.10. "Modifications"
+    means any of the following:
+
+    (a) any file in Source Code Form that results from an addition to,
+        deletion from, or modification of the contents of Covered
+        Software; or
+
+    (b) any new file in Source Code Form that contains any Covered
+        Software.
+
+1.11. "Patent Claims" of a Contributor
+    means any patent claim(s), including without limitation, method,
+    process, and apparatus claims, in any patent Licensable by such
+    Contributor that would be infringed, but for the grant of the
+    License, by the making, using, selling, offering for sale, having
+    made, import, or transfer of either its Contributions or its
+    Contributor Version.
+
+1.12. "Secondary License"
+    means either the GNU General Public License, Version 2.0, the GNU
+    Lesser General Public License, Version 2.1, the GNU Affero General
+    Public License, Version 3.0, or any later versions of those
+    licenses.
+
+1.13. "Source Code Form"
+    means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+    means an individual or a legal entity exercising rights under this
+    License. For legal entities, "You" includes any entity that
+    controls, is controlled by, or is under common control with You. For
+    purposes of this definition, "control" means (a) the power, direct
+    or indirect, to cause the direction or management of such entity,
+    whether by contract or otherwise, or (b) ownership of more than
+    fifty percent (50%) of the outstanding shares or beneficial
+    ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+    Licensable by such Contributor to use, reproduce, make available,
+    modify, display, perform, distribute, and otherwise exploit its
+    Contributions, either on an unmodified basis, with Modifications, or
+    as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+    for sale, have made, import, and otherwise transfer either its
+    Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+    or
+
+(b) for infringements caused by: (i) Your and any other third party's
+    modifications of Covered Software, or (ii) the combination of its
+    Contributions with other software (except as part of its Contributor
+    Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+    its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+    Form, as described in Section 3.1, and You must inform recipients of
+    the Executable Form how they can obtain a copy of such Source Code
+    Form by reasonable means in a timely manner, at a charge no more
+    than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+    License, or sublicense it under different terms, provided that the
+    license for the Executable Form does not attempt to limit or alter
+    the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+*                                                                      *
+*  6. Disclaimer of Warranty                                           *
+*  -------------------------                                           *
+*                                                                      *
+*  Covered Software is provided under this License on an "as is"       *
+*  basis, without warranty of any kind, either expressed, implied, or  *
+*  statutory, including, without limitation, warranties that the       *
+*  Covered Software is free of defects, merchantable, fit for a        *
+*  particular purpose or non-infringing. The entire risk as to the     *
+*  quality and performance of the Covered Software is with You.        *
+*  Should any Covered Software prove defective in any respect, You     *
+*  (not any Contributor) assume the cost of any necessary servicing,   *
+*  repair, or correction. This disclaimer of warranty constitutes an   *
+*  essential part of this License. No use of any Covered Software is   *
+*  authorized under this License except under this disclaimer.         *
+*                                                                      *
+************************************************************************
+
+************************************************************************
+*                                                                      *
+*  7. Limitation of Liability                                          *
+*  --------------------------                                          *
+*                                                                      *
+*  Under no circumstances and under no legal theory, whether tort      *
+*  (including negligence), contract, or otherwise, shall any           *
+*  Contributor, or anyone who distributes Covered Software as          *
+*  permitted above, be liable to You for any direct, indirect,         *
+*  special, incidental, or consequential damages of any character      *
+*  including, without limitation, damages for lost profits, loss of    *
+*  goodwill, work stoppage, computer failure or malfunction, or any    *
+*  and all other commercial damages or losses, even if such party      *
+*  shall have been informed of the possibility of such damages. This   *
+*  limitation of liability shall not apply to liability for death or   *
+*  personal injury resulting from such party's negligence to the       *
+*  extent applicable law prohibits such limitation. Some               *
+*  jurisdictions do not allow the exclusion or limitation of           *
+*  incidental or consequential damages, so this exclusion and          *
+*  limitation may not apply to You.                                    *
+*                                                                      *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+  This Source Code Form is subject to the terms of the Mozilla Public
+  License, v. 2.0. If a copy of the MPL was not distributed with this
+  file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+  This Source Code Form is "Incompatible With Secondary Licenses", as
+  defined by the Mozilla Public License, v. 2.0.
diff --git a/platform/libs.rhino/build.xml b/platform/libs.rhino/build.xml
new file mode 100644
index 0000000..b224dec
--- /dev/null
+++ b/platform/libs.rhino/build.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project name="platform/libs.rhino" default="build" basedir=".">
+    <import file="../../nbbuild/templates/projectized.xml"/>
+</project>
diff --git a/platform/libs.rhino/external/binaries-list b/platform/libs.rhino/external/binaries-list
new file mode 100644
index 0000000..f707592
--- /dev/null
+++ b/platform/libs.rhino/external/binaries-list
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+24650BD98B1041DF2EB1BE5CB64DD1AD5B2E7C55 org.mozilla:rhino:1.7.10
diff --git a/platform/libs.rhino/external/rhino-1.7.10-license.txt b/platform/libs.rhino/external/rhino-1.7.10-license.txt
new file mode 100644
index 0000000..4cee288
--- /dev/null
+++ b/platform/libs.rhino/external/rhino-1.7.10-license.txt
@@ -0,0 +1,380 @@
+Name: Rhino: JavaScript in Java
+Version: 1.7.10
+License: MPL-2.0
+Origin: https://developer.mozilla.org/de/docs/Rhino
+URL: https://github.com/mozilla/rhino
+Description: Rhino is an implementation of JavaScript in Java.
+
+Mozilla Public License Version 2.0
+==================================
+
+1. Definitions
+--------------
+
+1.1. "Contributor"
+    means each individual or legal entity that creates, contributes to
+    the creation of, or owns Covered Software.
+
+1.2. "Contributor Version"
+    means the combination of the Contributions of others (if any) used
+    by a Contributor and that particular Contributor's Contribution.
+
+1.3. "Contribution"
+    means Covered Software of a particular Contributor.
+
+1.4. "Covered Software"
+    means Source Code Form to which the initial Contributor has attached
+    the notice in Exhibit A, the Executable Form of such Source Code
+    Form, and Modifications of such Source Code Form, in each case
+    including portions thereof.
+
+1.5. "Incompatible With Secondary Licenses"
+    means
+
+    (a) that the initial Contributor has attached the notice described
+        in Exhibit B to the Covered Software; or
+
+    (b) that the Covered Software was made available under the terms of
+        version 1.1 or earlier of the License, but not also under the
+        terms of a Secondary License.
+
+1.6. "Executable Form"
+    means any form of the work other than Source Code Form.
+
+1.7. "Larger Work"
+    means a work that combines Covered Software with other material, in
+    a separate file or files, that is not Covered Software.
+
+1.8. "License"
+    means this document.
+
+1.9. "Licensable"
+    means having the right to grant, to the maximum extent possible,
+    whether at the time of the initial grant or subsequently, any and
+    all of the rights conveyed by this License.
+
+1.10. "Modifications"
+    means any of the following:
+
+    (a) any file in Source Code Form that results from an addition to,
+        deletion from, or modification of the contents of Covered
+        Software; or
+
+    (b) any new file in Source Code Form that contains any Covered
+        Software.
+
+1.11. "Patent Claims" of a Contributor
+    means any patent claim(s), including without limitation, method,
+    process, and apparatus claims, in any patent Licensable by such
+    Contributor that would be infringed, but for the grant of the
+    License, by the making, using, selling, offering for sale, having
+    made, import, or transfer of either its Contributions or its
+    Contributor Version.
+
+1.12. "Secondary License"
+    means either the GNU General Public License, Version 2.0, the GNU
+    Lesser General Public License, Version 2.1, the GNU Affero General
+    Public License, Version 3.0, or any later versions of those
+    licenses.
+
+1.13. "Source Code Form"
+    means the form of the work preferred for making modifications.
+
+1.14. "You" (or "Your")
+    means an individual or a legal entity exercising rights under this
+    License. For legal entities, "You" includes any entity that
+    controls, is controlled by, or is under common control with You. For
+    purposes of this definition, "control" means (a) the power, direct
+    or indirect, to cause the direction or management of such entity,
+    whether by contract or otherwise, or (b) ownership of more than
+    fifty percent (50%) of the outstanding shares or beneficial
+    ownership of such entity.
+
+2. License Grants and Conditions
+--------------------------------
+
+2.1. Grants
+
+Each Contributor hereby grants You a world-wide, royalty-free,
+non-exclusive license:
+
+(a) under intellectual property rights (other than patent or trademark)
+    Licensable by such Contributor to use, reproduce, make available,
+    modify, display, perform, distribute, and otherwise exploit its
+    Contributions, either on an unmodified basis, with Modifications, or
+    as part of a Larger Work; and
+
+(b) under Patent Claims of such Contributor to make, use, sell, offer
+    for sale, have made, import, and otherwise transfer either its
+    Contributions or its Contributor Version.
+
+2.2. Effective Date
+
+The licenses granted in Section 2.1 with respect to any Contribution
+become effective for each Contribution on the date the Contributor first
+distributes such Contribution.
+
+2.3. Limitations on Grant Scope
+
+The licenses granted in this Section 2 are the only rights granted under
+this License. No additional rights or licenses will be implied from the
+distribution or licensing of Covered Software under this License.
+Notwithstanding Section 2.1(b) above, no patent license is granted by a
+Contributor:
+
+(a) for any code that a Contributor has removed from Covered Software;
+    or
+
+(b) for infringements caused by: (i) Your and any other third party's
+    modifications of Covered Software, or (ii) the combination of its
+    Contributions with other software (except as part of its Contributor
+    Version); or
+
+(c) under Patent Claims infringed by Covered Software in the absence of
+    its Contributions.
+
+This License does not grant any rights in the trademarks, service marks,
+or logos of any Contributor (except as may be necessary to comply with
+the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
+
+No Contributor makes additional grants as a result of Your choice to
+distribute the Covered Software under a subsequent version of this
+License (see Section 10.2) or under the terms of a Secondary License (if
+permitted under the terms of Section 3.3).
+
+2.5. Representation
+
+Each Contributor represents that the Contributor believes its
+Contributions are its original creation(s) or it has sufficient rights
+to grant the rights to its Contributions conveyed by this License.
+
+2.6. Fair Use
+
+This License is not intended to limit any rights You have under
+applicable copyright doctrines of fair use, fair dealing, or other
+equivalents.
+
+2.7. Conditions
+
+Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
+in Section 2.1.
+
+3. Responsibilities
+-------------------
+
+3.1. Distribution of Source Form
+
+All distribution of Covered Software in Source Code Form, including any
+Modifications that You create or to which You contribute, must be under
+the terms of this License. You must inform recipients that the Source
+Code Form of the Covered Software is governed by the terms of this
+License, and how they can obtain a copy of this License. You may not
+attempt to alter or restrict the recipients' rights in the Source Code
+Form.
+
+3.2. Distribution of Executable Form
+
+If You distribute Covered Software in Executable Form then:
+
+(a) such Covered Software must also be made available in Source Code
+    Form, as described in Section 3.1, and You must inform recipients of
+    the Executable Form how they can obtain a copy of such Source Code
+    Form by reasonable means in a timely manner, at a charge no more
+    than the cost of distribution to the recipient; and
+
+(b) You may distribute such Executable Form under the terms of this
+    License, or sublicense it under different terms, provided that the
+    license for the Executable Form does not attempt to limit or alter
+    the recipients' rights in the Source Code Form under this License.
+
+3.3. Distribution of a Larger Work
+
+You may create and distribute a Larger Work under terms of Your choice,
+provided that You also comply with the requirements of this License for
+the Covered Software. If the Larger Work is a combination of Covered
+Software with a work governed by one or more Secondary Licenses, and the
+Covered Software is not Incompatible With Secondary Licenses, this
+License permits You to additionally distribute such Covered Software
+under the terms of such Secondary License(s), so that the recipient of
+the Larger Work may, at their option, further distribute the Covered
+Software under the terms of either this License or such Secondary
+License(s).
+
+3.4. Notices
+
+You may not remove or alter the substance of any license notices
+(including copyright notices, patent notices, disclaimers of warranty,
+or limitations of liability) contained within the Source Code Form of
+the Covered Software, except that You may alter any license notices to
+the extent required to remedy known factual inaccuracies.
+
+3.5. Application of Additional Terms
+
+You may choose to offer, and to charge a fee for, warranty, support,
+indemnity or liability obligations to one or more recipients of Covered
+Software. However, You may do so only on Your own behalf, and not on
+behalf of any Contributor. You must make it absolutely clear that any
+such warranty, support, indemnity, or liability obligation is offered by
+You alone, and You hereby agree to indemnify every Contributor for any
+liability incurred by such Contributor as a result of warranty, support,
+indemnity or liability terms You offer. You may include additional
+disclaimers of warranty and limitations of liability specific to any
+jurisdiction.
+
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
+
+If it is impossible for You to comply with any of the terms of this
+License with respect to some or all of the Covered Software due to
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
+describe the limitations and the code they affect. Such description must
+be placed in a text file included with all distributions of the Covered
+Software under this License. Except to the extent prohibited by statute
+or regulation, such description must be sufficiently detailed for a
+recipient of ordinary skill to be able to understand it.
+
+5. Termination
+--------------
+
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms. However, if You become
+compliant, then the rights granted under this License from a particular
+Contributor are reinstated (a) provisionally, unless and until such
+Contributor explicitly and finally terminates Your grants, and (b) on an
+ongoing basis, if such Contributor fails to notify You of the
+non-compliance by some reasonable means prior to 60 days after You have
+come back into compliance. Moreover, Your grants from a particular
+Contributor are reinstated on an ongoing basis if such Contributor
+notifies You of the non-compliance by some reasonable means, this is the
+first time You have received notice of non-compliance with this License
+from such Contributor, and You become compliant prior to 30 days after
+Your receipt of the notice.
+
+5.2. If You initiate litigation against any entity by asserting a patent
+infringement claim (excluding declaratory judgment actions,
+counter-claims, and cross-claims) alleging that a Contributor Version
+directly or indirectly infringes any patent, then the rights granted to
+You by any and all Contributors for the Covered Software under Section
+2.1 of this License shall terminate.
+
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
+end user license agreements (excluding distributors and resellers) which
+have been validly granted by You or Your distributors under this License
+prior to termination shall survive termination.
+
+************************************************************************
+*                                                                      *
+*  6. Disclaimer of Warranty                                           *
+*  -------------------------                                           *
+*                                                                      *
+*  Covered Software is provided under this License on an "as is"       *
+*  basis, without warranty of any kind, either expressed, implied, or  *
+*  statutory, including, without limitation, warranties that the       *
+*  Covered Software is free of defects, merchantable, fit for a        *
+*  particular purpose or non-infringing. The entire risk as to the     *
+*  quality and performance of the Covered Software is with You.        *
+*  Should any Covered Software prove defective in any respect, You     *
+*  (not any Contributor) assume the cost of any necessary servicing,   *
+*  repair, or correction. This disclaimer of warranty constitutes an   *
+*  essential part of this License. No use of any Covered Software is   *
+*  authorized under this License except under this disclaimer.         *
+*                                                                      *
+************************************************************************
+
+************************************************************************
+*                                                                      *
+*  7. Limitation of Liability                                          *
+*  --------------------------                                          *
+*                                                                      *
+*  Under no circumstances and under no legal theory, whether tort      *
+*  (including negligence), contract, or otherwise, shall any           *
+*  Contributor, or anyone who distributes Covered Software as          *
+*  permitted above, be liable to You for any direct, indirect,         *
+*  special, incidental, or consequential damages of any character      *
+*  including, without limitation, damages for lost profits, loss of    *
+*  goodwill, work stoppage, computer failure or malfunction, or any    *
+*  and all other commercial damages or losses, even if such party      *
+*  shall have been informed of the possibility of such damages. This   *
+*  limitation of liability shall not apply to liability for death or   *
+*  personal injury resulting from such party's negligence to the       *
+*  extent applicable law prohibits such limitation. Some               *
+*  jurisdictions do not allow the exclusion or limitation of           *
+*  incidental or consequential damages, so this exclusion and          *
+*  limitation may not apply to You.                                    *
+*                                                                      *
+************************************************************************
+
+8. Litigation
+-------------
+
+Any litigation relating to this License may be brought only in the
+courts of a jurisdiction where the defendant maintains its principal
+place of business and such litigation shall be governed by laws of that
+jurisdiction, without reference to its conflict-of-law provisions.
+Nothing in this Section shall prevent a party's ability to bring
+cross-claims or counter-claims.
+
+9. Miscellaneous
+----------------
+
+This License represents the complete agreement concerning the subject
+matter hereof. If any provision of this License is held to be
+unenforceable, such provision shall be reformed only to the extent
+necessary to make it enforceable. Any law or regulation which provides
+that the language of a contract shall be construed against the drafter
+shall not be used to construe this License against a Contributor.
+
+10. Versions of the License
+---------------------------
+
+10.1. New Versions
+
+Mozilla Foundation is the license steward. Except as provided in Section
+10.3, no one other than the license steward has the right to modify or
+publish new versions of this License. Each version will be given a
+distinguishing version number.
+
+10.2. Effect of New Versions
+
+You may distribute the Covered Software under the terms of the version
+of the License under which You originally received the Covered Software,
+or under the terms of any subsequent version published by the license
+steward.
+
+10.3. Modified Versions
+
+If you create software not governed by this License, and you want to
+create a new license for such software, you may create and use a
+modified version of this License if you rename the license and remove
+any references to the name of the license steward (except to note that
+such modified license differs from this License).
+
+10.4. Distributing Source Code Form that is Incompatible With Secondary
+Licenses
+
+If You choose to distribute Source Code Form that is Incompatible With
+Secondary Licenses under the terms of this version of the License, the
+notice described in Exhibit B of this License must be attached.
+
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
+
+  This Source Code Form is subject to the terms of the Mozilla Public
+  License, v. 2.0. If a copy of the MPL was not distributed with this
+  file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+If it is not possible or desirable to put the notice in a particular
+file, then You may include the notice in a location (such as a LICENSE
+file in a relevant directory) where a recipient would be likely to look
+for such a notice.
+
+You may add additional accurate notices of copyright ownership.
+
+Exhibit B - "Incompatible With Secondary Licenses" Notice
+---------------------------------------------------------
+
+  This Source Code Form is "Incompatible With Secondary Licenses", as
+  defined by the Mozilla Public License, v. 2.0.
diff --git a/platform/libs.rhino/manifest.mf b/platform/libs.rhino/manifest.mf
new file mode 100644
index 0000000..220f1b1
--- /dev/null
+++ b/platform/libs.rhino/manifest.mf
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+OpenIDE-Module: org.netbeans.libs.rhino/1
+OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/rhino/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.7.10
diff --git a/platform/libs.rhino/nbproject/project.properties b/platform/libs.rhino/nbproject/project.properties
new file mode 100644
index 0000000..bf9b950
--- /dev/null
+++ b/platform/libs.rhino/nbproject/project.properties
@@ -0,0 +1,21 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+javac.compilerargs=-Xlint -Xlint:-serial
+javac.source=1.7
+
+release.external/rhino-1.7.10.jar=modules/ext/rhino-1.7.10.jar
diff --git a/platform/libs.rhino/nbproject/project.xml b/platform/libs.rhino/nbproject/project.xml
new file mode 100644
index 0000000..2f7eaf3
--- /dev/null
+++ b/platform/libs.rhino/nbproject/project.xml
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.apisupport.project</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
+            <code-name-base>org.netbeans.libs.rhino</code-name-base>
+            <module-dependencies/>
+            <friend-packages>
+                <friend>org.netbeans.core.network</friend>
+                <package>org.mozilla.javascript</package>
+                <package>org.mozilla.javascript.debug</package>
+            </friend-packages>
+            <class-path-extension>
+                <runtime-relative-path>ext/rhino-1.7.10.jar</runtime-relative-path>
+                <binary-origin>external/rhino-1.7.10.jar</binary-origin>
+            </class-path-extension>
+        </data>
+    </configuration>
+</project>
diff --git a/platform/libs.rhino/src/org/netbeans/libs/rhino/Bundle.properties b/platform/libs.rhino/src/org/netbeans/libs/rhino/Bundle.properties
new file mode 100644
index 0000000..a423d77
--- /dev/null
+++ b/platform/libs.rhino/src/org/netbeans/libs/rhino/Bundle.properties
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+OpenIDE-Module-Name=Rhino: JavaScript in Java
+OpenIDE-Module-Display-Category=Libraries
+OpenIDE-Module-Short-Description=Bundles Rhino (JavaScript Implementation)
+OpenIDE-Module-Long-Description=\
+    This module bundles Rhino (a JavaScript Implementation written in java).


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[incubator-netbeans] 03/03: Merge branch 'rhino_pac_release100' into release100

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

matthiasblaesing pushed a commit to branch release100
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git

commit 8e8763dd8a27918b22b4af8519cfd93d5946a83a
Merge: 6242f29 c308357
Author: Matthias Bläsing <mb...@doppel-helix.eu>
AuthorDate: Thu Nov 29 16:00:18 2018 +0100

    Merge branch 'rhino_pac_release100' into release100
    
    Review was done on private@netbeans.incubator.apache.org

 nbbuild/cluster.properties                         |   1 +
 nbbuild/licenses/MPL-2.0                           | 373 ++++++++++++++++++++
 platform/core.network/arch.xml                     |  12 +-
 platform/core.network/nbproject/project.xml        |   9 +
 .../proxy/pac/datetime/PacUtilsDateTime.java       |  13 +-
 .../proxy/pac/impl/ClassFilterPacHelpers.java      |  42 ---
 .../proxy/pac/impl/NbPacScriptEvaluator.java       | 283 +++++++--------
 .../test/unit/data/pacFiles/wpad space.dat         |  22 --
 .../core/network/proxy/pac/PacEngineTest.java      |  23 ++
 platform/libs.rhino/build.xml                      |  24 ++
 platform/libs.rhino/external/binaries-list         |  17 +
 .../libs.rhino/external/rhino-1.7.10-license.txt   | 380 +++++++++++++++++++++
 platform/libs.rhino/manifest.mf                    |   4 +
 platform/libs.rhino/nbproject/project.properties   |  21 ++
 platform/libs.rhino/nbproject/project.xml          |  39 +++
 .../src/org/netbeans/libs/rhino/Bundle.properties  |  22 ++
 16 files changed, 1043 insertions(+), 242 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[incubator-netbeans] 02/03: Switch to Rhino as PAC evaluator

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

matthiasblaesing pushed a commit to branch release100
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git

commit c30835744e91d98f671678466d8cf7977bf7fa87
Author: Matthias Bläsing <mb...@doppel-helix.eu>
AuthorDate: Tue Nov 27 21:20:35 2018 +0100

    Switch to Rhino as PAC evaluator
---
 platform/core.network/arch.xml                     |  12 +-
 platform/core.network/nbproject/project.xml        |   9 +
 .../proxy/pac/datetime/PacUtilsDateTime.java       |  13 +-
 .../proxy/pac/impl/ClassFilterPacHelpers.java      |  42 ---
 .../proxy/pac/impl/NbPacScriptEvaluator.java       | 283 +++++++++------------
 .../test/unit/data/pacFiles/wpad space.dat         |  22 --
 .../core/network/proxy/pac/PacEngineTest.java      |  23 ++
 7 files changed, 162 insertions(+), 242 deletions(-)

diff --git a/platform/core.network/arch.xml b/platform/core.network/arch.xml
index 59da865..2f0d5c5 100644
--- a/platform/core.network/arch.xml
+++ b/platform/core.network/arch.xml
@@ -104,9 +104,7 @@
       which clients are supposed to download and execute in order to find 
       out which proxy to use. This is known as <a href="https://en.wikipedia.org/wiki/Proxy_auto-config">Proxy Auto-Config</a>
       (or PAC). This module provides a pluggable PAC evaluation environment
-      based on Nashorn. However, it will gracefully degrade to any other JavaScript
-      which may be installed in the JVM. Execution of the downloaded
-      JavaScript code is sandboxed. (only true for Nashorn)
+      based on Rhino. Execution of the downloaded JavaScript code is sandboxed.
   </p>
   <p>
       If you don't like the PAC evaluation environment provided
@@ -733,14 +731,6 @@
 -->
  <answer id="exec-reflection">
   <p>
-   Yes. It detects the presence of Nashorn (as opposed to say Rhino) by way 
-      of reflection. In particular it needs to know if the Java version is
-      Java 8u40 as Nashorn was greatly enhanced in that update and was more
-      or less useless (for our purpose) before this time. The use of reflection
-      means the code will gracefully 'degrade' to whatever script engine is
-      available if we are not on Java 8u40 or later.
-  </p>
-  <p>
    For testing only a dirty hack is used in our <code>FakeDns</code> class.
    This installs itself as a preferred name service in Java. This is done
    via reflection. It also uses proprietary <code>sun.*</code> package.
diff --git a/platform/core.network/nbproject/project.xml b/platform/core.network/nbproject/project.xml
index 0fe2742..57af864 100644
--- a/platform/core.network/nbproject/project.xml
+++ b/platform/core.network/nbproject/project.xml
@@ -62,6 +62,15 @@
                     </run-dependency>
                 </dependency>
                 <dependency>
+                    <code-name-base>org.netbeans.libs.rhino</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>1.7.10</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
                     <code-name-base>org.netbeans.modules.keyring</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
diff --git a/platform/core.network/src/org/netbeans/core/network/proxy/pac/datetime/PacUtilsDateTime.java b/platform/core.network/src/org/netbeans/core/network/proxy/pac/datetime/PacUtilsDateTime.java
index e08d2ce..4d224ad 100644
--- a/platform/core.network/src/org/netbeans/core/network/proxy/pac/datetime/PacUtilsDateTime.java
+++ b/platform/core.network/src/org/netbeans/core/network/proxy/pac/datetime/PacUtilsDateTime.java
@@ -260,7 +260,7 @@ public class PacUtilsDateTime {
     
     
     private static int getInteger(Object obj) throws PacDateTimeInputException {
-        if (obj instanceof Integer || obj instanceof Long) {
+        if (obj instanceof Number) {
             return ((Number) obj).intValue();
         }
         if (obj instanceof String) {
@@ -320,8 +320,9 @@ public class PacUtilsDateTime {
      * {@link PacHelperMethodsNetscape#weekdayRange(java.lang.Object...) weekdayRange()}
      * 
      * <p>
-     * Note: In Nashorn, JavaScript function arguments that are not used in the
-     * call will have a type of {@code Undefined}.
+     * Note: In Rhino, JavaScript function arguments that are not used in the
+     * call will have a type of {@code java.lang.String} and the value will be
+     * 'undefined'.
      *
      * @param objs
      * @return 
@@ -337,7 +338,8 @@ public class PacUtilsDateTime {
             }
             // Only parameters of type CharSequence (String) and 
             // Number (Integer, Long, etc) are relevant.
-            if ((obj instanceof Number) || (obj instanceof CharSequence)) {
+            // Rhino converts javascript undefined to the string "undefined"
+            if ((obj instanceof Number) || (obj instanceof CharSequence && (! "undefined".equals(obj)))) {
                 params++;
             }
         }
@@ -351,6 +353,9 @@ public class PacUtilsDateTime {
      */
     public static boolean usesGMT(Object... args) {
         int params = getNoOfParams(args);
+        if(params == 0) {
+            return false;
+        }
         if (args[params - 1] instanceof CharSequence) {
             String p = args[params - 1].toString();
             if (p.equals("GMT")) {
diff --git a/platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/ClassFilterPacHelpers.java b/platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/ClassFilterPacHelpers.java
deleted file mode 100644
index 7c5a742..0000000
--- a/platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/ClassFilterPacHelpers.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.netbeans.core.network.proxy.pac.impl;
-
-import jdk.nashorn.api.scripting.ClassFilter;
-import org.netbeans.core.network.proxy.pac.PacHelperMethods;
-
-/**
- * Nashorn class filter which helps us create a sandboxed JavaScript execution
- * environment which only has access to the Helper methods, nothing more.
- * 
- * <p>Note that the ClassFilter feature is specific to Nashorn (Rhino had the
- * {@code ClassShutter} class for this purpose), but the feature did not appear 
- * until Java 8u40.
- * 
- * @author lbruun
- */
-class ClassFilterPacHelpers implements ClassFilter {
-
-    @Override
-    public boolean exposeToScripts(String string) {
-        // The only Java class the PAC script is allowed to
-        // make use of is the PAC Helpers, nothing more. 
-        return string.equals(PacHelperMethods.class.getName());
-    }
-}
diff --git a/platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/NbPacScriptEvaluator.java b/platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/NbPacScriptEvaluator.java
index 55f09b6..334d982 100644
--- a/platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/NbPacScriptEvaluator.java
+++ b/platform/core.network/src/org/netbeans/core/network/proxy/pac/impl/NbPacScriptEvaluator.java
@@ -21,7 +21,6 @@ package org.netbeans.core.network.proxy.pac.impl;
 import java.net.InetSocketAddress;
 import java.net.Proxy;
 import java.net.URI;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
@@ -30,21 +29,19 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import javax.script.Bindings;
-import javax.script.Invocable;
-import javax.script.ScriptContext;
-import javax.script.ScriptEngine;
-import javax.script.ScriptEngineFactory;
-import javax.script.ScriptEngineManager;
-import javax.script.ScriptException;
-import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
-import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import org.mozilla.javascript.ClassShutter;
+import org.mozilla.javascript.Context;
+import org.mozilla.javascript.ContextFactory;
+import org.mozilla.javascript.EvaluatorException;
+import org.mozilla.javascript.Function;
+import org.mozilla.javascript.RhinoException;
+import org.mozilla.javascript.Scriptable;
+import org.mozilla.javascript.ScriptableObject;
 import org.netbeans.core.network.utils.SimpleObjCache;
 import org.netbeans.core.network.proxy.pac.PacHelperMethods;
 import org.netbeans.core.network.proxy.pac.PacJsEntryFunction;
 import org.netbeans.core.network.proxy.pac.PacValidationException;
 import org.netbeans.core.network.proxy.pac.PacParsingException;
-import org.openide.util.Exceptions;
 import org.netbeans.core.network.proxy.pac.PacScriptEvaluator;
 import org.netbeans.core.network.proxy.pac.PacUtils;
 import org.openide.util.Lookup;
@@ -180,14 +177,27 @@ import org.openide.util.Lookup;
 public class NbPacScriptEvaluator implements PacScriptEvaluator {
 
     private static final Logger LOGGER = Logger.getLogger(NbPacScriptEvaluator.class.getName());
-
+    // The execution limits are in place as a last resort. In general it is
+    // expected, that a PAC comes from a trusted source
+    private static final SandboxedContextFactory SANDBOXED_CONTEXT_FACTORY = new SandboxedContextFactory(
+            100_000,
+            5 * 1000,
+            new ClassShutter() {
+                @Override
+                public boolean visibleToScripts(String string) {
+                    return "org.netbeans.core.network.proxy.pac.impl.NbPacHelperMethods".equals(string)
+                            || "java.lang.String".equals(string);
+                }
+            }
+    );
 
     private static final String JS_HELPER_METHODS_INSTANCE_NAME = "jsPacHelpers";
     
     private final boolean canUseURLCaching;
-    private final PacScriptEngine scriptEngine;
+    private final Scriptable scriptEngine;
     private final SimpleObjCache<URI,List<Proxy>> resultCache;
-    
+    private final PacJsEntryFunction entryFunctionInfo;
+    private final Function entryFunction;
     private static final String PAC_PROXY = "PROXY";
     private static final String PAC_DIRECT = "DIRECT";
     private static final String PAC_SOCKS = "SOCKS";
@@ -195,20 +205,41 @@ public class NbPacScriptEvaluator implements PacScriptEvaluator {
     private static final String PAC_SOCKS5_FFEXT = "SOCKS5"; // Mozilla Firefox extension. Not part of original Netscape spec.
     private static final String PAC_HTTP_FFEXT = "HTTP"; // Mozilla Firefox extension. Not part of original Netscape spec.
     private static final String PAC_HTTPS_FFEXT = "HTTPS"; // Mozilla Firefox extension. Not part of original Netscape spec.
-    private final boolean nashornJava8u40Available;
     private final String pacScriptSource;
 
 
     public NbPacScriptEvaluator(String pacSourceCocde) throws PacParsingException {
         this.pacScriptSource = pacSourceCocde;
-        nashornJava8u40Available = getNashornJava8u40Available();
-        scriptEngine = getScriptEngine(pacSourceCocde);
         canUseURLCaching = !usesTimeDateFunctions(pacSourceCocde);
         if (canUseURLCaching) {
             resultCache = new SimpleObjCache<>(100);
         } else {
             resultCache = null;
         }
+        Context cx = SANDBOXED_CONTEXT_FACTORY.enterContext();
+        try {
+            String helperJSScript = getHelperJsScriptSource();
+            LOGGER.log(Level.FINER, "PAC Helper JavaScript :\n{0}", helperJSScript);
+
+            scriptEngine = cx.initSafeStandardObjects();
+
+            PacHelperMethods pacHelpers = Lookup.getDefault().lookup(PacHelperMethods.class);
+            if (pacHelpers == null) { // this should be redundant but we take no chances
+                pacHelpers = new NbPacHelperMethods();
+            }
+
+            ScriptableObject.putProperty(scriptEngine, JS_HELPER_METHODS_INSTANCE_NAME, pacHelpers);
+
+            cx.evaluateString(scriptEngine, pacSourceCocde, "PAC Source", 0, null);
+            cx.evaluateString(scriptEngine, helperJSScript, "JS Helper", 0, null);
+
+            entryFunctionInfo = testScriptEngine(scriptEngine, false);
+            entryFunction = (Function) ScriptableObject.getProperty(scriptEngine, entryFunctionInfo.getJsFunctionName());
+        } catch (RhinoException ex) {
+            throw new  PacParsingException(ex);
+        } finally {
+            Context.exit();
+        }
     }
 
     @Override
@@ -223,20 +254,18 @@ public class NbPacScriptEvaluator implements PacScriptEvaluator {
                 return jsResultAnalyzed;
             }
         }
+
+        Context cx = SANDBOXED_CONTEXT_FACTORY.enterContext();
         try {
-            Object jsResult = scriptEngine.findProxyForURL(PacUtils.toStrippedURLStr(uri), uri.getHost()); 
+
+            Object jsResult = entryFunction.call(cx, scriptEngine, null, new Object[] {PacUtils.toStrippedURLStr(uri), uri.getHost()});
             jsResultAnalyzed = analyzeResult(uri, jsResult);
             if (canUseURLCaching && (resultCache != null)) {
                 resultCache.put(uri, jsResultAnalyzed);   // save the result in the cache
             }
             return jsResultAnalyzed;
-        } catch (NoSuchMethodException ex) {
-            // If this exception occur at this time it is really, really unexpected. 
-            // We already gave the function a test spin in the constructor.
-            Exceptions.printStackTrace(ex);
-            return Collections.singletonList(Proxy.NO_PROXY);
-        } catch (ScriptException ex) {
-            LOGGER.log(Level.WARNING, "Error when executing PAC script function " + scriptEngine.getJsMainFunction().getJsFunctionName() + " : ", ex);
+        } catch (RhinoException ex) {
+            LOGGER.log(Level.WARNING, "Error when executing PAC script function " + entryFunctionInfo.getJsFunctionName() + " : ", ex);
             return Collections.singletonList(Proxy.NO_PROXY);
         } catch (Exception ex) {  // for runtime exceptions
             if (ex.getCause() != null) {
@@ -247,8 +276,10 @@ public class NbPacScriptEvaluator implements PacScriptEvaluator {
                 }
             }
             // other unforseen errors
-            LOGGER.log(Level.WARNING, "Error when executing PAC script function " + scriptEngine.getJsMainFunction().getJsFunctionName() + " : ", ex);
+            LOGGER.log(Level.WARNING, "Error when executing PAC script function " + entryFunctionInfo.getJsFunctionName() + " : ", ex);
             return Collections.singletonList(Proxy.NO_PROXY);
+        } finally {
+            Context.exit();
         }
     }
 
@@ -259,89 +290,29 @@ public class NbPacScriptEvaluator implements PacScriptEvaluator {
 
     @Override
     public String getJsEntryFunction() {
-        return scriptEngine.getJsMainFunction().getJsFunctionName();
+        return entryFunctionInfo.getJsFunctionName();
     }
 
     @Override
     public String getEngineInfo() {
-        ScriptEngineFactory factory = scriptEngine.getScriptEngine().getFactory();
-        return factory.getEngineName() + " version " + factory.getEngineVersion();
+        Context cx = Context.enter();
+        try {
+            return cx.getImplementationVersion();
+        } finally {
+            Context.exit();
+        }
     }
 
     @Override
     public String getPacScriptSource() {
         return this.pacScriptSource;
     }
-    
-    
 
-    private PacScriptEngine getScriptEngine(String pacSource) throws PacParsingException {
-
-        try {
-            String helperJSScript = getHelperJsScriptSource();
-            LOGGER.log(Level.FINER, "PAC Helper JavaScript :\n{0}", helperJSScript);
-            
-            ScriptEngine engine;
-            if (nashornJava8u40Available) {
-                engine = getNashornJSScriptEngine();
-            } else {
-                engine = getGenericJSScriptEngine();
-            }
-            
-            LOGGER.log(Level.FINE, "PAC script evaluator using:  {0}", getEngineInfo(engine));
-            
-            
-            PacHelperMethods pacHelpers = Lookup.getDefault().lookup(PacHelperMethods.class);
-            if (pacHelpers == null) { // this should be redundant but we take no chances
-                pacHelpers = new NbPacHelperMethods();
-            }
-            Bindings b = engine.createBindings();
-            b.put(JS_HELPER_METHODS_INSTANCE_NAME, pacHelpers);
-            engine.setBindings(b, ScriptContext.ENGINE_SCOPE);
-            
-            engine.eval(pacSource);
-            engine.eval(helperJSScript);
-
-            // Do some minimal testing of the validity of the PAC Script.
-            final PacJsEntryFunction jsMainFunction;
-            if (nashornJava8u40Available) {
-                jsMainFunction = testScriptEngine(engine, true);
-            } else {
-                jsMainFunction = testScriptEngine(engine, false);
-            }
-            
-            return new PacScriptEngine(engine, jsMainFunction);
-        } catch (ScriptException ex) {
-            throw new  PacParsingException(ex);
-        }
-    }
-    
-    private boolean getNashornJava8u40Available() {
-        try {
-            Class<?> klass = Class.forName("jdk.nashorn.api.scripting.NashornScriptEngineFactory");
-        } catch (ClassNotFoundException ex) {
-            return false;
-        }
-        return true;
-    }
-    
-    private ScriptEngine getNashornJSScriptEngine() {
-        NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
-        return factory.getScriptEngine(new ClassFilterPacHelpers());
-    }
-    
-    private ScriptEngine getGenericJSScriptEngine() {
-        // The result of the statements below may be Rhino, but more likely
-        // - since Java 8 - it will be a Nashorn engine.
-        ScriptEngineManager factory = new ScriptEngineManager();
-        return factory.getEngineByName("JavaScript");
-    }
-    
     /**
      * Test if the main entry point, function FindProxyForURL()/FindProxyForURLEx(), 
      * is available.
      */
-    private PacJsEntryFunction testScriptEngine(ScriptEngine eng, boolean doDeepTest) throws PacParsingException {
+    private PacJsEntryFunction testScriptEngine(Scriptable eng, boolean doDeepTest) throws PacParsingException {
         if (isJsFunctionAvailable(eng, PacJsEntryFunction.IPV6_AWARE.getJsFunctionName(), doDeepTest)) {
             return PacJsEntryFunction.IPV6_AWARE;
         }
@@ -351,30 +322,9 @@ public class NbPacScriptEvaluator implements PacScriptEvaluator {
         throw new PacParsingException("Function " + PacJsEntryFunction.STANDARD.getJsFunctionName() + " or " + PacJsEntryFunction.IPV6_AWARE.getJsFunctionName() + " not found in PAC Script.");
     }
 
-    private boolean isJsFunctionAvailable(ScriptEngine eng, String functionName, boolean doDeepTest) {
-        // We want to test if the function is there, but without actually 
-        // invoking it.        
-        Object obj = eng.get(functionName);
-        
-        if (!doDeepTest && obj != null) {  
-            // Shallow test. We've established that there's
-            // "something" in the ENGINE_SCOPE with a name like
-            // functionName, and we *hope* it is a function, but we really don't
-            // know, therefore we call it a shallow test.
-            return true;
-        }
-        
-        // For Nashorn post JDK8u40 we can do even deeper validation
-        // using the ScriptObjectMirror class. This will not work for Rhino.
-        if (doDeepTest && obj != null) {
-            if (obj instanceof ScriptObjectMirror) {
-                    ScriptObjectMirror  som = (ScriptObjectMirror) obj;
-                    if (som.isFunction()) {
-                        return true;
-                    }
-            }
-        }        
-        return false;
+    private boolean isJsFunctionAvailable(Scriptable eng, String functionName, boolean doDeepTest) {
+        Object o = ScriptableObject.getProperty(eng, functionName);
+        return o instanceof Function;
     }
     
 
@@ -399,26 +349,6 @@ public class NbPacScriptEvaluator implements PacScriptEvaluator {
         return matcher.matches();
     }
 
-    private String getEngineInfo(ScriptEngine engine) {
-        StringBuilder sb = new StringBuilder();
-        ScriptEngineFactory f = engine.getFactory();
-        sb.append("LanguageName=");
-        sb.append("\"").append(f.getLanguageName()).append("\"");
-        sb.append(" ");
-        sb.append("LanguageVersion=");
-        sb.append("\"").append(f.getLanguageVersion()).append("\"");
-        sb.append(" ");
-        sb.append("EngineName=");
-        sb.append("\"").append(f.getEngineName()).append("\"");
-        sb.append(" ");
-        sb.append("EngineNameAliases=");
-        sb.append(Arrays.toString(f.getNames().toArray(new String[f.getNames().size()])));
-        sb.append(" ");
-        sb.append("EngineVersion=");
-        sb.append("\"").append(f.getEngineVersion()).append("\"");
-        return sb.toString();
-    }
-
     /**
      * Translates result from JavaScript into list of java proxy types.
      * 
@@ -498,34 +428,61 @@ public class NbPacScriptEvaluator implements PacScriptEvaluator {
         
         return new Proxy(proxyType, new InetSocketAddress(host, portNo));
     }
-    
-    
-    private static class PacScriptEngine  {
-        private final ScriptEngine scriptEngine;
-        private final PacJsEntryFunction jsMainFunction;
-        private final Invocable invocable;
-
-        public PacScriptEngine(ScriptEngine scriptEngine, PacJsEntryFunction jsMainFunction) {
-            this.scriptEngine = scriptEngine;
-            this.jsMainFunction = jsMainFunction;
-            this.invocable = (Invocable) scriptEngine;
-        }
 
-        public PacJsEntryFunction getJsMainFunction() {
-            return jsMainFunction;
-        }
+    /**
+     * SandboxedContextFactory provides an Rhino execution context, that can
+     * limit executed instructions, execution time and exposed java classes
+     */
+    private static final class SandboxedContextFactory extends ContextFactory {
+        private final long maxExecutionTimeMS;
+        private final long maxInstructionCount;
+        private final ClassShutter classShutter;
 
-        public ScriptEngine getScriptEngine() {
-            return scriptEngine;
+        public SandboxedContextFactory(long maxInstructionCount, long maxExecutionTimeMS, ClassShutter classShutter) {
+            this.classShutter = classShutter;
+            this.maxInstructionCount = maxInstructionCount;
+            this.maxExecutionTimeMS = maxExecutionTimeMS;
         }
 
-        public Invocable getInvocable() {
-            return invocable;
-        }
-        
-        public Object findProxyForURL(String url, String host) throws ScriptException, NoSuchMethodException {
-            return invocable.invokeFunction(jsMainFunction.getJsFunctionName(), url, host);
-        }
+	@Override
+	protected Context makeContext() {
+	    return new SandboxedContext(this, classShutter, maxInstructionCount, maxExecutionTimeMS);
+	}
+
+    }
+
+    private static final class SandboxedContext extends Context {
+        private final long maxInstructionCount;
+        private final long maxExecutionTimeMS;
+	private final long executionStart = System.currentTimeMillis();
+	private long instructionCounter = 0;
+
+	public SandboxedContext(SandboxedContextFactory factory, ClassShutter classShutter, long maxInstructionCount, long maxExecutionTimeMS) {
+	    super(factory);
+            this.maxExecutionTimeMS = maxExecutionTimeMS;
+            this.maxInstructionCount = maxInstructionCount;
+	    setClassShutter(classShutter);
+	    setGenerateObserverCount(true);
+	    setInstructionObserverThreshold(1);
+	}
+
+	@Override
+	protected void observeInstructionCount(int instructionCount) {
+	    instructionCounter += instructionCount;
+	    long executionTime = System.currentTimeMillis() - executionStart;
+	    if(instructionCounter > maxInstructionCount || executionTime > maxExecutionTimeMS) {
+		throw new ExecutionLimitsExceeded(executionTime, maxExecutionTimeMS, instructionCounter, maxInstructionCount);
+	    }
+	}
+    }
+
+    private static class  ExecutionLimitsExceeded extends EvaluatorException {
+
+	public ExecutionLimitsExceeded(long executionTime, long maxExecutionTime, long intructionCount, long maxInstructionCount) {
+	    super(String.format("Exceeded execution limits (Execution Time (current/max): %dms / %dms, Instruction Count (current/max): %d / %d)",
+		    executionTime, maxExecutionTime,
+		    intructionCount, maxInstructionCount));
+	}
+
     }
-        
 }
diff --git a/platform/core.network/test/unit/data/pacFiles/wpad space.dat b/platform/core.network/test/unit/data/pacFiles/wpad space.dat
deleted file mode 100644
index 3310e6a..0000000
--- a/platform/core.network/test/unit/data/pacFiles/wpad space.dat	
+++ /dev/null
@@ -1,22 +0,0 @@
-/* 
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-function FindProxyForURL(url, host)
-{
-    // Make everything lower case.
-    url = url.toLowerCase();
-    host = host.toLowerCase();
-    if (isPlainHostName(host)) return "DIRECT";
-    return "PROXY www-proxy.us.oracle.com:80";
-};
diff --git a/platform/core.network/test/unit/src/org/netbeans/core/network/proxy/pac/PacEngineTest.java b/platform/core.network/test/unit/src/org/netbeans/core/network/proxy/pac/PacEngineTest.java
index 7d109a7..cba6cc7 100644
--- a/platform/core.network/test/unit/src/org/netbeans/core/network/proxy/pac/PacEngineTest.java
+++ b/platform/core.network/test/unit/src/org/netbeans/core/network/proxy/pac/PacEngineTest.java
@@ -15,6 +15,7 @@ package org.netbeans.core.network.proxy.pac;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.InetSocketAddress;
 import java.net.Proxy;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -75,6 +76,28 @@ public class PacEngineTest extends NbTestCase {
         testPacFile2("pac-test4.js", factory);
     }
 
+    @Test
+    public void testEngine2() throws IOException, PacParsingException, URISyntaxException, PacValidationException {
+
+        File pacFilesDir = new File(getDataDir(), "pacFiles");
+        byte[] b = Files.readAllBytes((new File(pacFilesDir, "wpad.dat")).toPath());
+        String pacSource = new String(b, StandardCharsets.UTF_8);
+
+        PacScriptEvaluatorFactory factory = new NbPacScriptEvaluatorFactory();
+        PacScriptEvaluator evaluator = factory.createPacScriptEvaluator(pacSource);
+
+        List<Proxy> proxiesFQDN = evaluator.findProxyForURL(new URI("https://www.heise.de"));
+        assertNotNull(proxiesFQDN);
+        assertEquals(1, proxiesFQDN.size());
+        assertEquals(Proxy.Type.HTTP, proxiesFQDN.get(0).type());
+        assertEquals("www-proxy.us.oracle.com", ((InetSocketAddress) proxiesFQDN.get(0).address()).getHostString());
+        assertEquals(80, ((InetSocketAddress) proxiesFQDN.get(0).address()).getPort());
+        List<Proxy> simpleName = evaluator.findProxyForURL(new URI("https://localserver"));
+        assertNotNull(simpleName);
+        assertEquals(1, simpleName.size());
+        assertEquals(Proxy.Type.DIRECT, simpleName.get(0).type());
+    }
+
     private String getPacSource(String pacFileName) throws IOException {
         File pacFilesDir = new File(getDataDir(), "pacFiles2");
         byte[] b = Files.readAllBytes((new File(pacFilesDir, pacFileName)).toPath());


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists