Skip to content

Commit d50457d

Browse files
author
Cari Spruiell
committed
MAGETWO-45436: Eliminate multiple escaping in the inline translation popup
- decoded all special characters before displaying in translation dialog - remove additional encoding from dialog's Custom field
1 parent d2ff2a2 commit d50457d

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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' => htmlspecialchars($matches[1][0]),
369-
'translated' => htmlspecialchars($matches[2][0]),
370-
'original' => $matches[3][0],
371-
'location' => htmlspecialchars(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]));

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ public function deleteTranslate($string, $locale = null, $storeId = null)
209209
public function saveTranslate($string, $translate, $locale = null, $storeId = null)
210210
{
211211
$string = htmlspecialchars_decode($string);
212-
$translate = htmlspecialchars_decode($translate);
213212
$connection = $this->getConnection();
214213
$table = $this->getMainTable();
215214
$translate = htmlspecialchars($translate, ENT_QUOTES);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
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>

0 commit comments

Comments
 (0)