Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
Tor Browser
Commits
ed6ab267
Commit
ed6ab267
authored
Oct 25, 2018
by
Matthew Finkel
Committed by
Matthew Finkel
Feb 05, 2021
Browse files
Bug 28125 - Prevent non-Necko network connections
parent
5ddaf16e
Changes
2
Hide whitespace changes
Inline
Side-by-side
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java
View file @
ed6ab267
...
...
@@ -488,54 +488,7 @@ public class GeckoMediaDrmBridgeV21 implements GeckoMediaDrm {
@Override
protected
Void
doInBackground
(
final
Void
...
params
)
{
HttpURLConnection
urlConnection
=
null
;
BufferedReader
in
=
null
;
try
{
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
();
int
responseCode
=
urlConnection
.
getResponseCode
();
if
(
responseCode
==
HttpURLConnection
.
HTTP_OK
)
{
in
=
new
BufferedReader
(
new
InputStreamReader
(
urlConnection
.
getInputStream
(),
StringUtils
.
UTF_8
));
String
inputLine
;
StringBuffer
response
=
new
StringBuffer
();
while
((
inputLine
=
in
.
readLine
())
!=
null
)
{
response
.
append
(
inputLine
);
}
in
.
close
();
mResponseBody
=
String
.
valueOf
(
response
).
getBytes
(
StringUtils
.
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
(
IOException
e
)
{
Log
.
e
(
LOGTAG
,
"Got exception during posting provisioning request ..."
,
e
);
}
catch
(
URISyntaxException
e
)
{
Log
.
e
(
LOGTAG
,
"Got exception during creating uri ..."
,
e
);
}
finally
{
if
(
urlConnection
!=
null
)
{
urlConnection
.
disconnect
();
}
try
{
if
(
in
!=
null
)
{
in
.
close
();
}
}
catch
(
IOException
e
)
{
Log
.
e
(
LOGTAG
,
"Exception during closing in ..."
,
e
);
}
}
Log
.
i
(
LOGTAG
,
"This is Tor Browser. Skipping."
);
return
null
;
}
...
...
mobile/android/geckoview/src/thirdparty/java/org/mozilla/thirdparty/com/google/android/exoplayer2/upstream/DefaultHttpDataSource.java
View file @
ed6ab267
...
...
@@ -395,51 +395,8 @@ public class DefaultHttpDataSource implements HttpDataSource {
*/
private
HttpURLConnection
makeConnection
(
URL
url
,
byte
[]
postBody
,
long
position
,
long
length
,
boolean
allowGzip
,
boolean
followRedirects
)
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
)
ProxySelector
.
openConnectionWithProxy
(
url
.
toURI
());
connection
.
setConnectTimeout
(
connectTimeoutMillis
);
connection
.
setReadTimeout
(
readTimeoutMillis
);
if
(
defaultRequestProperties
!=
null
)
{
for
(
Map
.
Entry
<
String
,
String
>
property
:
defaultRequestProperties
.
getSnapshot
().
entrySet
())
{
connection
.
setRequestProperty
(
property
.
getKey
(),
property
.
getValue
());
}
}
for
(
Map
.
Entry
<
String
,
String
>
property
:
requestProperties
.
getSnapshot
().
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
);
if
(!
allowGzip
)
{
connection
.
setRequestProperty
(
"Accept-Encoding"
,
"identity"
);
}
connection
.
setInstanceFollowRedirects
(
followRedirects
);
connection
.
setDoOutput
(
postBody
!=
null
);
if
(
postBody
!=
null
)
{
connection
.
setRequestMethod
(
"POST"
);
if
(
postBody
.
length
==
0
)
{
connection
.
connect
();
}
else
{
connection
.
setFixedLengthStreamingMode
(
postBody
.
length
);
connection
.
connect
();
OutputStream
os
=
connection
.
getOutputStream
();
os
.
write
(
postBody
);
os
.
close
();
}
}
else
{
connection
.
connect
();
}
return
connection
;
Log
.
i
(
TAG
,
"This is Tor Browser. Skipping."
);
throw
new
IOException
();
}
/**
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment