Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

htmlClass pattern validation is too restrictive #32004

Closed
1 of 5 tasks
thomas-kl1 opened this issue Feb 9, 2021 · 20 comments
Closed
1 of 5 tasks

htmlClass pattern validation is too restrictive #32004

thomas-kl1 opened this issue Feb 9, 2021 · 20 comments
Assignees
Labels
Area: Framework Component: Code Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: done Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@thomas-kl1
Copy link
Member

thomas-kl1 commented Feb 9, 2021

Resource: https://www.w3.org/TR/CSS22/syndata.html
Part 4.1.3

In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+0080 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier "B&W?" may be written as "B&W?" or "B\26 W\3F".

Preconditions (*)

  1. Add a new container in your layout
  2. Add a htmlClass with a character like "@"

Steps to reproduce (*)

  1. Add a new container in your layout
  2. Add a htmlClass with a character like "@"

Expected result (*)

  1. The container is added to the dom with the correct class attribute value

Actual result (*)

  1. Layout validation fails because it says the character is not allowed

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Feb 9, 2021

Hi @thomas-kl1. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@thomas-kl1
Copy link
Member Author

@magento I am working on this

@ihor-sviziev
Copy link
Contributor

Hi @thomas-kl1,
Could you describe what is the use case of using the @ symbol in the class names? Magento definitely not supporting, but I don't think there is some valid use case for using such things.

@ihor-sviziev ihor-sviziev added the Issue: needs update Additional information is require, waiting for response label Apr 8, 2021
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Apr 8, 2021
@ihor-sviziev ihor-sviziev self-assigned this Apr 8, 2021
@m2-assistant
Copy link

m2-assistant bot commented Apr 8, 2021

Hi @ihor-sviziev. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@m2-community-project m2-community-project bot added the Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”. label Apr 8, 2021
@thomas-kl1
Copy link
Member Author

@ihor-sviziev there is many css framework that use "@ " in classnames. Anyway the current validation it too much restrictive regarding this ressource https://www.w3.org/TR/CSS22/syndata.html

There is no valid point to prevent using other characters and some could be easily escaped thanks to the escaper object.
Many projects I work on, have to use patches to override this rule or to use alternative blocks and templates, which is redundant and could be avoided

@ihor-sviziev ihor-sviziev removed their assignment Apr 9, 2021
@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Apr 9, 2021

TBH I never saw that "at" symbol used in the class names, I also didn't see it in any CSS frameworks, and I personally don't think it's a good idea because it will confuse people. Maybe you could provide some examples?

I still believe this issue having a too-small amount of people. Probably priority for this issue should be P4, which is the lowest priority.

@thomas-kl1
Copy link
Member Author

thomas-kl1 commented Apr 9, 2021

You missed the point. The point: https://www.w3.org/TR/CSS21/syndata.html#value-def-identifier

If you need the full standard documentation, there's the links:

I never saw that "at" symbol used in the class names, I also didn't see it in any CSS frameworks

That's your thought, it doesn't make it true. Some in-house and proprietary frameworks could use chars that are not part of the current rules:

  • [a-zA-Z][a-zA-Z\d\-_:]*
  • [a-zA-Z][a-zA-Z\d\-_]*(\s[a-zA-Z][a-zA-Z\d\-_]*)*

I personally don't think it's a good idea because it will confuse people

That's also your opinion, developers are free to use it or not, so there is no confusion either.

I don't think there is some valid use case for using such things

Since some major companies are using it, it's pretty much valid to me, so it's still opinionated to me

What's the reason behind those Magento's rules? What is the legitimate design to write these regex patterns?
A framework should be a friendly tool for developers to help them to quickly solves common problems. Here it adds a constraint without any reasons.

Also I've used the "@" character as an example, but it could be any that follows the standard:

In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); they cannot start with a digit, two hyphens, or a hyphen followed by a digit. Identifiers can also contain escaped characters and any ISO 10646 character as a numeric code (see next item). For instance, the identifier "B&W?" may be written as "B&W?" or "B\26 W\3F".

We could agree or disagree to use such characters for identifiers, but we might follow the standards. The decision to use such characters is scoped to project, not to the framework.

@ihor-sviziev
Copy link
Contributor

@sivaschenko @sidolov @gabrieldagama, could you review this issue and comment,s and provide your opinion?
Thank you!

@m2-community-project m2-community-project bot added the Priority: P3 May be fixed according to the position in the backlog. label May 25, 2021
@engcom-November engcom-November added the Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it label Apr 7, 2022
@m2-community-project m2-community-project bot added this to Pull Request In Progress in Low Priority Backlog Apr 7, 2022
@MeCapron
Copy link
Contributor

MeCapron commented Jun 15, 2022

Hello,

I'm reopening this issue because it is also a problem for us.

It makes even more sense now that Tailwind is around the place for a lot of projects. The defined xsd is not scalable and do not take in account technologies or evolutions.

As @thomas-kl1 mentioned, this is not only concerning the @ symbol but all symbols accepted by the W3 standards.

Why can't we make this evolve?

@thomas-kl1
Copy link
Member Author

at least colon is now accepted :') 34115de

@MeCapron
Copy link
Contributor

Related to : #36452 which may fix this issue

@engcom-November
Copy link
Contributor

Hi @thomas-kl1 ,
Thanks for the report and collaboration! We have tried to reproduce this issue in Magento 2.4-develop branch but the issue is not reproducible.
We have followed the below steps:

  1. Added a new container in your layout

Container added in app/code/Magento/Ui/view/base/templates/control/button/default.phtml

  1. Added a htmlClass with a character like "@"
    We can able to see the container is added to the dom with the correct class attribute value
    Kindly recheck the issue on Magento 2.4-develop instance and elaborate missing steps if the issue is still reproducible.
    image

@engcom-November engcom-November self-assigned this Jan 27, 2023
@m2-assistant
Copy link

m2-assistant bot commented Jan 27, 2023

Hi @engcom-November. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-November engcom-November added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Jan 27, 2023
@thomas-kl1
Copy link
Member Author

thomas-kl1 commented Jan 27, 2023

@engcom-November sure after 2 years without updates, maybe it have been fixed somewhere by somebody...

@ihor-sviziev
Copy link
Contributor

ihor-sviziev commented Jan 27, 2023

Hi @engcom-November,
From your screenshot I see you don't have attribute "class", but you have "htmlClass", I bet that's the reason why it work for you.
In general, in the page I would expect having something like <div class"w-screen left-1/2 right-1/2 mx-[-50vw] relative @something">...</div>

@thomas-kl1
Copy link
Member Author

Good catch @ihor-sviziev I didn't checked the screenshot 😅

@engcom-November
Copy link
Contributor

engcom-November commented Jan 31, 2023

Hi @ihor-sviziev / @thomas-kl1 , Thank you for the response.
We have tried to reproduce the issue in Magento 2.4-develop branch and the issue has been reproducible for us. We have followed the below steps:

  1. Open any front end file, for example considered /app/code/Magento/catalog/view/frontend/layout/catalog_product_view.xmlChange the
  2. html class name to htmlClass="w-screen left-1/2 right-1/2 mx-[-50vw] relative @something"
  3. Deploy static content and flush cache
  4. Front end - Open the Product details page from any catagory.
    Were getting an error page
    image

Hence confirming the issue.

@engcom-November engcom-November added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Component: Code Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Reported on 2.4.x Indicates original Magento version for the Issue report. Area: Framework labels Jan 31, 2023
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-7854 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Jan 31, 2023

✅ Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@engcom-November engcom-November removed Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: needs update Additional information is require, waiting for response labels Jan 31, 2023
@thomas-kl1
Copy link
Member Author

thomas-kl1 commented Mar 14, 2023

Fixed by #36452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Component: Code Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P3 May be fixed according to the position in the backlog. Progress: done Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Severity: S4 Affects aesthetics, professional look and feel, “quality” or “usability”. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Development

Successfully merging a pull request may close this issue.

5 participants