Page MenuHomePhabricator

SVG Translate does not accept HTTPS URLs
Closed, ResolvedPublic

Description

When I enter a HTTPS URL (eg. https://upload.wikimedia.org/wikipedia/commons/a/a8/Butterworth_filter_bode_plot.svg) SVG Translate fails. Entering a file in the form File:Some file.svg also does not work.

Event Timeline

Jdx raised the priority of this task from to Low.
Jdx updated the task description. (Show Details)
Jdx subscribed.

My gut tells me this is a duplicate of T138780 which has been resolved.

The filename would enter correctly, but when the PHP script searched the file, it would throw an Intuition error for getLangNames(). That error has been fixed.

I can go to SVGTranslate and type in "File:First Ionization Energy.svg", and the script accesses that file and builds the table for translating.

Full HTTPS URLs still don't work – "error-notsvg Hit your browser's back button to retry." is displayed. Wiki links work at first glance, but I doubt it works at all – when I translated Butterworth filter bode plot.svg and tried to send it using OAuth method, I got:

Notice: Undefined offset: 16 in /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php on line 592

Call Stack:

0.0048     674272   1. {main}() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:0
0.2818    3408768   2. SVGtranslate->do_step() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:57
0.2821    3408904   3. SVGtranslate->generate_fourth_form() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:790

Notice: Undefined index: timestamp in /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php on line 602

Call Stack:

0.0048     674272   1. {main}() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:0
0.2818    3408768   2. SVGtranslate->do_step() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:57
0.2821    3408904   3. SVGtranslate->generate_fourth_form() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:790

Notice: Undefined index: user in /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php on line 602

Call Stack:

0.0048     674272   1. {main}() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:0
0.2818    3408768   2. SVGtranslate->do_step() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:57
0.2821    3408904   3. SVGtranslate->generate_fourth_form() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:790

Notice: Undefined index: user in /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php on line 602

Call Stack:

0.0048     674272   1. {main}() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:0
0.2818    3408768   2. SVGtranslate->do_step() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:57
0.2821    3408904   3. SVGtranslate->generate_fourth_form() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:790

Notice: Undefined index: width in /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php on line 602

Call Stack:

0.0048     674272   1. {main}() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:0
0.2818    3408768   2. SVGtranslate->do_step() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:57
0.2821    3408904   3. SVGtranslate->generate_fourth_form() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:790

Notice: Undefined index: height in /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php on line 602

Call Stack:

0.0048     674272   1. {main}() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:0
0.2818    3408768   2. SVGtranslate->do_step() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:57
0.2821    3408904   3. SVGtranslate->generate_fourth_form() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:790

Notice: Undefined index: size in /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php on line 602

Call Stack:

0.0048     674272   1. {main}() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:0
0.2818    3408768   2. SVGtranslate->do_step() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:57
0.2821    3408904   3. SVGtranslate->generate_fourth_form() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:790

Notice: Undefined index: comment in /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php on line 602

Call Stack:

0.0048     674272   1. {main}() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:0
0.2818    3408768   2. SVGtranslate->do_step() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:57
0.2821    3408904   3. SVGtranslate->generate_fourth_form() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:790

Warning: preg_replace(): Unknown modifier 'd' in /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php on line 302

Call Stack:

0.0048     674272   1. {main}() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:0
0.2818    3408768   2. SVGtranslate->do_step() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:57
0.2821    3408904   3. SVGtranslate->generate_fourth_form() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:790
0.6082    5795176   4. SVGtranslate->generate_svg() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:608
0.6603    5870952   5. preg_replace() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:302

Warning: preg_replace(): Unknown modifier '\' in /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php on line 302

Call Stack:

0.0048     674272   1. {main}() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:0
0.2818    3408768   2. SVGtranslate->do_step() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:57
0.2821    3408904   3. SVGtranslate->generate_fourth_form() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:790
0.6082    5795176   4. SVGtranslate->generate_svg() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:608
0.6606    5804760   5. preg_replace() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:302

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:602) in /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php on line 321

Call Stack:

0.0048     674272   1. {main}() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:0
0.2818    3408768   2. SVGtranslate->do_step() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:57
0.2821    3408904   3. SVGtranslate->generate_fourth_form() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:790
0.7851    7294080   4. SVGtranslate->cache() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:644
0.7851    7294160   5. session_start() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:321

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:602) in /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php on line 321

Call Stack:

0.0048     674272   1. {main}() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:0
0.2818    3408768   2. SVGtranslate->do_step() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/index.php:57
0.2821    3408904   3. SVGtranslate->generate_fourth_form() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:790
0.7851    7294080   4. SVGtranslate->cache() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:644
0.7851    7294160   5. session_start() /mnt/nfs/labstore-secondary-tools-project/svgtranslate/public_html/svgtranslate.php:321

The bug report is about entering a filename during the first step/page of SVGTranslate.

I can enter "File:Butterworth filter bode plot.svg" and make it to the second page that offers form with the words to translate.

I can enter "http://upload.wikimedia.org/wikipedia/commons/a/a8/Butterworth_filter_bode_plot.svg" and get the same result.

If I enter "https://upload.wikimedia.org/wikipedia/commons/a/a8/Butterworth_filter_bode_plot.svg", then I get an error message.

The instructions on the first page tell the user to enter a WP file or a URL; the example URL uses http: and does not use https:. My guess is the code decides whether it is a URL or a Wikimedia filename by looking for "http:" at the start of the string. Quick, dirty, effective -- until the world switches to https:.

It would be nice if it took https:, but the initial complaint includes the failure of Wikimedia filenames. That is not the behavior that exists today. It will take WM filenames and http: URLs. The previous T138780 bug would given apparent failures for all three varieties. I would have expected this report to show up in March 2016 (Jdx's report is Feb 2016), but the getLangNames may have been changed in a clone first.

I don't read the initial report as accepting a filename name, allowing translation to proceed, and then a failure to save the result. The getLangNames() bug would have prevented reaching the translation page.

I see this bug report being completely resolved if (1) the code is fixed so https: URLs are recognized or (2) it's viewed that SVGTranslate was never intended to take an https: URL so it is just a missing feature. Yes, I know that it bureaucratic doublespeak.

There may well be another bug about saving the result. @Mikey641 made that claim in T138780, but @Aklapper asked Mikey641 to file a separate report for that separate problem. I don't know if Mikey has filed another report. I see this bug as a dup of T138780, and the powers that be apparently want Mikey or @Jdx or someone else to file a report that addresses the failure to upload the translation. I'd be happy with any focused report about upload, but I really don't know what I'm doing around here or what people really want. I don't even know where to report some stupid wrong-case bugs with MediaWiki file handling.

I have never tried to upload a file using SVGTranslate. so I don't know whether both methods (OAuth and plain) fail.

There could be other things going on. The undefined index 16 suggest that there was a problem with one of the 28 translations and SVGTranslate did not handle it well. IIRC, the form requires all fields to filled out before it POSTs, but something else may be happening. SVG uses regular expressions rather than the DOM, so it could have an I-already-substituted-that-string problem ("-60" is translated twice and its index is plausibly 16 the second time around) or some string in the input file may confuse a regular expression. I don't know PHP and only gave the code a cursory read a couple months back. Other notices suggest there was an attempt to get a security token that failed; SVG tries to look at the timestamp but gets nothing because the token isn't there. I don't know how OAuth is supposed to work, so I'm out of my depth here. It could also be as cascade error; errors after the first may be consequences of earlier failures.

On another front, SVGTranslate's approach to translation is poor. There are already ru and sv clones of the file when only 7 phrases need translation. And the SVG file itself is a gnuplot / Inkscape contortion; the plot is crude linear interpolation that does not magnify well; the original PNG file is visually superior. Anyway, to which language are you translating?

Looking at https://github.com/Jarry1250/labs-svgtranslate/blob/master/svgtranslate.php

Line numbers appear off by one.

542: $imagedata = $image->imageinfo( 999 );

apparently builds an array of the image history. The Butterworth filter bode plot only has 2 items of history.

547: $originaluploadindex = count( $imagedata ) - 1;

gets the index of the oldest (original) image history. The value should be 2-1 = 1.

591: $pagetext .= date( "Y-m-d", strtotime( $imagedata[$originaluploadindex]["timestamp"] ) ) . " (upload to Commons)\n";

uses originaluploadindex. Error message for line 592 suggests that originaluploadindex == 16.
The error is bizarre because imagedata should have that many items; maybe "offset 16" means something else (such as hash for accessing "timestamp" key). The implication is imagedata holds garbage rather than the two image histories.

The errors at line 602 are all about reading information out of the (garbage) history array.

600: foreach( $imagedata as $vkey => $cntns ){
601: $pagetext .= "**" . $imagedata[$vkey]["timestamp"] . " [[User:" . $imagedata[$vkey]["user"] . "|" . $imagedata[$vkey]["user"] . "]] " . $imagedata[$vkey]["width"] . "x" . $imagedata[$vkey]["height"] . " (" . $imagedata[$vkey]["size"] . " bytes) ''<nowiki>" . substr( strip_tags( str_replace( "\n", " ", $imagedata[$vkey]["comment"] ) ), 0, 225 ) . "</nowiki>''\n";
602: }

Since imagedata is apparently damaged, it is not surprising that keys such as "timestamp" do not exist.

Then it looks like there are two warnings at line 302 where translation regexs failed.

The remaining errors seem to be synchronization complaints: a header had already transmitted before some additional information was added that needed to be in the header.

SVGTranslate looks at the filename and figures out the appropriate URL using the following method:

On line 185, it checks that the name ends in ".svg".

If the name does not have a slash in it, then it's presumed to be a Wikimedia file name.
Otherwise, it checks if the name starts with "http:"; if it does not, then "http:" is prefixed to the name. (Lines 202 to 206). That would turn "https:..." into "http:https:..." (which won't work).

Thanks for looking into this. The http(s) issue should be fixed in https://github.com/Jarry1250/labs-svgtranslate/commit/5f56f1bc442e0591e9373641784ee68a05047152 . 'Cannot send session cookie - headers already sent' errors are the natural consequence of other error output nixing the proper flow controls. I'll look into the other bugs now.

Incidentally, I agree with you that SVGTranslate is a horrible tool that creates horrible output. (I actually patched MediaWiki to support properly translated SVGs, but have yet to finish a tool I've been working on for years to translate them properly in-browser.)

Jarry1250 claimed this task.

Okay, the tool now seems to work for me following https://github.com/MW-Peachy/Peachy/pull/113 . Let me know if not though.