[tor-commits] [tor-browser] 05/66: Bug 28125: Prevent non-Necko network connections

gitolite role git at cupani.torproject.org
Wed Aug 31 17:42:04 UTC 2022


This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch tor-browser-102.2.0esr-12.0-2
in repository tor-browser.

commit 28b8c1975579077e54d39f2c7837b03c1b8675b1
Author: Matthew Finkel <Matthew.Finkel at gmail.com>
AuthorDate: Thu Oct 25 19:17:09 2018 +0000

    Bug 28125: Prevent non-Necko network connections
---
 .../exoplayer2/upstream/DefaultHttpDataSource.java | 46 +-------------------
 .../gecko/media/GeckoMediaDrmBridgeV21.java        | 50 +---------------------
 2 files changed, 3 insertions(+), 93 deletions(-)

diff --git a/mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java b/mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java
index c0e8e23bfe279..3df3c39e1db6c 100644
--- a/mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java
+++ b/mobile/android/exoplayer2/src/main/java/org/mozilla/thirdparty/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java
@@ -531,50 +531,8 @@ public class DefaultHttpDataSource extends BaseDataSource implements HttpDataSou
       boolean followRedirects,
       Map<String, String> requestParameters)
       throws IOException, URISyntaxException {
-    /**
-     * Tor Project modified the way the connection object was created. For the sake of
-     * simplicity, instead of duplicating the whole file we changed the connection object
-     * to use the ProxySelector.
-     */
-    HttpURLConnection connection = (HttpURLConnection) openConnectionWithProxy(url.toURI());
-
-    connection.setConnectTimeout(connectTimeoutMillis);
-    connection.setReadTimeout(readTimeoutMillis);
-
-    Map<String, String> requestHeaders = new HashMap<>();
-    if (defaultRequestProperties != null) {
-      requestHeaders.putAll(defaultRequestProperties.getSnapshot());
-    }
-    requestHeaders.putAll(requestProperties.getSnapshot());
-    requestHeaders.putAll(requestParameters);
-
-    for (Map.Entry<String, String> property : requestHeaders.entrySet()) {
-      connection.setRequestProperty(property.getKey(), property.getValue());
-    }
-
-    if (!(position == 0 && length == C.LENGTH_UNSET)) {
-      String rangeRequest = "bytes=" + position + "-";
-      if (length != C.LENGTH_UNSET) {
-        rangeRequest += (position + length - 1);
-      }
-      connection.setRequestProperty("Range", rangeRequest);
-    }
-    connection.setRequestProperty("User-Agent", userAgent);
-    connection.setRequestProperty("Accept-Encoding", allowGzip ? "gzip" : "identity");
-    connection.setInstanceFollowRedirects(followRedirects);
-    connection.setDoOutput(httpBody != null);
-    connection.setRequestMethod(DataSpec.getStringForHttpMethod(httpMethod));
-
-    if (httpBody != null) {
-      connection.setFixedLengthStreamingMode(httpBody.length);
-      connection.connect();
-      OutputStream os = connection.getOutputStream();
-      os.write(httpBody);
-      os.close();
-    } else {
-      connection.connect();
-    }
-    return connection;
+    Log.i(TAG, "This is Tor Browser. Skipping.");
+    throw new IOException();
   }
 
   /** Creates an {@link HttpURLConnection} that is connected with the {@code url}. */
diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java
index 26ae2ae594b96..7d5b87c157b19 100644
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java
@@ -493,55 +493,7 @@ public class GeckoMediaDrmBridgeV21 implements GeckoMediaDrm {
 
     @Override
     protected Void doInBackground(final Void... params) {
-      HttpURLConnection urlConnection = null;
-      BufferedReader in = null;
-      try {
-        final URI finalURI =
-            new URI(mURL + "&signedRequest=" + URLEncoder.encode(new String(mDrmRequest), "UTF-8"));
-        urlConnection = (HttpURLConnection) ProxySelector.openConnectionWithProxy(finalURI);
-        urlConnection.setRequestMethod("POST");
-        if (DEBUG) Log.d(LOGTAG, "Provisioning, posting url =" + finalURI.toString());
-
-        // Add data
-        urlConnection.setRequestProperty("Accept", "*/*");
-        urlConnection.setRequestProperty("User-Agent", getCDMUserAgent());
-        urlConnection.setRequestProperty("Content-Type", "application/json");
-
-        // Execute HTTP Post Request
-        urlConnection.connect();
-
-        final int responseCode = urlConnection.getResponseCode();
-        if (responseCode == HttpURLConnection.HTTP_OK) {
-          in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream(), UTF_8));
-          String inputLine;
-          final StringBuffer response = new StringBuffer();
-
-          while ((inputLine = in.readLine()) != null) {
-            response.append(inputLine);
-          }
-          in.close();
-          mResponseBody = String.valueOf(response).getBytes(UTF_8);
-          if (DEBUG) Log.d(LOGTAG, "Provisioning, response received.");
-          if (mResponseBody != null) Log.d(LOGTAG, "response length=" + mResponseBody.length);
-        } else {
-          Log.d(LOGTAG, "Provisioning, server returned HTTP error code :" + responseCode);
-        }
-      } catch (final IOException e) {
-        Log.e(LOGTAG, "Got exception during posting provisioning request ...", e);
-      } catch (final URISyntaxException e) {
-        Log.e(LOGTAG, "Got exception during creating uri ...", e);
-      } finally {
-        if (urlConnection != null) {
-          urlConnection.disconnect();
-        }
-        try {
-          if (in != null) {
-            in.close();
-          }
-        } catch (final IOException e) {
-          Log.e(LOGTAG, "Exception during closing in ...", e);
-        }
-      }
+      Log.i(LOGTAG, "This is Tor Browser. Skipping.");
       return null;
     }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the tor-commits mailing list