Remove javascript from href attributes

[MAILPOET-2438]
This commit is contained in:
Rostislav Wolny
2019-10-07 14:54:29 +02:00
committed by Jack Kitterhing
parent e4dd097090
commit 6668be4a03
11 changed files with 84 additions and 36 deletions

View File

@@ -191,7 +191,6 @@ class FormList extends React.Component {
{' '} {' '}
<button <button
className="page-title-action" className="page-title-action"
href="javascript:;"
onClick={this.createForm} onClick={this.createForm}
data-automation-id="create_new_form" data-automation-id="create_new_form"
type="button" type="button"

View File

@@ -26,9 +26,12 @@ class ListingGroups extends React.Component {
<li key={group.name}> <li key={group.name}>
{(index > 0) ? ' |' : ''} {(index > 0) ? ' |' : ''}
<a <a
href="javascript:;" href="#"
className={classes} className={classes}
onClick={() => this.handleSelect(group.name)} onClick={(event) => {
event.preventDefault();
this.handleSelect(group.name);
}}
data-automation-id={`filters_${group.label.replace(' ', '_').toLowerCase()}`} data-automation-id={`filters_${group.label.replace(' ', '_').toLowerCase()}`}
> >
{group.label} {group.label}

View File

@@ -77,8 +77,11 @@ class ListingItem extends React.Component {
{(!isFirst) ? ' | ' : ''} {(!isFirst) ? ' | ' : ''}
<a <a
type="button" type="button"
href="javascript:;" href="#"
onClick={() => this.handleTrashItem(this.props.item.id)} onClick={(event) => {
event.preventDefault();
this.handleTrashItem(this.props.item.id);
}}
> >
{MailPoet.I18n.t('moveToTrash')} {MailPoet.I18n.t('moveToTrash')}
</a> </a>
@@ -122,12 +125,13 @@ class ListingItem extends React.Component {
> >
{(!isFirst) ? ' | ' : ''} {(!isFirst) ? ' | ' : ''}
<a <a
href="javascript:;" href="#"
onClick={ onClick={(event) => {
(action.onClick !== undefined) event.preventDefault();
? () => action.onClick(this.props.item, this.props.onRefreshItems) if (action.onClick !== undefined) {
: false action.onClick(this.props.item, this.props.onRefreshItems);
} }
}}
> >
{ action.label } { action.label }
</a> </a>
@@ -157,8 +161,11 @@ class ListingItem extends React.Component {
<div className="row-actions"> <div className="row-actions">
<span> <span>
<a <a
href="javascript:;" href="#"
onClick={() => this.handleRestoreItem(this.props.item.id)} onClick={(event) => {
event.preventDefault();
this.handleRestoreItem(this.props.item.id);
}}
> >
{MailPoet.I18n.t('restore')} {MailPoet.I18n.t('restore')}
</a> </a>
@@ -167,8 +174,11 @@ class ListingItem extends React.Component {
<span className="delete"> <span className="delete">
<a <a
className="submitdelete" className="submitdelete"
href="javascript:;" href="#"
onClick={() => this.handleDeleteItem(this.props.item.id)} onClick={(event) => {
event.preventDefault();
this.handleDeleteItem(this.props.item.id);
}}
> >
{MailPoet.I18n.t('deletePermanently')} {MailPoet.I18n.t('deletePermanently')}
</a> </a>

View File

@@ -62,8 +62,11 @@ class ListingItems extends React.Component { // eslint-disable-line react/prefer
} }
&nbsp; &nbsp;
<a <a
onClick={this.props.onSelectAll} href="#"
href="javascript:;" onClick={(event) => {
event.preventDefault();
this.props.onSelectAll(event);
}}
> >
{ {
(this.props.selection !== 'all') (this.props.selection !== 'all')

View File

@@ -84,9 +84,12 @@ const MailerError = (props) => {
{ props.mta_method === 'PHPMail' ? <PHPMailerCheckSettingsNotice /> : <MailerCheckSettingsNotice /> } { props.mta_method === 'PHPMail' ? <PHPMailerCheckSettingsNotice /> : <MailerCheckSettingsNotice /> }
<p> <p>
<a <a
href="javascript:;" href="#"
className="button button-primary" className="button button-primary"
onClick={resumeMailerSending} onClick={(event) => {
event.preventDefault();
resumeMailerSending(event);
}}
> >
{ MailPoet.I18n.t('mailerResumeSendingButton') } { MailPoet.I18n.t('mailerResumeSendingButton') }
</a> </a>

View File

@@ -78,8 +78,11 @@ class ListingPages extends React.Component {
if (this.props.page > 1) { if (this.props.page > 1) {
previousPage = ( previousPage = (
<a <a
href="javascript:;" href="#"
onClick={this.setPreviousPage} onClick={(event) => {
event.preventDefault();
this.setPreviousPage(event);
}}
className="prev-page button" className="prev-page button"
> >
<span className="screen-reader-text">{MailPoet.I18n.t('previousPage')}</span> <span className="screen-reader-text">{MailPoet.I18n.t('previousPage')}</span>
@@ -91,8 +94,11 @@ class ListingPages extends React.Component {
if (this.props.page > 2) { if (this.props.page > 2) {
firstPage = ( firstPage = (
<a <a
href="javascript:;" href="#"
onClick={this.setFirstPage} onClick={(event) => {
event.preventDefault();
this.setFirstPage(event);
}}
className="first-page button" className="first-page button"
> >
<span className="screen-reader-text">{MailPoet.I18n.t('firstPage')}</span> <span className="screen-reader-text">{MailPoet.I18n.t('firstPage')}</span>
@@ -104,8 +110,11 @@ class ListingPages extends React.Component {
if (this.props.page < this.getLastPage()) { if (this.props.page < this.getLastPage()) {
nextPage = ( nextPage = (
<a <a
href="javascript:;" href="#"
onClick={this.setNextPage} onClick={(event) => {
event.preventDefault();
this.setNextPage(event);
}}
className="next-page button" className="next-page button"
> >
<span className="screen-reader-text">{MailPoet.I18n.t('nextPage')}</span> <span className="screen-reader-text">{MailPoet.I18n.t('nextPage')}</span>
@@ -117,8 +126,11 @@ class ListingPages extends React.Component {
if (this.props.page < this.getLastPage() - 1) { if (this.props.page < this.getLastPage() - 1) {
lastPage = ( lastPage = (
<a <a
href="javascript:;" href="#"
onClick={this.setLastPage} onClick={(event) => {
event.preventDefault();
this.setLastPage();
}}
className="last-page button" className="last-page button"
> >
<span className="screen-reader-text">{MailPoet.I18n.t('lastPage')}</span> <span className="screen-reader-text">{MailPoet.I18n.t('lastPage')}</span>

View File

@@ -72,8 +72,11 @@ const LinkButton = ({ className, onClick, children }) => (
<a <a
className={classNames('button', className)} className={classNames('button', className)}
style={{ display: 'inline-block' }} style={{ display: 'inline-block' }}
href="javascript:;" href="#"
onClick={onClick} onClick={(event) => {
event.preventDefault();
onClick(event);
}}
> >
{children} {children}
</a> </a>

View File

@@ -193,8 +193,11 @@ class NewsletterListStandard extends React.Component {
<strong> <strong>
<a <a
className="row-title" className="row-title"
href="javascript:;" href="#"
onClick={() => confirmEdit(newsletter)} onClick={(event) => {
event.preventDefault();
confirmEdit(newsletter);
}}
> >
{ newsletter.queue.newsletter_rendered_subject || newsletter.subject } { newsletter.queue.newsletter_rendered_subject || newsletter.subject }
</a> </a>

View File

@@ -152,8 +152,11 @@ const ListingItem = ({
<br /> <br />
<a <a
className="button" className="button"
href="javascript:;" href="#"
onClick={resend} onClick={(event) => {
event.preventDefault();
resend();
}}
> >
{MailPoet.I18n.t('resend')} {MailPoet.I18n.t('resend')}
</a> </a>

View File

@@ -7,9 +7,12 @@ const Tabs = ({ tabs, selected, select }) => (
{tabs.map(({ name, label }) => ( {tabs.map(({ name, label }) => (
<li key={name}> <li key={name}>
<a <a
href="javascript:" href="#"
className={selected === name ? 'current' : ''} className={selected === name ? 'current' : ''}
onClick={() => select(name)} onClick={(event) => {
event.preventDefault();
select(name);
}}
> >
{' '} {' '}
{label} {label}

View File

@@ -104,7 +104,13 @@ class TemplateBox extends React.Component {
let preview = ''; let preview = '';
if (typeof thumbnail === 'string' && thumbnail.length > 0) { if (typeof thumbnail === 'string' && thumbnail.length > 0) {
preview = ( preview = (
<a href="javascript:;" onClick={this.onPreview}> <a
href="#"
onClick={(event) => {
event.preventDefault();
this.onPreview(event);
}}
>
<img src={thumbnail} alt={MailPoet.I18n.t('templatePreview')} loading="lazy" /> <img src={thumbnail} alt={MailPoet.I18n.t('templatePreview')} loading="lazy" />
<div className="mailpoet_overlay"> <div className="mailpoet_overlay">
<p className="mailpoet_more_details">{MailPoet.I18n.t('zoom')}</p> <p className="mailpoet_more_details">{MailPoet.I18n.t('zoom')}</p>