WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 22 months ago

#42802 closed defect (bug) (fixed)

Custom HTML widget validation error

Reported by: markemark Owned by: westonruter
Milestone: 4.9.3 Priority: normal
Severity: normal Version: 4.9
Component: Widgets Keywords: has-patch fixed-major
Focuses: javascript, administration Cc:
PR Number:

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 2 years ago.
Convert the error to warning for single quotes instead of double quotes
42802.2.patch (34.7 KB) - added by sasiddiqui 2 years ago.
Changed the message of the error as well.
42802-remove-rul.patch (513 bytes) - added by sasiddiqui 2 years ago.
Making "attr-value-double-quotes" to false

Download all attachments as: .zip

Change History (21)

#1 @westonruter
2 years ago

  • Keywords reporter-feedback added

@markemark What is the validation error you are getting?

#2 @sasiddiqui
2 years 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
2 years 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
2 years ago

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

@sasiddiqui
2 years ago

Changed the message of the error as well.

#4 @sasiddiqui
2 years 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
2 years 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
2 years ago

  • Keywords needs-patch added; has-patch removed

@sasiddiqui
2 years ago

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

#7 @sasiddiqui
2 years 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
2 years ago

  • Keywords has-patch added; needs-patch removed

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

#9 @westonruter
23 months ago

#42988 was marked as a duplicate.

#10 @westonruter
22 months 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.


22 months ago

#12 @dd32
22 months ago

  • Milestone changed from 4.9.2 to 4.9.3

Bumping to 4.9.3 due to 4.9.2s release

#13 @sasiddiqui
22 months ago

@markemark Kindly get sometime from your schedule and check 42802-remove-rul.patch either it fixes your defined issue or not.

Please provide your feedback after testing it.

Thanks

#14 @sasiddiqui
22 months ago

@westonruter Can i own this ticket?

#15 @westonruter
22 months ago

  • Owner set to westonruter
  • Status changed from new to accepted
  • Version changed from 4.9.1 to 4.9

@sasiddiqui I don't think there's anything else to do here to own. I just need to commit. I would have preferred to have @markemark test it first, however.

#16 @westonruter
22 months ago

  • Resolution set to fixed
  • Status changed from accepted to closed

In 42531:

Code Editor: Disable attr-value-double-quotes HTMLHint rule since too strict for user input.

Using single-quoted attribute values is not in any way invalid HTML.

Amends [41376].
Props sasiddiqui.
See #12423.
Fixes #42802.

#17 @westonruter
22 months ago

  • Keywords fixed-major added; reporter-feedback needs-testing removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

#18 @westonruter
22 months ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 42532:

Code Editor: Disable attr-value-double-quotes HTMLHint rule since too strict for user input.

Using single-quoted attribute values is not in any way invalid HTML.

Amends [41376].
Props sasiddiqui.
See #12423.
Fixes #42802 for 4.9 branch.

Note: See TracTickets for help on using tickets.