Unable to upload some files to mediawiki - mediawiki

I've got an internal wiki (airgapped) where we hope to upload a variety of configuration files and other non-standard files. Rather than needing to explicitly allow the extension, I want to allow any extension as long as its not in the blacklist. Additionally, I want to disable MIME checking because it thinks certain files are something they are not and doesn't know what to do with them.
I have tried placing these settings in my LocalSettings.php file:
$wgVerifyMimeType = false;
$wgCheckFileExtensions = false;
$wgStrictFileExtensions = false;
However, these appear to do absolutely nothing. I am still prohibited from uploading a file with an extension not explicitly allowed, and I also continue to get the error "This file is a corrupt or otherwise unreadable ZIP file. It cannot be properly checked for security." (Its a Chrome CRX extension file).
What am I missing here? The mediawiki manual and the other articles I have read tell me to do what I've tried, but its not working. I am running mediawiki 1.37.1.

Make sure that $wgProhibitedFileExtensions = [] and $wgVerifyMimeTypeIE = false.
To enable .crx, set $wgAllowJavaUploads = true.
In some other cases, you may also need $wgDisableUploadScriptChecks.
Warning to readers: all of the above is dangerous.

Related

How to avoid download file rename?

I have a file named <h1>test.zip on my webspace. When i try to download it, it get renamed as
__h1_test.zip
Is there a way to leave the original filename to the downloaded file?
I'd like the downloaded file to keep the name <h1>test.zip once downloaded.
I'm using ubuntu at the moment and i can rename files as <h1>test.zip on my device.
"<" this tag is coverted into "_"
so i suggest you , don't use "< >" tag , add another name.
No. The browser does that to prevent the user from accidentally overwriting an existing file with the same name and you have no control over this.
You have a few options to change it. None of them are perfect.
Go to chrome settings in your browser bar chrome://settings/, scroll down to advanced, click it, scroll down to downloads and check the box to prompt. You can then specify the same name so it isn't auto-renamed but it will prompt every time, even if there isn't a duplicate. You get used to it fast, so it isn't as big of a deal as it sounds like.
If that isn't what you want check out a Chrome extension that attempts to address this issue (not sure if it works with ubuntu though). There are numerous forums out there where people are asking for the same functionality and have been for years so don't expect Chrome to change default behavior... Here's one (untested by me) -> https://chrome.google.com/webstore/detail/downloads-overwrite-alrea/lddjgfpjnifpeondafidennlcfagekbp?hl=en-US
Finally, depending on what you are doing (always downloading the same set of files for example) you could configure an FTP client or something else to pull the files and set the name instead of using a browser to pull them... you would be able to configure that more easily to overwrite. If you are downloading random things and just want to save bandwidth/etc when accidentally downloading the same file, then you likely need an extension/different browser/etc. to resolve it.

Embedding images on mediawiki

I have tried to embed an image on mediawiki that I have installed on my server. The images are in this folder /var/www/html/mywiki/images$.
Here is the screenshot of what I see when I save the page to view the image
When I try the upload option, this is the error message i get
[b5f5e4d3] 2016-10-25 12:30:15: Fatal exception of type "MWException"
Where could i be making the mistake?
From my experience with mediawiki, when you upload to the site it stores them in randomzed lettered/numbered folders... ie w/images/9/9d and you have no control over uploading them directly to the folder through your server. I haven't tried directly uploading them, I've always used the wiki itself to upload.
MediaWiki offers some extensions for bulk uploading here:
https://www.mediawiki.org/wiki/Category:Bulk_upload
And you can find them under Special categories once you've installed the Extension and updated your LocalSettings.php to allow them to run.
I personally use BatchUpload (https://www.mediawiki.org/wiki/Extension:SimpleBatchUpload) because I don't have a lot of files to upload at one time, and although it is marked as stable, it sometimes sticks... still better than uploading one at a time.
If you find an alternative way for mass uploading using FTP directly to the server, I would love to know... as I searched for that myself.
Good luck!
You should not upload images manually, but use Special:Upload page to upload image into Mediawiki. Error you've mentioned indicates that there is something wrong with your installation, so you should put $wgShowExceptionDetails = true; into LocalSettings.php to see more details about this error. There is a chance that your /images/ directory is not writable - check its permissions.

Why is my iFrame HTML file not being shown inline? Instead, the HTML file is being downloaded

Up until a few weeks ago, any HTML files I linked to an iFrame would be shown within the frame. All of a sudden, Chrome and Firefox will now ask me whether I want to download the HTML file in the iFrame. It's an Apache server and I do believe it was upgraded recently. How it was upgraded, I am not sure. I was wondering if it had anything to do with the way certain MIME types get processed within an iFrame.
Note: Chrome and Firefox are the only browsers that I've tested this with. I don't think this is a browser issue though.
It's very likely the mime-type configuration is no longer properly set up on your Apache server. Most of the time, the server configuration sets the mime type of the returned object based on the file extension you're requesting. If your file extensions have changed, or if you're using dynamic URLs that don't end in ".docx"), e.g. that get processed by an intervening app server to return the file without themselves setting the MIME type, then the browser has no way of knowing what the contents are, and correctly concludes that the best thing to do is to just gives you the contents in a file.
So... set the extension of the file you're downloading to .docx or .doc. If you're using a default Apache config, that might do it. If that doesn't work, change the mime type of the returned object based on a URL filter configuration in your apache.conf or other apache config file. Or if using dynamic URLs, explicitly set the mime type in your code to one of the following:
.doc - application/msword
.dot - application/msword
.docx - application/vnd.openxmlformats-officedocument.wordprocessingml.document
.dotx - application/vnd.openxmlformats-officedocument.wordprocessingml.template
.docm - application/vnd.ms-word.document.macroEnabled.12
.dotm - application/vnd.ms-word.template.macroEnabled.12

threepenny-gui - opening files

Dear Haskell community I have written my first gui application and decided to use
threepenny-gui to do so.
The task is the following search the files in a given folder for matches and provide links to open those files. In addition I made nice parse and render function as the files (mostly) have a special formatting.
But now I have stumbled upon a problem - most browsers prohibit links to local files by href="file://localhost/home/user/folder/file.pdf" being opened, for security reasons, which I do understand and find completely sensible.
I tried to use href="./file.pdf" when the program and the file are in the same folder, which also doesn't seem to work.
The code of the whole application is available at github/epsilonhalbe, I run it in a folder and access it via a browser at localhost:100000
The HTTP server provided by threepenny-gui will serve up static content from the directory you specify in tpStatic. Put your files in that directory, and make your links' paths be relative to it, and you'll be good to go!
As of threepenny-gui-0.4.*, there are also two functions loadFile and loadDirectory that can be used to serve a local file or directory at an automatically generated URL. This can be useful if the tpStatic field is not enough.

HTML5 offline "Application Cache Error event: Manifest fetch failed (-1)"

I'm trying to write an HTML5 offline application but can't seem to get Chrome to accept the cache manifest file.
Chrome logs the following output to its console while loading the application:
Creating Application Cache with manifest http://localhost/cache.manifest
Application Cache Checking event
Application Cache Error event: Manifest fetch failed (-1) http://localhost/cache.manifest
However, if I remove all lines from the manifest file except for the first line (i.e. "CACHE MANIFEST") Chrome accepts the manifest:
Creating Application Cache with manifest http://localhost/cache.manifest
Application Cache Checking event
Application Cache Downloading event
Application Cache Progress event (0 of 0)
Application Cache Cached event
But, as soon as I add a new line to the manifest (even if that next line is empty) Chrome reverts to complaining that the fetch failed.
All files are being served locally from a Windows 7 PC via Python using SimpleHTTPServer on port 80. I've updated the types_map in %PYTHON%/Lib/mimetypes.py with the following line:
'.manifest': 'text/cache-manifest',
The manifest should contain the following:
CACHE MANIFEST
scripts/africa.js
scripts/main.js
scripts/offline.js
scripts/libs/raphael-min.js
favicon.ico
apple-touch-icon.png
To cache a website offline (HTML5) you need to specify all the files needed for it to run. In short specify the site main components needed.
Easy way to create a manifest is in Note Pad.
Note: CACHE MANIFEST needs to be first line and your files will follow after a line space as follows:
CACHE MANIFEST
Scripts/script.js
Content/Site.css
Scripts/jquery-ui-1.8.20.min.js
Scripts/modernizr-2.5.3.js
SESOL.png
Scripts/jquery.formatCurrency-1.4.0.min.js
http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css
http://code.jquery.com/jquery-1.8.2.min.js
http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js
Content/themes/images/icons-18-white.png
Controllers/AccountController
Controllers/HomeController
Models/AccountModels
Account/Login
Home/CheckOut
Note2: remove all spaces after each line.
Note:3 you need to follow the exact format FOLDER/File or FOLDER/FOLDER/FILE ect....
Just because you have a manifest file doesnt mean it will load. you need to add the following to the Tag:
<html manifest="~/cache.manifest" type="text/cache-manifest">
Don't forget that after you add this it's cached the first time the page loads. So you need to register a cache event in the 'mobileinit' event.
$(document).on("mobileinit", function () {
//register event to cache site for offline use
cache = window.applicationCache;
cache.addEventListener('updateready', cacheUpdatereadyListener, false);
cache.addEventListener('error', cacheErrorListener, false);
function cacheUpdatereadyListener (){
window.applicationCache.update();
window.applicationCache.swapCache();
}
function cacheErrorListener() {
alert('site not availble offline')
}
}
Download Safari and use the web inspector to find errors.
http://developer.apple.com/library/safari/#documentation/appleapplications/Conceptual/Safari_Developer_Guide/1Introduction/Introduction.html#//apple_ref/doc/uid/TP40007874-CH1-SW1
Tip: Chrome's developer tools "F12" will show you the errors in the manifest load. ie the files you still need to add.
Hope this helps, covers the entire process. I assuming if you are at this stage in development you new to add these to the mobile init:
$.mobile.allowCrossDomainPages = true; // cross domain page loading
$.mobile.phonegapNavigationEnabled = true; //Android enabled mobile
$.mobile.page.prototype.options.domCache = true; //page caching prefech rendering
$.support.touchOverflow = true; //Android enhanced scrolling
$.mobile.touchOverflowEnabled = true; // enhanced scrolling transition availible in iOS 5
Safari Developer Guide:
https://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/Client-SideStorage/Client-SideStorage.html#//apple_ref/doc/uid/TP40002051-CH4-SW4
Have you tried anything like https://manifest-validator.appspot.com/ to validate your manifest?
I've struggled with my manifest file for quite a while, it is really hard to pinpoint what is wrong. Could be something as simple as wrong encoding to an extra line break at the start.
Today I experienced exactly the same problem. After hours of working I came the the key point: the format of manifest file. In short, the file must begin a new line ONLY with ascii(0A), not ascii(0D), or ascii(0D + 0A). Only in this way can I live with Chrome, or I will get a blank page, and the error info in the console window.
According to w3c, (http://www.w3.org/TR/html5/offline.html), in “5.6.3.2 Writing cache manifests”,both 0A, 0D and 0D + 0A are all acceptable. So, my opinion is: Chrome is not compatible with w3c in the point.
Further more, say, if myapp.js is to be cached, it MUST follow the same rule: begins a new line only with ascii(0A), or Chrome will throw the same info in the console windows.
My Chrome is 13.0.782.107
I have now resolved this issue by switching to CherryPy for serving these files :)
If anyone else becomes similarly stuck but wants to keep the server part simple, the following Python may be sufficient for getting started:
import cherrypy
class SimpleStaticServer:
#cherrypy.expose
def index(self):
return '<html><body>Go to the static index page</body></html>'
cherrypy.config.update({
# global
'server.socket_host': '192.168.0.3',
'server.socket_port': 80,
# /static
'tools.staticdir.on': True,
'tools.staticdir.dir': "(directory where static files are stored)",
})
cherrypy.quickstart(SimpleStaticServer())
If you want to visit the "site" from another device, you'll need to use the external IP address (for me this was 192.168.0.3). Otherwise, you can just use '127.0.0.1' for the 'server.socket_host' value. I then point my browser to http://192.168.0.3/index.html to get my static index page.
I have resolved this issue in visual studio for MVC application.
follow below steps:
I have created .appcache file in notepad and copy manifest file content into it.
(you don't need to create .Manifest file OR not create Manifest.cshtml view. just create .appcache file in notepad.)
give reference as
<html manifest="~/example.appcache"> in view
and issue will be resolved
I think the line
CACHE:
is missing in the manifest file (should be the 2nd line, before the list of files.