Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Mullvad Browser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Applications
Mullvad Browser
Commits
8dd327f6
Commit
8dd327f6
authored
16 years ago
by
mconnor@steelgryphon.com
Browse files
Options
Downloads
Patches
Plain Diff
backing out bug 393246 for final to resolve bug 432836, a=schrep
parent
a863361e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docshell/base/nsDefaultURIFixup.cpp
+54
-2
54 additions, 2 deletions
docshell/base/nsDefaultURIFixup.cpp
docshell/base/nsDefaultURIFixup.h
+3
-0
3 additions, 0 deletions
docshell/base/nsDefaultURIFixup.h
with
57 additions
and
2 deletions
docshell/base/nsDefaultURIFixup.cpp
+
54
−
2
View file @
8dd327f6
...
...
@@ -46,6 +46,7 @@
#include
"nsIPrefService.h"
#include
"nsIPrefLocalizedString.h"
#include
"nsIPlatformCharset.h"
#include
"nsILocalFile.h"
#include
"nsIURIFixup.h"
...
...
@@ -231,6 +232,17 @@ nsDefaultURIFixup::CreateFixupURI(const nsACString& aStringURI, PRUint32 aFixupF
#endif
}
// For these protocols, use system charset instead of the default UTF-8,
// if the URI is non ASCII.
PRBool
bAsciiURI
=
IsASCII
(
uriString
);
PRBool
bUseNonDefaultCharsetForURI
=
!
bAsciiURI
&&
(
scheme
.
IsEmpty
()
||
scheme
.
LowerCaseEqualsLiteral
(
"http"
)
||
scheme
.
LowerCaseEqualsLiteral
(
"https"
)
||
scheme
.
LowerCaseEqualsLiteral
(
"ftp"
)
||
scheme
.
LowerCaseEqualsLiteral
(
"file"
));
// Now we need to check whether "scheme" is something we don't
// really know about.
nsCOMPtr
<
nsIProtocolHandler
>
ourHandler
,
extHandler
;
...
...
@@ -240,7 +252,8 @@ nsDefaultURIFixup::CreateFixupURI(const nsACString& aStringURI, PRUint32 aFixupF
if
(
ourHandler
!=
extHandler
||
!
PossiblyHostPortUrl
(
uriString
))
{
// Just try to create an URL out of it
rv
=
NS_NewURI
(
aURI
,
uriString
,
nsnull
);
rv
=
NS_NewURI
(
aURI
,
uriString
,
bUseNonDefaultCharsetForURI
?
GetCharsetForUrlBar
()
:
nsnull
);
if
(
!*
aURI
&&
rv
!=
NS_ERROR_MALFORMED_URI
)
{
return
rv
;
...
...
@@ -310,9 +323,13 @@ nsDefaultURIFixup::CreateFixupURI(const nsACString& aStringURI, PRUint32 aFixupF
uriString
.
Assign
(
NS_LITERAL_CSTRING
(
"ftp://"
)
+
uriString
);
else
uriString
.
Assign
(
NS_LITERAL_CSTRING
(
"http://"
)
+
uriString
);
// For ftp & http, we want to use system charset.
if
(
!
bAsciiURI
)
bUseNonDefaultCharsetForURI
=
PR_TRUE
;
}
// end if checkprotocol
rv
=
NS_NewURI
(
aURI
,
uriString
,
nsnull
);
rv
=
NS_NewURI
(
aURI
,
uriString
,
bUseNonDefaultCharsetForURI
?
GetCharsetForUrlBar
()
:
nsnull
);
// Did the caller want us to try an alternative URI?
// If so, attempt to fixup http://foo into http://www.foo.com
...
...
@@ -739,6 +756,41 @@ PRBool nsDefaultURIFixup::PossiblyByteExpandedFileName(const nsAString& aIn)
return
PR_FALSE
;
}
const
char
*
nsDefaultURIFixup
::
GetFileSystemCharset
()
{
if
(
mFsCharset
.
IsEmpty
())
{
nsresult
rv
;
nsCAutoString
charset
;
nsCOMPtr
<
nsIPlatformCharset
>
plat
(
do_GetService
(
NS_PLATFORMCHARSET_CONTRACTID
,
&
rv
));
if
(
NS_SUCCEEDED
(
rv
))
rv
=
plat
->
GetCharset
(
kPlatformCharsetSel_FileName
,
charset
);
if
(
charset
.
IsEmpty
())
mFsCharset
.
AssignLiteral
(
"ISO-8859-1"
);
else
mFsCharset
.
Assign
(
charset
);
}
return
mFsCharset
.
get
();
}
const
char
*
nsDefaultURIFixup
::
GetCharsetForUrlBar
()
{
const
char
*
charset
=
GetFileSystemCharset
();
#ifdef XP_MAC
// check for "x-mac-" prefix
if
((
strlen
(
charset
)
>=
6
)
&&
charset
[
0
]
==
'x'
&&
charset
[
2
]
==
'm'
)
{
if
(
!
strcmp
(
"x-mac-roman"
,
charset
))
return
"ISO-8859-1"
;
// we can do more x-mac-xxxx mapping here
// or somewhere in intl code like nsIPlatformCharset.
}
#endif
return
charset
;
}
nsresult
nsDefaultURIFixup
::
KeywordURIFixup
(
const
nsACString
&
aURIString
,
nsIURI
**
aURI
)
{
...
...
This diff is collapsed.
Click to expand it.
docshell/base/nsDefaultURIFixup.h
+
3
−
0
View file @
8dd327f6
...
...
@@ -68,8 +68,11 @@ private:
PRBool
PossiblyHostPortUrl
(
const
nsACString
&
aUrl
);
PRBool
MakeAlternateURI
(
nsIURI
*
aURI
);
PRBool
IsLikelyFTP
(
const
nsCString
&
aHostSpec
);
const
char
*
GetFileSystemCharset
();
const
char
*
GetCharsetForUrlBar
();
nsCOMPtr
<
nsIPrefBranch
>
mPrefBranch
;
nsCAutoString
mFsCharset
;
};
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment