Merge "Don't fallback from uk to ru"
[lhc/web/wiklou.git] / includes / upload / UploadBase.php
index 1be5c24..ea6ef30 100644 (file)
@@ -446,7 +446,8 @@ abstract class UploadBase {
                        return $status;
                }
 
-               $this->mFileProps = FSFile::getPropsFromPath( $this->mTempPath, $this->mFinalExtension );
+               $mwProps = new MWFileProps( MimeMagic::singleton() );
+               $this->mFileProps = $mwProps->getPropsFromPath( $this->mTempPath, $this->mFinalExtension );
                $mime = $this->mFileProps['mime'];
 
                if ( $wgVerifyMimeType ) {
@@ -504,7 +505,8 @@ abstract class UploadBase {
                # getTitle() sets some internal parameters like $this->mFinalExtension
                $this->getTitle();
 
-               $this->mFileProps = FSFile::getPropsFromPath( $this->mTempPath, $this->mFinalExtension );
+               $mwProps = new MWFileProps( MimeMagic::singleton() );
+               $this->mFileProps = $mwProps->getPropsFromPath( $this->mTempPath, $this->mFinalExtension );
 
                # check MIME type, if desired
                $mime = $this->mFileProps['file-mime'];
@@ -1438,7 +1440,11 @@ abstract class UploadBase {
                        'http://www.w3.org/tr/rec-rdf-syntax/',
                ];
 
-               if ( !in_array( $namespace, $validNamespaces ) ) {
+               // Inkscape mangles namespace definitions created by Adobe Illustrator.
+               // This is nasty but harmless. (T144827)
+               $isBuggyInkscape = preg_match( '/^&(#38;)*ns_[a-z_]+;$/', $namespace );
+
+               if ( !( $isBuggyInkscape || in_array( $namespace, $validNamespaces ) ) ) {
                        wfDebug( __METHOD__ . ": Non-svg namespace '$namespace' in uploaded file.\n" );
                        /** @todo Return a status object to a closure in XmlTypeCheck, for MW1.21+ */
                        $this->mSVGNSError = $namespace;
@@ -1501,6 +1507,7 @@ abstract class UploadBase {
                        # fragment links are allowed. For all other tags, only data:
                        # and fragment are allowed.
                        if ( $stripped == 'href'
+                               && $value !== ''
                                && strpos( $value, 'data:' ) !== 0
                                && strpos( $value, '#' ) !== 0
                        ) {