r49670 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49669‎ | r49670 | r49671 >
Date:18:01, 20 April 2009
Author:thomasv
Status:reverted (Comments)
Tags:
Comment:
fetch djvu text
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)
  • /trunk/extensions/ProofreadPage/proofread.js (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -18,6 +18,8 @@
1919 $wgDjvutxt = null;
2020
2121
 22+
 23+
2224 $wgExtensionCredits['other'][] = array(
2325 'name' => 'ProofreadPage',
2426 'author' => 'ThomasV',
@@ -28,6 +30,8 @@
2931
3032
3133 $wgExtensionFunctions[] = "pr_main";
 34+$wgAjaxExportList[] = "pr_fetch_djvutxt";
 35+
3236 function pr_main() {
3337 global $wgParser;
3438 $wgParser->setHook( "pagelist", "pr_renderPageList" );
@@ -35,8 +39,30 @@
3640 }
3741
3842
 43+/*
 44+ * Fetch Djvu text with curl
 45+ */
 46+function pr_fetch_djvutxt( $url ) {
3947
 48+ if($url[0]=='/') $url = "http://localhost" . $url;
4049
 50+ $ch = curl_init( $url );
 51+ curl_setopt( $ch, CURLOPT_HEADER, false );
 52+ curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
 53+ $text = curl_exec( $ch );
 54+
 55+ $errno = curl_errno( $ch );
 56+ $httpCode = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
 57+ //$contentType = curl_getinfo( $ch, CURLINFO_CONTENT_TYPE );
 58+
 59+ curl_close($ch);
 60+ if($errno==0 && ( $httpCode==200 || $httpCode==404 ) ) {
 61+ return $text;
 62+ }
 63+ return "";
 64+}
 65+
 66+
4167 # Bump the version number every time you change proofread.js
4268 $wgProofreadPageVersion = 18;
4369
Index: trunk/extensions/ProofreadPage/proofread.js
@@ -47,6 +47,7 @@
4848
4949
5050
 51+
5152 function pr_image_url(requested_width){
5253 var image_url;
5354
@@ -316,7 +317,7 @@
317318 table.style.cssText = "width:100%;";
318319
319320 //fill table
320 - if(self.proofreadpage_default_layout=='horizontal')
 321+ if(self.proofreadpage_default_layout=='horizontal')
321322 pr_fill_table(true);
322323 else
323324 pr_fill_table(false);
@@ -493,18 +494,41 @@
494495 addOnloadHook(pr_init_tabs);
495496
496497
497 -function pr_initzoom(){
498 - if(document.getElementById("wpTextbox1")){
 498+/*fetch djvu content with ajax*/
 499+function pr_fetch_djvutxt(){
 500+ var text_url = proofreadPageThumbURL.replace('##WIDTH##px',"djvutxt").replace(".jpg",".txt");
 501+ sajax_do_call( 'pr_fetch_djvutxt', [ text_url ], pr_init_textbox );
 502+}
 503+
 504+
 505+function pr_init_textbox(xmlhttp) {
 506+ if (xmlhttp == null) return;
 507+ if (xmlhttp.readyState == 4) {
 508+ document.getElementById("wpTextbox1").value = xmlhttp.responseText;
 509+ }
 510+}
 511+
 512+
 513+function pr_onload(){
 514+
 515+ if(self.proofreadPageIsEdit){
 516+ if(!document.getElementById("wpTextbox1") ) return;
499517 if(self.pr_horiz)
500518 document.getElementById("wpTextbox1").style.cssText = "height:"+self.vertHeight+"px";
501519 else
502520 document.getElementById("wpTextbox1").style.cssText = "height:"+(self.TextBoxHeight-7)+"px";
503521 pr_zoom(0);
 522+
 523+ //to enable, set proofreadpage_djvutxt=1
 524+ if(self.proofreadpage_djvutxt) {
 525+ if( document.getElementById("wpTextbox1").value == "" ) pr_fetch_djvutxt();
 526+ }
504527 }
505528 }
506 -hookEvent("load", pr_initzoom );
 529+hookEvent("load", pr_onload );
507530
508531
 532+
509533 /*Quality buttons*/
510534
511535 function pr_add_quality(form,value){

Follow-up revisions

RevisionCommit summaryAuthorDate
r49673* Follow up r49670: Bump style number due to changed .js file...raymond19:14, 20 April 2009
r50026Revert r49669, r49670 "extract text layer from djvu file (see bug 18046)"...brion22:54, 28 April 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   22:39, 28 April 2009

Manual use of curl should be avoided; it may not be installed, and 'localhost' may not do anything useful.

Further this appears to be a general "fetch any foreign URL and pass the data through" which is a serious security hole.

#Comment by Brion VIBBER (talk | contribs)   22:54, 28 April 2009

Reverted for now in r50026

Status & tagging log