Skip to content

Commit 2102fc9

Browse files
author
Paliarush, Alexander(apaliarush)
committed
Merge pull request #170 from magento-api/MAGETWO-45350-Inline-Translation
[API + Ogres] Bug fixes
2 parents 071413e + 1310a77 commit 2102fc9

File tree

6 files changed

+47
-44
lines changed

6 files changed

+47
-44
lines changed

app/code/Magento/Translation/Model/Inline/Parser.php

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ protected function _applySpecialTagsFormat($tagHtml, $tagName, $trArr)
311311
{
312312
$specialTags = $tagHtml . '<span class="translate-inline-' . $tagName . '" ' . $this->_getHtmlAttribute(
313313
self::DATA_TRANSLATE,
314-
htmlspecialchars('[' . join(',', $trArr) . ']')
314+
'[' . join(',', $trArr) . ']'
315315
);
316316
$additionalAttr = $this->_getAdditionalHtmlAttribute($tagName);
317317
if ($additionalAttr !== null) {
@@ -365,10 +365,10 @@ private function _getTranslateData($regexp, &$text, $locationCallback, $options
365365
while (preg_match($regexp, $text, $matches, PREG_OFFSET_CAPTURE, $next)) {
366366
$trArr[] = json_encode(
367367
[
368-
'shown' => $matches[1][0],
369-
'translated' => $matches[2][0],
370-
'original' => $matches[3][0],
371-
'location' => call_user_func($locationCallback, $matches, $options),
368+
'shown' => htmlspecialchars_decode($matches[1][0]),
369+
'translated' => htmlspecialchars_decode($matches[2][0]),
370+
'original' => htmlspecialchars_decode($matches[3][0]),
371+
'location' => htmlspecialchars_decode(call_user_func($locationCallback, $matches, $options)),
372372
]
373373
);
374374
$text = substr_replace($text, $matches[1][0], $matches[0][1], strlen($matches[0][0]));
@@ -411,15 +411,14 @@ private function _prepareTagAttributesForContent(&$content)
411411
) . '#i';
412412
if (preg_match($transRegExp, $tagHtml, $matches)) {
413413
$tagHtml = str_replace($matches[0], '', $tagHtml);
414-
//remove tra
415414
$trAttr = ' ' . $this->_getHtmlAttribute(
416415
self::DATA_TRANSLATE,
417-
htmlspecialchars('[' . $matches[1] . ',' . join(',', $trArr) . ']')
416+
'[' . htmlspecialchars($matches[1]) . ',' . join(',', $trArr) . ']'
418417
);
419418
} else {
420419
$trAttr = ' ' . $this->_getHtmlAttribute(
421420
self::DATA_TRANSLATE,
422-
htmlspecialchars('[' . join(',', $trArr) . ']')
421+
'[' . join(',', $trArr) . ']'
423422
);
424423
}
425424
$trAttr = $this->_addTranslateAttribute($trAttr);
@@ -581,16 +580,16 @@ private function _otherText()
581580
while (preg_match('#' . self::REGEXP_TOKEN . '#', $this->_content, $matches, PREG_OFFSET_CAPTURE, $next)) {
582581
$translateProperties = json_encode(
583582
[
584-
'shown' => $matches[1][0],
585-
'translated' => $matches[2][0],
583+
'shown' => htmlspecialchars($matches[1][0]),
584+
'translated' => htmlspecialchars($matches[2][0]),
586585
'original' => $matches[3][0],
587586
'location' => 'Text',
588-
'scope' => $matches[4][0],
587+
'scope' => htmlspecialchars($matches[4][0]),
589588
]
590589
);
591590

592591
$spanHtml = $this->_getDataTranslateSpan(
593-
htmlspecialchars('[' . $translateProperties . ']'),
592+
'[' . htmlspecialchars($translateProperties) . ']',
594593
$matches[1][0]
595594
);
596595
$this->_content = substr_replace($this->_content, $spanHtml, $matches[0][1], strlen($matches[0][0]));

app/code/Magento/Translation/Model/ResourceModel/StringUtils.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ public function deleteTranslate($string, $locale = null, $storeId = null)
208208
*/
209209
public function saveTranslate($string, $translate, $locale = null, $storeId = null)
210210
{
211+
$string = htmlspecialchars_decode($string);
211212
$connection = $this->getConnection();
212213
$table = $this->getMainTable();
213214
$translate = htmlspecialchars($translate, ENT_QUOTES);

app/code/Magento/Translation/view/adminhtml/templates/translate_inline.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@
3838
<label for="custom_<%- i %>">Custom:</label>
3939
</th>
4040
<td class="value">
41-
<input name="translate[<%- i %>][original]" type="hidden" value="<%- data.escape(item.original) %>"/>
41+
<input name="translate[<%- i %>][original]" type="hidden" value="<%- item.original %>"/>
4242
<input id="custom_<%- i %>"
4343
name="translate[<%- i %>][custom]"
4444
class="input-text"
45-
value="<%- data.escape(item.translated) %>" />
45+
value="<%- item.translated %>" />
4646
</td>
4747
</tr>
4848
</table></div>

app/code/Magento/Translation/view/frontend/templates/translate_inline.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
<label for="custom_<%- i %>">Custom:</label>
4040
</th>
4141
<td class="value">
42-
<input name="translate[<%- i %>][original]" type="hidden" value="<%- data.escape(item.original) %>"/>
42+
<input name="translate[<%- i %>][original]" type="hidden" value="<%- item.original %>"/>
4343
<input id="custom_<%- i %>"
4444
name="translate[<%- i %>][custom]"
4545
class="input-text"
46-
value="<%- data.escape(item.translated) %>" />
46+
value="<%- item.translated %>" />
4747
</td>
4848
</tr>
4949
</table>

setup/view/error/401.phtml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
// @codingStandardsIgnoreFile
88

99
?>
10+
<script>
11+
document.title = 'Magento Setup - 401 Unauthorized Access';
12+
</script>
1013
<section class="page-landing">
1114
<img class="logo" src="<?php echo $this->basePath() ?>/pub/images/magento-logo.svg" alt="Magento"/>
1215
<p class="text-welcome">

setup/view/layout/layout.phtml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,34 @@
1818
->appendStylesheet($this->basePath() . '/pub/styles/setup.css');
1919
?>
2020
<?php echo $this->headScript()
21-
->appendFile('pub/angular/angular.min.js')
22-
->appendFile('pub/angular-ng-storage/angular-ng-storage.min.js')
23-
->appendFile('pub/angular-ng-dialog/angular-ng-dialog.min.js')
24-
->appendFile('pub/angular-clickout/angular-clickout.min.js')
25-
->appendFile('pub/angular-ui-router/angular-ui-router.min.js')
26-
->appendFile('pub/angular-ui-bootstrap/angular-ui-bootstrap.min.js')
27-
->appendFile('pub/angular-sanitize/angular-sanitize.min.js')
28-
->appendFile('pub/magento/setup/app.js')
29-
->appendFile('pub/magento/setup/main.js')
30-
->appendFile('pub/magento/setup/landing.js')
31-
->appendFile('pub/magento/setup/component-grid.js')
32-
->appendFile('pub/magento/setup/readiness-check.js')
33-
->appendFile('pub/magento/setup/add-database.js')
34-
->appendFile('pub/magento/setup/web-configuration.js')
35-
->appendFile('pub/magento/setup/customize-your-store.js')
36-
->appendFile('pub/magento/setup/create-admin-account.js')
37-
->appendFile('pub/magento/setup/install.js')
38-
->appendFile('pub/magento/setup/success.js')
39-
->appendFile('pub/magento/setup/create-backup.js')
40-
->appendFile('pub/magento/setup/complete-backup.js')
41-
->appendFile('pub/magento/setup/data-option.js')
42-
->appendFile('pub/magento/setup/start-updater.js')
43-
->appendFile('pub/magento/setup/updater-success.js')
44-
->appendFile('pub/magento/setup/select-version.js')
45-
->appendFile('pub/magento/setup/home.js')
46-
->appendFile('pub/magento/setup/auth-dialog.js')
47-
->appendFile('pub/magento/setup/system-config.js')
48-
->appendFile('pub/magento/setup/install-extension-grid.js');
21+
->appendFile($this->basePath() . '/pub/angular/angular.min.js')
22+
->appendFile($this->basePath() . '/pub/angular-ng-storage/angular-ng-storage.min.js')
23+
->appendFile($this->basePath() . '/pub/angular-ng-dialog/angular-ng-dialog.min.js')
24+
->appendFile($this->basePath() . '/pub/angular-clickout/angular-clickout.min.js')
25+
->appendFile($this->basePath() . '/pub/angular-ui-router/angular-ui-router.min.js')
26+
->appendFile($this->basePath() . '/pub/angular-ui-bootstrap/angular-ui-bootstrap.min.js')
27+
->appendFile($this->basePath() . '/pub/angular-sanitize/angular-sanitize.min.js')
28+
->appendFile($this->basePath() . '/pub/magento/setup/app.js')
29+
->appendFile($this->basePath() . '/pub/magento/setup/main.js')
30+
->appendFile($this->basePath() . '/pub/magento/setup/landing.js')
31+
->appendFile($this->basePath() . '/pub/magento/setup/component-grid.js')
32+
->appendFile($this->basePath() . '/pub/magento/setup/readiness-check.js')
33+
->appendFile($this->basePath() . '/pub/magento/setup/add-database.js')
34+
->appendFile($this->basePath() . '/pub/magento/setup/web-configuration.js')
35+
->appendFile($this->basePath() . '/pub/magento/setup/customize-your-store.js')
36+
->appendFile($this->basePath() . '/pub/magento/setup/create-admin-account.js')
37+
->appendFile($this->basePath() . '/pub/magento/setup/install.js')
38+
->appendFile($this->basePath() . '/pub/magento/setup/success.js')
39+
->appendFile($this->basePath() . '/pub/magento/setup/create-backup.js')
40+
->appendFile($this->basePath() . '/pub/magento/setup/complete-backup.js')
41+
->appendFile($this->basePath() . '/pub/magento/setup/data-option.js')
42+
->appendFile($this->basePath() . '/pub/magento/setup/start-updater.js')
43+
->appendFile($this->basePath() . '/pub/magento/setup/updater-success.js')
44+
->appendFile($this->basePath() . '/pub/magento/setup/select-version.js')
45+
->appendFile($this->basePath() . '/pub/magento/setup/home.js')
46+
->appendFile($this->basePath() . '/pub/magento/setup/auth-dialog.js')
47+
->appendFile($this->basePath() . '/pub/magento/setup/system-config.js')
48+
->appendFile($this->basePath() . '/pub/magento/setup/install-extension-grid.js');
4949
?>
5050
<link
5151
rel="icon"

0 commit comments

Comments
 (0)