Commit graph

56 commits

Author SHA1 Message Date
Umherirrender c6023ed58c Use namespaced Xml class
Change-Id: I1cc4f8a077621d5c4af9ffc82f139b3a3a8bb69d
2024-10-20 01:20:58 +02:00
Umherirrender 4fc3c8fc7b Use namespaced Parser class
Change-Id: Ibbd84c533498a4a99a76569f4c362964bb3489fb
2024-06-09 11:41:27 +02:00
Umherirrender b2463a3c11 build: Upgrade mediawiki/mediawiki-codesniffer to v43.0.0
Change-Id: I4ca71737ae99fe58139f9e9e69129c83334c502b
2024-03-11 19:24:14 +01:00
Arlo Breault 0c88ab1abd Use Parsoid's extension API's getExternalLinkAttribs
Depends-On: I31a8c6a9bb2741899d5445c3457fd424e283397b
Change-Id: Iaf8531a37e8d9d3ce1bece9ab3086e5967dca08f
2024-03-04 18:00:04 -05:00
jenkins-bot 4b0aa6c502 Merge "Revert "Filter out null external link attributes"" 2024-02-16 16:19:19 +00:00
Gergő Tisza b5f8605406 Revert "Filter out null external link attributes"
This reverts commit 760641e180.

Reason for revert: it was a quick fix, has been fixed properly in core
instead in I907c22ef070616d81b9a50b0e807a7b8f78b59b5.

Bug: T357668
Change-Id: I4ec440c1e326419a8be5457b79c5374316755a53
2024-02-16 15:34:54 +00:00
Arlo Breault 4d19d19f1d Fix matching external link rel
Introduced in I8d7bdf1bccc869b4dc17058a5822ef34968471e6

Change-Id: I52a8a993fbdd4058d40f4aeac3df37e90e686f3e
2024-02-15 21:24:59 -05:00
Gergő Tisza 760641e180 Filter out null external link attributes
Follows up If4880e4e0b3cd2056521d44baf261ed848511bcd.

Bug: T357668
Change-Id: Ifec733a923f193b72eaba9a1e604ad4e56c0aef2
2024-02-15 21:24:59 +00:00
Alexander Mashin 754b722c56 Set target to $wgExternalLinkTarget
Set hyperlink 'target' attribute to $wgExternalLinkTarget.

In addition, set the 'rel' attribute according to the
$wgNoFollowLinks, $wgNoFollowDomainExceptions
and $wgNoFollowNsExceptions settings (bug T186241).

Bug: T356730
Change-Id: If4880e4e0b3cd2056521d44baf261ed848511bcd
2024-02-06 16:09:32 +07:00
Subramanya Sastry 655ea71656 Use the namespaced versions of some class names (vs aliases)
Change-Id: Idc350cfc4ece2eaa73f8cd2a0a97b839d4caf37e
2024-01-02 13:50:14 -06:00
Subramanya Sastry 66ec96d6b1 ParsoidImageMap: use wfMessage to localize description types
* The previously failing Parsoid test now passes.

Bug: T311523
Depends-On: Id7d9e82ee4ff20a79ba1a5b2433fa29bc5f76e68
Change-Id: I03115b91fd781b72f0bf2c66cb6c18963a772dab
2023-10-09 12:21:35 -05:00
Umherirrender 9b9ef62a4c Remove null fallback from DOMElement::getAttribute
Also set @phan-var to handle nullable parentNode
DOMNode::$parentNode is documented as nullable in php8.1
DOMElement::getAttribute is documented to return string in php8.1
Reported by phan running under php8.1

Change-Id: Ia4abd7bf03bc52d7d4ba2c69738bb90c55d01a2b
2023-10-06 20:08:08 +02:00
Subramanya Sastry d9a7fea019 Move Parsoid implementation of ImageMap from Parsoid repo
* There have been no changes to the code except for:
  - class is now called ParsoidImageMap with a matching file name
  - the namespace is changed to MediaWiki\Extension\ImageMap.
  - adding phan directives to deal with Parsoid's DOM proxies
    which phan doesn't seem to be see here.

* Parsoid's SiteConfig extension registration code simply overwrites
  the extConfig array for a tag name. So, keeping the config and
  implementation identical ensures that no matter which version of
  code is registered (based on load order), we get the same behavior.

* Once this rolls out on the next train, we can remove the code
  from Parsoid.

* Future patches might refactor the two implementations to extract
  common functionality or merge code into a single file.

Change-Id: I6cffa4420d2daa70174fa926d5c7a4d983792969
2023-09-19 16:21:40 -05:00
gerritbot d3b897ffa1 Replace some moved Title class uses, now MediaWiki\Title\Title
Bug: T321681
Change-Id: I181ab0a62d32ddcab818b48f2d0301b0374a54d9
2023-08-19 12:02:23 +00:00
Arlo Breault 96c60d44ca Add resource for thumb magnify links
Bug: T329413
Depends-On: Id46d1b2ab1af3baebff13e10f1485f3cfd9a4b37
Change-Id: Idec1b8dc1c742ca6ea3b24f3b14738c2d1f5b01d
2023-05-25 16:09:06 +00:00
Arlo Breault b2113e0154 Add back description links when !$wgParserEnableLegacyMediaDOM
The approach taken here is the same as in core for magnify links on
thumbs in Id46d1b2ab1af3baebff13e10f1485f3cfd9a4b37

The gist is that resource attributes are added on the mw-file-element so
that the necessary url is present in the html.  A class is also added to
the wrapper element that designates where the link should be positioned.
Finally, a script adds the link which styles in appropriately.

Bug: T329364
Depends-On: Id46d1b2ab1af3baebff13e10f1485f3cfd9a4b37
Change-Id: I20130fd39135dfd5074590ee9c2b6e01693384e4
2023-05-22 15:22:42 +00:00
Arlo Breault 6d83c5bc21 Fix adding titles when caption isn't visible
This was added in Ic0169d3914c5ce442b063f4bbbb6493966dbb302 and it
looks wrong on a few levels: the format isn't captured, and only
mw:File is emitted now.

Change-Id: I5aff7b53348696c485ef5683f6aab7aaafac4973
2023-04-27 13:34:16 +00:00
Umherirrender 4b479f6427 Replace deprecated ConfigFactory::getDefaultInstance
Bug: T325966
Change-Id: I2bbaa9d1a65e4f33cb9d919237d8664e3f74a51e
2022-12-27 21:10:16 +01:00
Bartosz Dziewoński c8c8b9c735 Avoid Phan PhanUndeclaredMethod false positives
The insertBefore() and appendChild() methods return their first
argument, but Phan only knows that they return a DOMNode, even though
we passed in a DOMElement. Rearrange slightly to avoid this pattern.

Change-Id: I04c58458e1ba0d728374ead756afb6facf970766
2022-11-25 18:37:02 +00:00
Bartosz Dziewoński 2cc6549898 Use Parsoid's HTML5-compliant helpers for HTML transformations
Previously XML parsing and serialization was used, causing `<br>`
to be disallowed and `<br />` to turn into `<br></br>`.

Also update some uses of XPath to use querySelector() helper.

Bug: T113791
Change-Id: Ic2069015b4cbb5d05a72eb383052319048111623
2022-11-25 17:05:24 +00:00
Reedy 76a921145e Switch to HookHandlers
Bug: T271015
Change-Id: I3a0b766dd9f64494a842f1bb1e64f6a51b146692
2022-08-26 19:13:13 +00:00
Arlo Breault 75f95fbc1e Place tooltips if caption isn't visible
Matches Parsoid commit Icbc36b6e9aa1b9f4f27c23f4833c626a725cc154

Bug: T297443
Bug: T108380
Depends-On: I30eba0fb226971ddeda4eb240929e89ef7e5f45f
Change-Id: Ic0169d3914c5ce442b063f4bbbb6493966dbb302
2022-05-16 19:22:03 -04:00
Reedy e0ef563437 Correct namespacing to match best practices
Bug: T303105
Change-Id: Ie72eb7c2dfcf9a7d5f95e9130d3631f2aa7d542e
2022-03-05 15:10:40 +00:00
jenkins-bot 5d8fc50038 Merge "Account for strtok boolean return type" 2022-02-26 04:47:48 +00:00
Arlo Breault 375570b616 Account for strtok boolean return type
This has been around for 16 years (since 284a684c) but throws when
strict_types are enforced.

Ternary is fine here since "0" doesn't seem like a legitimate type.

Bug: T302093
Change-Id: I1d2087ba28496e26c2718387cd735541698351f0
2022-02-25 18:53:47 -05:00
Reedy bf2da4d9d3 Replace usages of Wikimedia\(suppress|restore)Warnings()
Change-Id: Ic092d27608f5a309617498789dab36d1c7088dfa
2022-02-24 21:20:40 +00:00
Arlo Breault 124cff0cb2 Handle link= file option
This only crashed the legacy output.

Bug: T294467
Change-Id: I4c44c0d04a0726c88d4ec9a7efbfd5e0a49d4437
2021-11-24 18:00:23 -05:00
Arlo Breault ee3e717a52 Force block imagemaps when !$enableLegacyMediaDOM
Matches the implementation in Idb576004a58f0949b824a46d26dab7d715268ca4

Bug: T290044
Change-Id: I3971471dd4f56d9df9246dc571a4c42cfe424867
2021-09-08 20:08:13 -04:00
Arlo Breault 66cc306cbe Update ImageMap for new media structure
Bug: T272186
Change-Id: I5544b7274316248773f191eb7ecd08088473fcd9
2021-08-12 19:00:19 -04:00
libraryupgrader f66f1a81d5 build: Updating mediawiki/mediawiki-phan-config to 0.10.5
Change-Id: Icabfa063e34d2d09de7bf8b3154682ac1c4682f0
2020-12-10 15:11:24 +00:00
libraryupgrader 70257f4768 build: Updating mediawiki/mediawiki-phan-config to 0.10.4
Change-Id: I08d86d940369267b661e05628578ce81802773f4
2020-11-20 13:15:43 +00:00
jenkins-bot 37d7e591a0 Merge "Modernize ImageMap implementation a bit" 2020-07-03 03:13:48 +00:00
libraryupgrader f775561eba build: Updating mediawiki/mediawiki-phan-config to 0.10.2
Additional changes:
* Removed phan-taint-check-plugin from extra, now inherited from mediawiki-phan-config.

Change-Id: I48df539047c1a2a481969ebd3736d73a52fbdbe6
2020-06-02 19:34:16 +00:00
jenkins-bot 30883c721d Merge "Remove unused $id property" 2020-05-22 07:00:11 +00:00
Thiemo Kreuz 826f5f6ffb Modernize ImageMap implementation a bit
Notable:
* Use strict === for string comparisons.
* Use ?? instead of isset(), where it makes sense.
* Avoid expensive recursiveTagParse() with empty strings.
* Add strict Parser type hint. Note this would have failed anyway
  because the code below just assumes this is a Parser.
* Use the actual $lineNum from the loop instead of manually counting.
  Note the loop is 0-based, while $lineNum is meant to be 1-based.
  Therefor the ++.

Change-Id: I907b6c9ce3eef404dc7f048c14c4707dd1d0d98a
2020-05-20 08:48:52 +02:00
Thiemo Kreuz da2838adfc Remove unused $id property
Unused since Ia906b46 (March 2019, not linked to a Phabricator
ticket).

Change-Id: Ie57b9da09a840eacac3eff2f7794fa9e352f28da
2020-05-20 08:32:04 +02:00
DannyS712 c765a86777 Fix PSR12.Properties.ConstantVisibility.NotFound
Bug: T253169
Change-Id: I44a288dc7f754af13991f949cfc180c19da782ec
2020-05-19 23:21:15 +00:00
Reedy 9e45ad3f6f Namespace extension
Change-Id: Ifbbb52819789bf5ad3e35dd56f6e1f48f1d85aba
2020-04-19 01:18:57 +00:00
Arlo Breault edb47bb2d4 Fix imagemap_invalid_coord message
Looks like this was introduced in 28bb0b5

Change-Id: Ic51accc74006fe64df80bb2ff58e4fd7b0274936
2020-04-06 12:29:06 -04:00
C. Scott Ananian 6b4e6becb5 Use Parser::getTitle(), not @internal $parser->mTitle field
Change-Id: I45b9f4a22e89ee7729ecf51f2cd452556f629205
2020-03-30 13:14:12 -04:00
Umherirrender 313fba8175 Use MediaWikiServices::getBadFileLookup
This required MediaWiki 1.34 (already set in extension.json)

Change-Id: I6a7e51fed5718c33de67a530ce032f8725e0bfcc
2020-03-14 21:14:32 +01:00
Umherirrender c6a8e7fefe Use MediaWikiServices::getRepoGroup
This required MediaWiki 1.34

Change-Id: I4c0887e2d9fc8882805292d7ea5dbc0a68ce34a8
2020-03-14 14:36:27 +01:00
libraryupgrader a2b3060bce build: Updating composer dependencies
* jakub-onderka/php-console-highlighter: 0.3.2 → 0.4.0
* mediawiki/minus-x: 0.3.2 → 1.0.0
* mediawiki/mediawiki-phan-config: 0.9.0 → 0.9.2

Change-Id: I8141f11390205d00a11b819de03e796e08cc8f88
2020-02-19 19:21:15 +00:00
libraryupgrader 4fb2612a0c build: Updating mediawiki/mediawiki-codesniffer to 29.0.0
Additional changes:
* Also sorted "composer fix" command to run phpcbf last.

Change-Id: Ibf8a07b82fd03c38f1a07eef445c751c8a7a273b
2020-01-14 05:57:36 +00:00
libraryupgrader bbe82f0371 build: Updating mediawiki/mediawiki-phan-config to 0.9.0
Additional changes:
* Added .eslintcache to .gitignore.

Change-Id: I9e04f1ed8c96fcd92d8232f39b169ae3d0dff029
2019-12-27 19:03:37 +00:00
Max Semenik f5427d519d Stop passing objects by reference
Bug: T193950
Change-Id: Iefb9848806d5e73fdebe0e31d16b362e101347a1
2019-11-14 23:42:52 -08:00
Ed Sanders 28bb0b502f Rewrite tokenizeCoords to use a while loop, and use it for 'poly'
This provides consistent token validation for
'poly', 'rect' & 'circle'.

Change-Id: I2f558b57dbd93b3bf8ed1762d10ba94772f48a15
2019-10-11 21:00:23 +00:00
Ed Sanders b024fddb4d Make mapName deterministic so it can be tested
Change-Id: Ia906b46fbe8d84ae1482f8efaeb609d08c53bfa8
2019-08-30 17:43:37 +01:00
Alex Ezell 9f962fbad1 Allow negative coordinates in poly image maps
Previous attempts to clean this up followed similar logic to the
circle and rect types of imagemaps. However, in reality, we have
many image maps in our content that have negative values for poly
coordinates. While this isn't logical, breaking them so loudly
in the page isn't desirable.

This change then removes the check for positive value and passes
along the negative coordinate.

Bug: T217087
Change-Id: I0ee84f059dacde79a7e4fb0a172ac6937360d864
2019-04-11 09:23:14 -04:00
Ed Sanders fb20685b48 Use is_numeric instead of ctype_digit for 'poly' validation
Duplicates the logic from tokenizeCoords which is used by
'rect' & 'circle'.

Bug: T217087
Change-Id: I7c59bb9ea410bae8800922356829bca669d2e69c
2019-03-31 00:21:43 +00:00