Skip to content

Commit 1079faa

Browse files
Authenticated(Editor+) Stored Cross-Site Scripting (#96)
* Authenticated(Editor+) Stored Cross-Site Scripting * Few other small fixes
1 parent 1572bdc commit 1079faa

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

admin/class-custom-permalinks-post-types-table.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,13 @@ protected function column_title( $item ) {
239239
}
240240

241241
$edit_link = get_edit_post_link( $item['ID'] );
242-
$title_with_edit_link = $post_title;
242+
$title_with_edit_link = esc_html( $post_title );
243243
if ( ! empty( $edit_link ) ) {
244244
$title_with_edit_link = sprintf(
245-
'<a href="%s" target="_blank" title="' . esc_html__( 'Edit ', 'custom-permalinks' ) . ' ' . $post_title . '">%s</a>',
246-
$edit_link,
247-
$post_title
245+
'<a href="%1s" target="_blank" title="%2s">%3s</a>',
246+
esc_url( $edit_link ),
247+
esc_attr__( 'Edit', 'custom-permalinks' ) . ' ' . esc_attr( $post_title ),
248+
$title_with_edit_link
248249
);
249250
}
250251

@@ -283,10 +284,12 @@ protected function column_type( $item ) {
283284
*/
284285
protected function column_permalink( $item ) {
285286
$page_url = get_permalink( $item['ID'] );
287+
$page_url = esc_url( $page_url );
286288

287289
$permalink = sprintf(
288-
'<a href="%s" target="_blank" title="' . esc_html__( 'Visit', 'custom-permalinks' ) . ' ' . $item['post_title'] . '">%s</a>',
290+
'<a href="%1s" target="_blank" title="%2s">%3s</a>',
289291
$page_url,
292+
esc_attr__( 'Visit', 'custom-permalinks' ) . ' ' . esc_attr( $item['post_title'] ),
290293
$page_url
291294
);
292295

admin/class-custom-permalinks-taxonomies-table.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -235,26 +235,22 @@ protected function column_title( $item ) {
235235
$edit_link = '';
236236
$term_title = 'NOT SET';
237237

238-
if ( isset( $item['ID'] ) && isset( $item['type'] ) ) {
239-
$taxonomy_type = 'category';
240-
if ( 'tag' === $item['type'] ) {
241-
$taxonomy_type = 'post_tag';
242-
}
243-
244-
$edit_link = get_edit_term_link( $item['ID'], $taxonomy_type );
245-
$term = get_term( $item['ID'], $taxonomy_type );
238+
if ( isset( $item['ID'] ) ) {
239+
$edit_link = get_edit_term_link( $item['ID'] );
240+
$term = get_term( $item['ID'] );
246241

247-
if ( isset( $term ) && isset( $term->name ) && ! empty( $term->name ) ) {
242+
if ( isset( $term, $term->name ) && ! empty( $term->name ) ) {
248243
$term_title = $term->name;
249244
}
250245
}
251246

252-
$title_with_edit_link = $term_title;
247+
$title_with_edit_link = esc_html( $term_title );
253248
if ( ! empty( $edit_link ) ) {
254249
$title_with_edit_link = sprintf(
255-
'<a href="%s" target="_blank" title="' . esc_html__( 'Edit ', 'custom-permalinks' ) . ' ' . $term_title . '">%s</a>',
256-
$edit_link,
257-
$term_title
250+
'<a href="%1s" target="_blank" title="%2s">%3s</a>',
251+
esc_url( $edit_link ),
252+
esc_attr__( 'Edit', 'custom-permalinks' ) . ' ' . esc_attr( $term_title ),
253+
$title_with_edit_link
258254
);
259255
}
260256

@@ -312,6 +308,7 @@ protected function column_permalink( $item ) {
312308
}
313309
}
314310

311+
$taxonomy_type = $item['type'];
315312
if ( 'tag' === $item['type'] ) {
316313
$taxonomy_type = 'post_tag';
317314
}
@@ -333,17 +330,18 @@ protected function column_permalink( $item ) {
333330
$perm_text = str_replace( $home_url, '', $permalink );
334331

335332
$term_title = '';
336-
if ( isset( $item['ID'] ) && isset( $item['type'] ) ) {
337-
$term = get_term( $item['ID'], $item['type'] );
338-
if ( isset( $term ) && isset( $term->name ) && ! empty( $term->name ) ) {
333+
if ( isset( $item['ID'] ) ) {
334+
$term = get_term( $item['ID'] );
335+
if ( isset( $term, $term->name ) && ! empty( $term->name ) ) {
339336
$term_title = $term->name;
340337
}
341338
}
342339

343340
$permalink = sprintf(
344-
'<a href="%s" target="_blank" title="' . esc_html__( 'Visit', 'custom-permalinks' ) . ' ' . $term_title . '">%s</a>',
345-
$permalink,
346-
$perm_text
341+
'<a href="%1s" target="_blank" title="%2s">%3s</a>',
342+
esc_url( $permalink ),
343+
esc_attr__( 'Visit', 'custom-permalinks' ) . ' ' . esc_attr( $term_title ),
344+
esc_html( $perm_text )
347345
);
348346
}
349347

0 commit comments

Comments
 (0)