WordPress.org

Make WordPress Core

Opened 6 weeks ago

Last modified 6 hours ago

#42802 new defect (bug)

Custom HTML widget validation error

Reported by: markemark Owned by:
Milestone: 4.9.3 Priority: normal
Severity: normal Version: 4.9.1
Component: Widgets Keywords: reporter-feedback needs-testing has-patch
Focuses: javascript, administration Cc:

Description

Hi there, recently updated to latest wordpress version 4.9.1
Now custom html widget, which works, now I cannot save, says there is a validation error, so I cannot edit and save.

Here is the html (with external javascript)

<div class="cta_addtocart">
<h3>Sober Intervention Training</h3>
<p>(Course Delivered in English)</p>
<p class="space">Just 20 places in total</p>

<p class="days">3 DAYS - Friday 16th February 2018 - Sunday 18th February 2018</p>

<p class="where">Tegnérgatan 24, 113 59 Stockholm, Sweden</p>

<script type='text/javascript' src='https://www.universe.com/embed2.js'></script>
[x_button type='flat' shape='rounded' size='large' href='https://www.universe.com/events/sober-academy-sober-intervention-training-tickets-9TFQX2' title='Sober Intervention Training -
 Stockholm']Get Tickets[/x_button]

</div>

I have tried with and without "type='text/javascript'" - but still error, therefore I cannot edit?

Can you please fix ?

Attachments (3)

42802.patch (34.7 KB) - added by sasiddiqui 6 weeks ago.
Convert the error to warning for single quotes instead of double quotes
42802.2.patch (34.7 KB) - added by sasiddiqui 6 weeks ago.
Changed the message of the error as well.
42802-remove-rul.patch (513 bytes) - added by sasiddiqui 6 weeks ago.
Making "attr-value-double-quotes" to false

Download all attachments as: .zip

Change History (15)

#1 @westonruter
6 weeks ago

  • Keywords reporter-feedback added

@markemark What is the validation error you are getting?

#2 @sasiddiqui
6 weeks ago

  • Keywords dev-feedback added

@markemark You are getting error due to the quotation issue on type and src. You need to define the type and src attribute in double quotes instead of single quote.

So, Your code something looks like this:

<div class="cta_addtocart">
<h3>Sober Intervention Training</h3>
<p>(Course Delivered in English)</p>
<p class="space">Just 20 places in total</p>

<p class="days">3 DAYS - Friday 16th February 2018 - Sunday 18th February 2018</p>

<p class="where">Tegnérgatan 24, 113 59 Stockholm, Sweden</p>

<script type="text/javascript" src="https://www.universe.com/embed2.js"></script>
[x_button type='flat' shape='rounded' size='large' href='https://www.universe.com/events/sober-academy-sober-intervention-training-tickets-9TFQX2' title='Sober Intervention Training -
 Stockholm']Get Tickets[/x_button]

</div>

Hope, it helps you :)

#3 @westonruter
6 weeks ago

It's either that or an issue with unfiltered_html. Really the use of single quotes shouldn't be an error. It should be a warning at most.

@sasiddiqui
6 weeks ago

Convert the error to warning for single quotes instead of double quotes

@sasiddiqui
6 weeks ago

Changed the message of the error as well.

#4 @sasiddiqui
6 weeks ago

  • Keywords has-patch needs-testing added

Patch has been added for changing the error to warning and the message as well. Please refer:

https://core.trac.wordpress.org/attachment/ticket/42802/42802.2.patch

Previous Message:
Attribute values must be in double quotes.

Updated Message:
Attribute values should be in double quotes.

#5 @westonruter
6 weeks ago

  • Keywords dev-feedback removed
  • Milestone changed from Awaiting Review to 4.9.2

@sasiddiqui Patching HTMLHint isn't going to be the right solution. Instead, the attr-value-double-quotes rule should just be removed: https://github.com/WordPress/wordpress-develop/blob/1c2b0762c7f1a91394c633ae812505919bd297ed/src/wp-includes/general-template.php#L3253

@markemark Please confirm which validation error message you're setting.

#6 @westonruter
6 weeks ago

  • Keywords needs-patch added; has-patch removed

@sasiddiqui
6 weeks ago

Making "attr-value-double-quotes" to false

#7 @sasiddiqui
6 weeks ago

@westonruter I have patched HTMLHint to make doublw quotes error to warning as i thought it should be warned to user when single quote with attributes it doesn't need to be removed.

Anyways, if you just want to remove the rule so you just make it false for now.

#8 @westonruter
6 weeks ago

  • Keywords has-patch added; needs-patch removed

Just waiting for @markemark to respond to confirm the issue.

#9 @westonruter
8 days ago

#42988 was marked as a duplicate.

#10 @westonruter
33 hours ago

@markemark please confirm that the 42802-remove-rul.patch fixes the issue so we can merge into the next release.

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.


33 hours ago

#12 @dd32
6 hours ago

  • Milestone changed from 4.9.2 to 4.9.3

Bumping to 4.9.3 due to 4.9.2s release

Note: See TracTickets for help on using tickets.